subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hwri...@apache.org
Subject svn commit: r1158879 - in /subversion/branches/fs-py/subversion: libsvn_fs_py/fs_fs.c python/svn/fs/__init__.py
Date Wed, 17 Aug 2011 19:27:28 GMT
Author: hwright
Date: Wed Aug 17 19:27:28 2011
New Revision: 1158879

URL: http://svn.apache.org/viewvc?rev=1158879&view=rev
Log:
On the fs-py branch:
Move the remaining "open a FS" logic into Python.

* subversion/python/svn/fs/__init__.py
  (_read_format): Moved here...
  (FS._read_format): ...from here.
  (_check_format): New.
  (FS._open_fs): Finish opening the filesystem.

* subversion/libsvn_fs_py/fs_fs.c
  (svn_fs_py__open): Just delegate to the Python method.

Modified:
    subversion/branches/fs-py/subversion/libsvn_fs_py/fs_fs.c
    subversion/branches/fs-py/subversion/python/svn/fs/__init__.py

Modified: subversion/branches/fs-py/subversion/libsvn_fs_py/fs_fs.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_fs_py/fs_fs.c?rev=1158879&r1=1158878&r2=1158879&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_fs_py/fs_fs.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_fs_py/fs_fs.c Wed Aug 17 19:27:28 2011
@@ -1243,8 +1243,6 @@ svn_error_t *
 svn_fs_py__open(svn_fs_t *fs, const char *path, apr_pool_t *pool)
 {
   fs_fs_data_t *ffd = fs->fsap_data;
-  int format;
-  int max_files_per_dir;
 
   fs->path = apr_pstrdup(fs->pool, path);
 
@@ -1253,18 +1251,6 @@ svn_fs_py__open(svn_fs_t *fs, const char
   apr_pool_cleanup_register(fs->pool, ffd->p_fs, svn_fs_py__destroy_py_object,
                             apr_pool_cleanup_null);
 
-  /* Read the FS format number. */
-  SVN_ERR(read_format(&format, &max_files_per_dir,
-                      path_format(fs, pool), pool));
-  SVN_ERR(check_format(format));
-
-  /* Read the min unpacked revision. */
-  if (format >= SVN_FS_FS__MIN_PACKED_FORMAT)
-    SVN_ERR(update_min_unpacked_rev(fs, pool));
-
-  /* Read the configuration file. */
-  SVN_ERR(read_config(fs, pool));
-
   return SVN_NO_ERROR;
 }
 

Modified: subversion/branches/fs-py/subversion/python/svn/fs/__init__.py
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/python/svn/fs/__init__.py?rev=1158879&r1=1158878&r2=1158879&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/python/svn/fs/__init__.py (original)
+++ subversion/branches/fs-py/subversion/python/svn/fs/__init__.py Wed Aug 17 19:27:28 2011
@@ -54,6 +54,7 @@ MIN_PROTOREVS_DIR_FORMAT            = 3
 MIN_NO_GLOBAL_IDS_FORMAT            = 3
 MIN_PACKED_FORMAT                   = 4
 MIN_REP_SHARING_FORMAT              = 4
+PACKED_REVPROP_SQLITE_DEV_FORMAT    = 5
 
 _DEFAULT_MAX_FILES_PER_DIR = 1000
 _TIMESTAMP_FORMAT = '%Y-%m-%dT%H:%M:%S.%fZ'
@@ -113,6 +114,25 @@ _DEFAULT_CONFIG_CONTENTS = \
        CONFIG_OPTION_ENABLE_REP_SHARING)
 
 
+def _read_format(path):
+    try:
+        with open(path, 'rb') as f:
+            format = int(f.readline())
+            max_files_per_dir = 0
+            for l in f:
+                l = l.split()
+                if format > MIN_LAYOUT_FORMAT_OPTION_FORMAT \
+                        and l[0] == 'layout':
+                    if l[1] == 'linear':
+                        max_files_per_dir = 0
+                    elif l[1] == 'sharded':
+                        max_files_per_dir = int(l[2])
+        return (format, max_files_per_dir)
+    except IOError:
+        # Treat an absent format file as format 1.
+        return (1, 0)
+
+
 def _write_format(path, format, max_files_per_dir, overwrite=True):
     assert 1 <= format and format <= FORMAT_NUMBER
 
@@ -138,6 +158,30 @@ def _write_format(path, format, max_file
     os.chmod(path, stat.S_IREAD)
 
 
+def _check_format(format):
+    '''Return the error svn.err.FS_UNSUPPORTED_FORMAT if FS's format
+    number is not the same as a format number supported by this
+    Subversion.'''
+
+    # Blacklist.  These formats may be either younger or older than
+    # SVN_FS_FS__FORMAT_NUMBER, but we don't support them.
+    if format is PACKED_REVPROP_SQLITE_DEV_FORMAT:
+        raise svn.SubversionException(svn.err.FS_UNSUPPORTED_FORMAT,
+                                      "Found format '%d', only created by " +
+                                      "unreleased dev builds; see " +
+                                      "http://subversion.apache.org" +
+                                      "/docs/release-notes/1.7#revprop-packing"
+                                       % format)
+
+    #  We support all formats from 1-current simultaneously
+    if 1 <= format <= FORMAT_NUMBER:
+        return
+
+    raise svn.SubversionException(svn.err.FS_UNSUPPORTED_FORMAT,
+                "Expected FS format between '1' and '%d'; found format '%d'" %
+                (FORMAT_NUMBER, format))
+
+
 class FS(object):
     def __path_rev_shard(self, rev):
         assert self.max_files_per_dir
@@ -249,25 +293,6 @@ class FS(object):
         os.rename(tempf.name, final_path)
 
 
-    def __read_format(self):
-        try:
-            with open(self.__path_format, 'rb') as f:
-                self.format = int(f.readline())
-                self.max_files_per_dir = 0
-                for l in f:
-                    l = l.split()
-                    if self.format > MIN_LAYOUT_FORMAT_OPTION_FORMAT \
-                            and l[0] == 'layout':
-                        if l[1] == 'linear':
-                            self.max_files_per_dir = 0
-                        elif l[1] == 'sharded':
-                            self.max_files_per_dir = int(l[2])
-        except IOError:
-            # Treat an absent format file as format 1.
-            self.format = 1
-            self.max_files_per_dir = 0
-
-
     def __update_min_unpacked_rev(self):
         assert self.format >= MIN_PACKED_FORMAT
         with open(self.__path_min_unpacked_rev, 'rb') as f:
@@ -370,12 +395,19 @@ class FS(object):
         with open(self.__path_uuid, 'rb') as f:
             self.uuid = uuid.UUID(f.readline().rstrip())
 
-        self.__read_format()
+        # Read the FS format number.
+        (self.format, self.max_files_per_dir) = _read_format(self.__path_format)
+        _check_format(self.format)
+
+        # Read the min unpacked revision.
         if self.format >= MIN_PACKED_FORMAT:
             self.__update_min_unpacked_rev()
 
         self._youngest_rev_cache = self._get_youngest()
 
+        # Read the configuration file
+        self._read_config()
+
 
     def __setup_paths(self):
         self.__path_uuid = os.path.join(self.path, PATH_UUID)



Mime
View raw message