[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] add version queries and version checks (issue 1861)

From: Edmund Horner <chrysophylax_at_chrysophylax.cjb.net>
Date: 2004-07-06 11:48:40 CEST

Greg Hudson wrote:
> On Mon, 2004-07-05 at 02:01, Edmund Horner wrote:
>
>>However I have added svn_libname__version() functions
>>for the plugin libraries.
>
> Pointless and messy. Until such a time as the vtable work is done to
> make it possible to query an FS or RA module's version after loading it,
> don't add any symbols like this.
>
> (There's no urgency to doing this work, since the RA/FS ABI version will
> serve in the meantime.)

Righty ho.

I have removed the svn_libname__version() functions from svn_fs_base,
svn_fs_fs, svn_ra_local, svn_ra_dav.

The function svn_ra_svn_version() function remains, since it is checked
by svnserve/main.c. Does that sound ok?

Regards, etc.
Edmund.

Issue 1861: Implement library version functions, and check library
versions in command-line clients. Each library features a
"svn_libname_version" function that returns information on the
Subversion version the library is compiled as. Clients call their own
"check_lib_versions" (or a similarly named) function that uses
svn_ver_check_list (from libsvn_subr/version.c) to call the version
functions of a list of libraries, which ensures there are no version
mismatches.

This change is a generalisation of r9697 to other libraries and
clients.

* subversion/libsvn_delta/version.c (svn_delta_version),
   subversion/libsvn_ra_svn/version.c (svn_ra_svn_version):
     New files, with functions for returning library versions.

* subversion/libsvn_diff/util.c (svn_diff_version),
   subversion/libsvn_fs/fs-loader.c (svn_fs_version),
   subversion/libsvn_ra/ra_loader.c (svn_ra_version),
   subversion/libsvn_repos/repos.c (svn_repos_version),
   subversion/libsvn_wc/util.c (svn_wc_version):
     New functions for returning library versions.

* subversion/include/svn_delta.h (svn_delta_version),
   subversion/include/svn_diff.h (svn_diff_version),
   subversion/include/svn_fs.h (svn_fs_version),
   subversion/include/svn_ra.h (svn_ra_version),
   subversion/include/svn_ra_svn.h (svn_ra_svn_version),
   subversion/include/svn_repos.h (svn_repos_version),
   subversion/include/svn_wc.h (svn_wc_version):
     New function symbols.

* subversion/svnadmin/main.c,
   subversion/svnlook/main.c,
   subversion/svndumpfilter/main.c,
   subversion/svnserve/main.c,
   subversion/svnversion/main.c,
   contrib/client-side/svn-push/svn-push.c:
     (check_lib_versions): New function that checks the compiled
         versions of all svn libraries needed by this client.
     (main): Call check_lib_versions() and exit with failure if library
         versions are not adequate.

* subversion/clients/cmdline/main.c:
     (check_lib_versions): Add remaining library version checks.

Index: subversion/libsvn_ra/ra_loader.c
===================================================================
--- subversion/libsvn_ra/ra_loader.c (revision 10147)
+++ subversion/libsvn_ra/ra_loader.c (working copy)
@@ -280,3 +280,12 @@
 
   return SVN_NO_ERROR;
 }
+
+
+/* Return the library version number.
+ */
+const svn_version_t *
+svn_ra_version (void)
+{
+ SVN_VERSION_BODY;
+}
Index: subversion/svnadmin/main.c
===================================================================
--- subversion/svnadmin/main.c (revision 10147)
+++ subversion/svnadmin/main.c (working copy)
@@ -30,6 +30,7 @@
 #include "svn_config.h"
 #include "svn_repos.h"
 #include "svn_fs.h"
+#include "svn_version.h"
 
 #include "svn_private_config.h"
 
@@ -133,6 +134,24 @@
 }
 
 
+/* Version compatibility check */
+static svn_error_t *
+check_lib_versions (void)
+{
+ static const svn_version_checklist_t checklist[] =
+ {
+ { "svn_subr", svn_subr_version },
+ { "svn_repos", svn_repos_version },
+ { "svn_fs", svn_fs_version },
+ { "svn_delta", svn_delta_version },
+ { NULL, NULL }
+ };
+
+ SVN_VERSION_DEFINE (my_version);
+ return svn_ver_check_list (&my_version, checklist);
+}
+
+
 
 /** Subcommands. **/
 
@@ -866,6 +885,16 @@
   pool = svn_pool_create_ex (NULL, allocator);
   apr_allocator_owner_set (allocator, pool);
 
+ /* Check library versions */
+ err = check_lib_versions ();
+ if (err)
+ {
+ svn_handle_error (err, stderr, FALSE);
+ svn_error_clear (err);
+ svn_pool_destroy (pool);
+ return EXIT_FAILURE;
+ }
+
   if (argc <= 1)
     {
       subcommand_help (NULL, NULL, pool);
Index: subversion/include/svn_diff.h
===================================================================
--- subversion/include/svn_diff.h (revision 10147)
+++ subversion/include/svn_diff.h (working copy)
@@ -50,6 +50,7 @@
 #include "svn_types.h"
 #include "svn_error.h"
 #include "svn_io.h"
+#include "svn_version.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -57,6 +58,13 @@
 
 
 
+/**
+ * Get libsvn_diff version information.
+ * @since New in 1.1.
+ */
+const svn_version_t *svn_diff_version (void);
+
+
 /* Diffs. */
 
 /** An opaque type that represents a difference between either two or
Index: subversion/include/svn_fs.h
===================================================================
--- subversion/include/svn_fs.h (revision 10147)
+++ subversion/include/svn_fs.h (working copy)
@@ -37,6 +37,13 @@
 #endif /* __cplusplus */
 
 
+/**
+ * Get libsvn_fs version information.
+ * @since New in 1.1.
+ */
+const svn_version_t *svn_fs_version (void);
+
+
 /* Opening and creating filesystems. */
 
 
Index: subversion/include/svn_ra_svn.h
===================================================================
--- subversion/include/svn_ra_svn.h (revision 10147)
+++ subversion/include/svn_ra_svn.h (working copy)
@@ -323,6 +323,12 @@
                                     svn_config_t *pwdb, const char **user,
                                     svn_boolean_t *success);
 
+/**
+ * Get libsvn_ra_svn version information.
+ * @since New in 1.1.
+ */
+const svn_version_t *svn_ra_svn_version (void);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
Index: subversion/include/svn_repos.h
===================================================================
--- subversion/include/svn_repos.h (revision 10147)
+++ subversion/include/svn_repos.h (working copy)
@@ -29,6 +29,7 @@
 #include "svn_delta.h"
 #include "svn_types.h"
 #include "svn_error.h"
+#include "svn_version.h"
 
 
 #ifdef __cplusplus
@@ -37,6 +38,13 @@
 
 /* ---------------------------------------------------------------*/
 
+/**
+ * Get libsvn_repos version information.
+ * @since New in 1.1.
+ */
+const svn_version_t *svn_repos_version (void);
+
+
 
 /** Callback type for checking authorization on paths produced by (at
  * least) svn_repos_dir_delta().
Index: subversion/include/svn_delta.h
===================================================================
--- subversion/include/svn_delta.h (revision 10147)
+++ subversion/include/svn_delta.h (working copy)
@@ -33,6 +33,7 @@
 #include "svn_string.h"
 #include "svn_error.h"
 #include "svn_io.h"
+#include "svn_version.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -40,6 +41,13 @@
 
 
 
+/**
+ * Get libsvn_delta version information.
+ * @since New in 1.1.
+ */
+const svn_version_t *svn_delta_version (void);
+
+
 /** Text deltas.
  *
  * A text delta represents the difference between two strings of
Index: subversion/include/svn_wc.h
===================================================================
--- subversion/include/svn_wc.h (revision 10147)
+++ subversion/include/svn_wc.h (working copy)
@@ -50,6 +50,13 @@
 #endif /* __cplusplus */
 
 
+/**
+ * Get libsvn_wc version information.
+ * @since New in 1.1.
+ */
+const svn_version_t *svn_wc_version (void);
+
+
 /* Locking/Opening/Closing */
 
 /** Baton for access to a working copy administrative area.
Index: subversion/include/svn_ra.h
===================================================================
--- subversion/include/svn_ra.h (revision 10147)
+++ subversion/include/svn_ra.h (working copy)
@@ -40,6 +40,13 @@
 
 /* Misc. declarations */
 
+/**
+ * Get libsvn_ra version information.
+ * @since New in 1.1.
+ */
+const svn_version_t *svn_ra_version (void);
+
+
 /** This is a function type which allows the RA layer to fetch working
  * copy (WC) properties.
  *
Index: subversion/libsvn_fs/fs-loader.c
===================================================================
--- subversion/libsvn_fs/fs-loader.c (revision 10147)
+++ subversion/libsvn_fs/fs-loader.c (working copy)
@@ -814,3 +814,11 @@
 {
   return a->vtable->compare (a, b);
 }
+
+/* Return the library version number.
+ */
+const svn_version_t *
+svn_fs_version (void)
+{
+ SVN_VERSION_BODY;
+}
Index: subversion/libsvn_diff/util.c
===================================================================
--- subversion/libsvn_diff/util.c (revision 10147)
+++ subversion/libsvn_diff/util.c (working copy)
@@ -181,3 +181,11 @@
 
   return SVN_NO_ERROR;
 }
+
+/* Return the library version number.
+ */
+const svn_version_t *
+svn_diff_version (void)
+{
+ SVN_VERSION_BODY;
+}
Index: subversion/libsvn_wc/util.c
===================================================================
--- subversion/libsvn_wc/util.c (revision 10147)
+++ subversion/libsvn_wc/util.c (working copy)
@@ -102,3 +102,11 @@
 
   return SVN_NO_ERROR;
 }
+
+/* Get library version information.
+ */
+const svn_version_t *
+svn_wc_version (void)
+{
+ SVN_VERSION_BODY;
+}
Index: subversion/svnlook/main.c
===================================================================
--- subversion/svnlook/main.c (revision 10147)
+++ subversion/svnlook/main.c (working copy)
@@ -255,7 +255,27 @@
     return SVN_NO_ERROR;
 }
 
+
+/* Version compatibility check */
 static svn_error_t *
+check_lib_versions (void)
+{
+ static const svn_version_checklist_t checklist[] =
+ {
+ { "svn_subr", svn_subr_version },
+ { "svn_repos", svn_repos_version },
+ { "svn_fs", svn_fs_version },
+ { "svn_delta", svn_delta_version },
+ { "svn_diff", svn_diff_version },
+ { NULL, NULL }
+ };
+
+ SVN_VERSION_DEFINE (my_version);
+ return svn_ver_check_list (&my_version, checklist);
+}
+
+
+static svn_error_t *
 get_property (svn_string_t **prop_value /* native */,
               svn_boolean_t need_translation,
               svnlook_ctxt_t *c,
@@ -1811,6 +1831,16 @@
   pool = svn_pool_create_ex (NULL, allocator);
   apr_allocator_owner_set (allocator, pool);
 
+ /* Check library versions */
+ err = check_lib_versions ();
+ if (err)
+ {
+ svn_handle_error (err, stderr, FALSE);
+ svn_error_clear (err);
+ svn_pool_destroy (pool);
+ return EXIT_FAILURE;
+ }
+
   if (argc <= 1)
     {
       subcommand_help (NULL, NULL, pool);
Index: subversion/clients/cmdline/main.c
===================================================================
--- subversion/clients/cmdline/main.c (revision 10147)
+++ subversion/clients/cmdline/main.c (working copy)
@@ -692,8 +692,11 @@
 {
   static const svn_version_checklist_t checklist[] =
     {
- { "svn_subr", svn_subr_version },
+ { "svn_subr", svn_subr_version },
       { "svn_client", svn_client_version },
+ { "svn_wc", svn_wc_version },
+ { "svn_ra", svn_ra_version },
+ { "svn_delta", svn_delta_version },
       { NULL, NULL }
     };
 
Index: subversion/svndumpfilter/main.c
===================================================================
--- subversion/svndumpfilter/main.c (revision 10147)
+++ subversion/svndumpfilter/main.c (working copy)
@@ -812,6 +812,24 @@
 }
 
 
+/* Version compatibility check */
+static svn_error_t *
+check_lib_versions (void)
+{
+ static const svn_version_checklist_t checklist[] =
+ {
+ { "svn_subr", svn_subr_version },
+ { "svn_repos", svn_repos_version },
+ { "svn_fs", svn_fs_version },
+ { "svn_delta", svn_delta_version },
+ { NULL, NULL }
+ };
+
+ SVN_VERSION_DEFINE (my_version);
+ return svn_ver_check_list (&my_version, checklist);
+}
+
+
 /* qsort-ready comparison function. */
 static int compare_paths (const void *a, const void *b)
 {
@@ -999,6 +1017,16 @@
   pool = svn_pool_create_ex (NULL, allocator);
   apr_allocator_owner_set (allocator, pool);
                   
+ /* Check library versions */
+ err = check_lib_versions ();
+ if (err)
+ {
+ svn_handle_error (err, stderr, FALSE);
+ svn_error_clear (err);
+ svn_pool_destroy (pool);
+ return EXIT_FAILURE;
+ }
+
   if (argc <= 1)
     {
       subcommand_help (NULL, NULL, pool);
Index: subversion/libsvn_repos/repos.c
===================================================================
--- subversion/libsvn_repos/repos.c (revision 10147)
+++ subversion/libsvn_repos/repos.c (working copy)
@@ -1335,3 +1335,10 @@
   return SVN_NO_ERROR;
 }
 
+/* Get library version information.
+ */
+const svn_version_t *
+svn_repos_version (void)
+{
+ SVN_VERSION_BODY;
+}
Index: subversion/libsvn_ra_svn/version.c
===================================================================
--- subversion/libsvn_ra_svn/version.c (revision 0)
+++ subversion/libsvn_ra_svn/version.c (revision 0)
@@ -0,0 +1,27 @@
+/*
+ * version.c: library version number
+ *
+ * ====================================================================
+ * Copyright (c) 2000-2004 CollabNet. All rights reserved.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at http://subversion.tigris.org/license-1.html.
+ * If newer versions of this license are posted there, you may use a
+ * newer version instead, at your option.
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals. For exact contribution history, see the revision
+ * history and logs, available at http://subversion.tigris.org/.
+ * ====================================================================
+ */
+
+
+
+#include "svn_version.h"
+
+const svn_version_t *
+svn_ra_svn_version (void)
+{
+ SVN_VERSION_BODY;
+}

Property changes on: subversion/libsvn_ra_svn/version.c
___________________________________________________________________
Name: svn:eol-style
   + native

Index: subversion/libsvn_delta/version.c
===================================================================
--- subversion/libsvn_delta/version.c (revision 0)
+++ subversion/libsvn_delta/version.c (revision 0)
@@ -0,0 +1,27 @@
+/*
+ * version.c: library version number
+ *
+ * ====================================================================
+ * Copyright (c) 2000-2004 CollabNet. All rights reserved.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at http://subversion.tigris.org/license-1.html.
+ * If newer versions of this license are posted there, you may use a
+ * newer version instead, at your option.
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals. For exact contribution history, see the revision
+ * history and logs, available at http://subversion.tigris.org/.
+ * ====================================================================
+ */
+
+
+
+#include "svn_version.h"
+
+const svn_version_t *
+svn_delta_version (void)
+{
+ SVN_VERSION_BODY;
+}

Property changes on: subversion/libsvn_delta/version.c
___________________________________________________________________
Name: svn:eol-style
   + native

Index: subversion/svnserve/main.c
===================================================================
--- subversion/svnserve/main.c (revision 10147)
+++ subversion/svnserve/main.c (working copy)
@@ -37,6 +37,8 @@
 #include "svn_utf.h"
 #include "svn_path.h"
 #include "svn_opt.h"
+#include "svn_repos.h"
+#include "svn_version.h"
 
 #include "server.h"
 
@@ -195,6 +197,25 @@
 }
 #endif
 
+/* Version compatibility check */
+static svn_error_t *
+check_lib_versions (void)
+{
+ static const svn_version_checklist_t checklist[] =
+ {
+ { "svn_subr", svn_subr_version },
+ { "svn_repos", svn_repos_version },
+ { "svn_fs", svn_fs_version },
+ { "svn_delta", svn_delta_version },
+ { "svn_ra_svn", svn_ra_svn_version },
+ { NULL, NULL }
+ };
+
+ SVN_VERSION_DEFINE (my_version);
+ return svn_ver_check_list (&my_version, checklist);
+}
+
+
 int main(int argc, const char *const *argv)
 {
   enum run_mode run_mode = run_mode_none;
@@ -229,6 +250,16 @@
   /* Create our top-level pool. */
   pool = svn_pool_create(NULL);
 
+ /* Check library versions */
+ err = check_lib_versions ();
+ if (err)
+ {
+ svn_handle_error (err, stderr, FALSE);
+ svn_error_clear (err);
+ svn_pool_destroy (pool);
+ return EXIT_FAILURE;
+ }
+
   apr_getopt_init(&os, pool, argc, argv);
 
   params.root = "/";
Index: subversion/svnversion/main.c
===================================================================
--- subversion/svnversion/main.c (revision 10147)
+++ subversion/svnversion/main.c (working copy)
@@ -157,6 +157,23 @@
 }
 
 
+/* Version compatibility check */
+static svn_error_t *
+check_lib_versions (void)
+{
+ static const svn_version_checklist_t checklist[] =
+ {
+ { "svn_subr", svn_subr_version },
+ { "svn_client", svn_client_version },
+ { "svn_wc", svn_wc_version },
+ { NULL, NULL }
+ };
+
+ SVN_VERSION_DEFINE (my_version);
+ return svn_ver_check_list (&my_version, checklist);
+}
+
+
 /*
  * Why is this not an svn subcommand? I have this vague idea that it could
  * be run as part of the build process, with the output embedded in the svn
@@ -200,6 +217,16 @@
   pool = svn_pool_create_ex (NULL, allocator);
   apr_allocator_owner_set (allocator, pool);
 
+ /* Check library versions */
+ err = check_lib_versions ();
+ if (err)
+ {
+ svn_handle_error (err, stderr, FALSE);
+ svn_error_clear (err);
+ svn_pool_destroy (pool);
+ return EXIT_FAILURE;
+ }
+
   sb.switched = FALSE;
   sb.modified = FALSE;
   sb.committed = FALSE;
Index: contrib/client-side/svn-push/svn-push.c
===================================================================
--- contrib/client-side/svn-push/svn-push.c (revision 10147)
+++ contrib/client-side/svn-push/svn-push.c (working copy)
@@ -144,7 +144,25 @@
 
   return SVN_NO_ERROR;
 }
+
 
+/* Version compatibility check */
+static svn_error_t *
+check_lib_versions (void)
+{
+ static const svn_version_checklist_t checklist[] =
+ {
+ { "svn_subr", svn_subr_version },
+ { "svn_delta", svn_delta_version },
+ { "svn_ra", svn_ra_version },
+ { NULL, NULL }
+ };
+
+ SVN_VERSION_DEFINE (my_version);
+ return svn_ver_check_list (&my_version, checklist);
+}
+
+
 int
 main (int argc, char *argv[])
 {
@@ -159,6 +177,14 @@
     return EXIT_FAILURE;
 
   top_pool = svn_pool_create (NULL);
+
+ /* Check library versions */
+ error = check_lib_versions ();
+ if (error)
+ {
+ svn_handle_error (error, stderr, 0);
+ return EXIT_FAILURE;
+ }
 
 #define CMD_LINE_ERROR \
         { \

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Jul 6 12:11:45 2004

This is an archived mail posted to the Subversion Dev mailing list.