subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1511324 - in /subversion/branches/log-addressing/subversion: include/private/svn_fs_util.h libsvn_fs_base/fs.c libsvn_fs_base/fs.h libsvn_fs_fs/fs_fs.c libsvn_fs_util/fs-util.c libsvn_fs_x/fs.h libsvn_fs_x/fs_x.c
Date Wed, 07 Aug 2013 14:12:52 GMT
Author: stefan2
Date: Wed Aug  7 14:12:51 2013
New Revision: 1511324

URL: http://svn.apache.org/r1511324
Log:
On the log-addressing branch:  Factor out a function evaluating
the various version compatibility FS configuration parameters.
Use that function in all 3 backends such that all of them handle
all compat options that we have.

Allow for 1.x compatibility only and let the backend select the
FS format based on the minor version.

* subversion/include/private/svn_fs_util.h
  (svn_fs__compatible_version): declare new private API function

* subversion/libsvn_fs_util/fs-util.c
  (svn_fs__compatible_version): implement it

* subversion/libsvn_fs_fs/fs_fs.c
  (svn_fs_fs__create): use the new API

* subversion/libsvn_fs_base/fs.h
  (SVN_FS_BASE__FORMAT_NUMBER): remind people to update *_create upon bump

* subversion/libsvn_fs_base/fs.c
  (base_create): use the new API

* subversion/libsvn_fs_x/fs.h
  (SVN_FS_X__FORMAT_NUMBER): remind people to update *_create upon bump

* subversion/libsvn_fs_x/fs_x.c
  (svn_fs_x__create): use the new API

Modified:
    subversion/branches/log-addressing/subversion/include/private/svn_fs_util.h
    subversion/branches/log-addressing/subversion/libsvn_fs_base/fs.c
    subversion/branches/log-addressing/subversion/libsvn_fs_base/fs.h
    subversion/branches/log-addressing/subversion/libsvn_fs_fs/fs_fs.c
    subversion/branches/log-addressing/subversion/libsvn_fs_util/fs-util.c
    subversion/branches/log-addressing/subversion/libsvn_fs_x/fs.h
    subversion/branches/log-addressing/subversion/libsvn_fs_x/fs_x.c

Modified: subversion/branches/log-addressing/subversion/include/private/svn_fs_util.h
URL: http://svn.apache.org/viewvc/subversion/branches/log-addressing/subversion/include/private/svn_fs_util.h?rev=1511324&r1=1511323&r2=1511324&view=diff
==============================================================================
--- subversion/branches/log-addressing/subversion/include/private/svn_fs_util.h (original)
+++ subversion/branches/log-addressing/subversion/include/private/svn_fs_util.h Wed Aug  7
14:12:51 2013
@@ -210,6 +210,17 @@ svn_fs__append_to_merged_froms(svn_merge
                                const char *rel_path,
                                apr_pool_t *pool);
 
+/* Given the FS creation options in CONFIG, return the oldest version that
+   we shall be compatible with in *COMPATIBLE_VERSION.
+   Allocate the result in POOL.
+
+   Note: For now, we will create an error for any compatibility request
+         that is not a 1.x. */
+svn_error_t *
+svn_fs__compatible_version(svn_version_t **compatible_version,
+                           apr_hash_t *config,
+                           apr_pool_t *pool);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

Modified: subversion/branches/log-addressing/subversion/libsvn_fs_base/fs.c
URL: http://svn.apache.org/viewvc/subversion/branches/log-addressing/subversion/libsvn_fs_base/fs.c?rev=1511324&r1=1511323&r2=1511324&view=diff
==============================================================================
--- subversion/branches/log-addressing/subversion/libsvn_fs_base/fs.c (original)
+++ subversion/branches/log-addressing/subversion/libsvn_fs_base/fs.c Wed Aug  7 14:12:51
2013
@@ -738,12 +738,27 @@ base_create(svn_fs_t *fs, const char *pa
   /* See if compatibility with older versions was explicitly requested. */
   if (fs->config)
     {
-      if (svn_hash_gets(fs->config, SVN_FS_CONFIG_PRE_1_4_COMPATIBLE))
-        format = 1;
-      else if (svn_hash_gets(fs->config, SVN_FS_CONFIG_PRE_1_5_COMPATIBLE))
-        format = 2;
-      else if (svn_hash_gets(fs->config, SVN_FS_CONFIG_PRE_1_6_COMPATIBLE))
-        format = 3;
+      svn_version_t *compatible_version;
+      SVN_ERR(svn_fs__compatible_version(&compatible_version, fs->config,
+                                         pool));
+
+      /* select format number */
+      switch(compatible_version->minor)
+        {
+          case 0:
+          case 1:
+          case 2:
+          case 3: format = 1;
+                  break;
+
+          case 4: format = 2;
+                  break;
+
+          case 5: format = 3;
+                  break;
+
+          default:format = SVN_FS_BASE__FORMAT_NUMBER;
+        }
     }
 
   /* Create the environment and databases. */

Modified: subversion/branches/log-addressing/subversion/libsvn_fs_base/fs.h
URL: http://svn.apache.org/viewvc/subversion/branches/log-addressing/subversion/libsvn_fs_base/fs.h?rev=1511324&r1=1511323&r2=1511324&view=diff
==============================================================================
--- subversion/branches/log-addressing/subversion/libsvn_fs_base/fs.h (original)
+++ subversion/branches/log-addressing/subversion/libsvn_fs_base/fs.h Wed Aug  7 14:12:51
2013
@@ -43,7 +43,11 @@ extern "C" {
    repository format number, and independent of any other FS back
    ends.  See the SVN_FS_BASE__MIN_*_FORMAT defines to get a sense of
    what changes and features were added in which versions of this
-   back-end's format.  */
+   back-end's format.
+
+   Note: If you bump this, please update the switch statement in
+         base_create() as well.
+ */
 #define SVN_FS_BASE__FORMAT_NUMBER                4
 
 /* Minimum format number that supports representation sharing.  This

Modified: subversion/branches/log-addressing/subversion/libsvn_fs_fs/fs_fs.c
URL: http://svn.apache.org/viewvc/subversion/branches/log-addressing/subversion/libsvn_fs_fs/fs_fs.c?rev=1511324&r1=1511323&r2=1511324&view=diff
==============================================================================
--- subversion/branches/log-addressing/subversion/libsvn_fs_fs/fs_fs.c (original)
+++ subversion/branches/log-addressing/subversion/libsvn_fs_fs/fs_fs.c Wed Aug  7 14:12:51
2013
@@ -42,7 +42,6 @@
 
 #include "private/svn_fs_util.h"
 #include "private/svn_string_private.h"
-#include "private/svn_subr_private.h"
 #include "../libsvn_fs/fs-loader.h"
 
 /* The default maximum number of files per directory to store in the
@@ -1082,34 +1081,8 @@ svn_fs_fs__create(svn_fs_t *fs,
   if (fs->config)
     {
       svn_version_t *compatible_version;
-      const char *compatible;
-
-      /* This will cause a compiler warning as soon as we merge with
-         the FSX branch.  Remove this when it happens. */
-#define SVN_FS_CONFIG_COMPATIBLE_VERSION ""
-      /* TODO: move this code to fs_utils */
-      
-      /* set compatible version according to generic option */
-      compatible = svn_hash_gets(fs->config, SVN_FS_CONFIG_COMPATIBLE_VERSION);
-      if (compatible)
-        SVN_ERR(svn_version__parse_version_string(&compatible_version,
-                                                  compatible, pool));
-      else
-        compatible_version = apr_pmemdup(pool, svn_subr_version(),
-                                         sizeof(*compatible_version));
-
-      /* we handle SVN 1.x only */
-      SVN_ERR_ASSERT(compatible_version->major == 1);
-
-      /* specific options take precedence */
-      if (svn_hash_gets(fs->config, SVN_FS_CONFIG_PRE_1_4_COMPATIBLE))
-        compatible_version->minor = 3;
-      else if (svn_hash_gets(fs->config, SVN_FS_CONFIG_PRE_1_5_COMPATIBLE))
-        compatible_version->minor = 4;
-      else if (svn_hash_gets(fs->config, SVN_FS_CONFIG_PRE_1_6_COMPATIBLE))
-        compatible_version->minor = 5;
-      else if (svn_hash_gets(fs->config, SVN_FS_CONFIG_PRE_1_8_COMPATIBLE))
-        compatible_version->minor = 7;
+      SVN_ERR(svn_fs__compatible_version(&compatible_version, fs->config,
+                                         pool));
 
       /* select format number */
       switch(compatible_version->minor)

Modified: subversion/branches/log-addressing/subversion/libsvn_fs_util/fs-util.c
URL: http://svn.apache.org/viewvc/subversion/branches/log-addressing/subversion/libsvn_fs_util/fs-util.c?rev=1511324&r1=1511323&r2=1511324&view=diff
==============================================================================
--- subversion/branches/log-addressing/subversion/libsvn_fs_util/fs-util.c (original)
+++ subversion/branches/log-addressing/subversion/libsvn_fs_util/fs-util.c Wed Aug  7 14:12:51
2013
@@ -31,9 +31,11 @@
 #include "svn_fs.h"
 #include "svn_dirent_uri.h"
 #include "svn_path.h"
+#include "svn_version.h"
 
 #include "private/svn_fs_util.h"
 #include "private/svn_fspath.h"
+#include "private/svn_subr_private.h"
 #include "../libsvn_fs/fs-loader.h"
 
 /* Return TRUE, if PATH of PATH_LEN > 0 chars starts with a '/' and does
@@ -221,3 +223,53 @@ svn_fs__append_to_merged_froms(svn_merge
 
   return SVN_NO_ERROR;
 }
+
+svn_error_t *
+svn_fs__compatible_version(svn_version_t **compatible_version,
+                           apr_hash_t *config,
+                           apr_pool_t *pool)
+{
+  svn_version_t *version;
+  const char *compatible;
+
+  /* set compatible version according to generic option */
+  compatible = svn_hash_gets(config, SVN_FS_CONFIG_COMPATIBLE_VERSION);
+  if (compatible)
+    SVN_ERR(svn_version__parse_version_string(&version,
+                                              compatible, pool));
+  else
+    version = apr_pmemdup(pool, svn_subr_version(),
+                                     sizeof(*version));
+
+  /* specific options take precedence.
+     Let the lowest version compatibility requirement win */
+  if (svn_hash_gets(config, SVN_FS_CONFIG_PRE_1_8_COMPATIBLE))
+    {
+      version->major = 1;
+      version->minor = 7;
+    }
+  else if (svn_hash_gets(config, SVN_FS_CONFIG_PRE_1_6_COMPATIBLE))
+    {
+      version->major = 1;
+      version->minor = 5;
+    }
+  else if (svn_hash_gets(config, SVN_FS_CONFIG_PRE_1_5_COMPATIBLE))
+    {
+      version->major = 1;
+      version->minor = 4;
+    }
+  else if (svn_hash_gets(config, SVN_FS_CONFIG_PRE_1_4_COMPATIBLE))
+    {
+      version->major = 1;
+      version->minor = 3;
+    }
+
+  /* our backends only know how to handle 1.x compatibility */
+  if (version->major != 1)
+    return svn_error_create(SVN_ERR_FS_UNSUPPORTED_FORMAT, NULL,
+                      _("No compatibility possible to anything but 1.x"));
+
+  /* done here */
+  *compatible_version = version;
+  return SVN_NO_ERROR;
+}

Modified: subversion/branches/log-addressing/subversion/libsvn_fs_x/fs.h
URL: http://svn.apache.org/viewvc/subversion/branches/log-addressing/subversion/libsvn_fs_x/fs.h?rev=1511324&r1=1511323&r2=1511324&view=diff
==============================================================================
--- subversion/branches/log-addressing/subversion/libsvn_fs_x/fs.h (original)
+++ subversion/branches/log-addressing/subversion/libsvn_fs_x/fs.h Wed Aug  7 14:12:51 2013
@@ -114,7 +114,11 @@ extern "C" {
 
 /* The format number of this filesystem.
    This is independent of the repository format number, and
-   independent of any other FS back ends. */
+   independent of any other FS back ends.
+
+   Note: If you bump this, please update the switch statement in
+         svn_fs_x__create() as well.
+ */
 #define SVN_FS_X__FORMAT_NUMBER   1
 
 /* Private FSX-specific data shared between all svn_txn_t objects that

Modified: subversion/branches/log-addressing/subversion/libsvn_fs_x/fs_x.c
URL: http://svn.apache.org/viewvc/subversion/branches/log-addressing/subversion/libsvn_fs_x/fs_x.c?rev=1511324&r1=1511323&r2=1511324&view=diff
==============================================================================
--- subversion/branches/log-addressing/subversion/libsvn_fs_x/fs_x.c (original)
+++ subversion/branches/log-addressing/subversion/libsvn_fs_x/fs_x.c Wed Aug  7 14:12:51 2013
@@ -786,19 +786,25 @@ svn_fs_x__create(svn_fs_t *fs,
   if (fs->config)
     {
       svn_version_t *compatible_version;
-      const char *compatible;
-      compatible = svn_hash_gets(fs->config, SVN_FS_CONFIG_COMPATIBLE_VERSION);
-      if (compatible)
-        SVN_ERR(svn_version__parse_version_string(&compatible_version,
-                                                  compatible, pool));
-      if (svn_hash_gets(fs->config, SVN_FS_CONFIG_PRE_1_4_COMPATIBLE)
-          || svn_hash_gets(fs->config, SVN_FS_CONFIG_PRE_1_5_COMPATIBLE)
-          || svn_hash_gets(fs->config, SVN_FS_CONFIG_PRE_1_6_COMPATIBLE)
-          || svn_hash_gets(fs->config, SVN_FS_CONFIG_PRE_1_8_COMPATIBLE)
-          || (compatible && compatible_version->major == SVN_VER_MAJOR
-              && compatible_version->minor <= 8))
-        return svn_error_create(SVN_ERR_FS_UNSUPPORTED_FORMAT, NULL,
-                 _("FSX is not compatible with Subversion prior to 1.9"));
+      SVN_ERR(svn_fs__compatible_version(&compatible_version, fs->config,
+                                         pool));
+
+      /* select format number */
+      switch(compatible_version->minor)
+        {
+          case 0:
+          case 1:
+          case 2:
+          case 3:
+          case 4:
+          case 5:
+          case 6:
+          case 7:
+          case 8: return svn_error_create(SVN_ERR_FS_UNSUPPORTED_FORMAT, NULL,
+                  _("FSFS is not compatible with Subversion prior to 1.9"));
+
+          default:format = SVN_FS_X__FORMAT_NUMBER;
+        }
     }
   ffd->format = format;
   ffd->max_files_per_dir = SVN_FS_X_DEFAULT_MAX_FILES_PER_DIR;



Mime
View raw message