You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2011/08/24 23:54:12 UTC
svn commit: r1161297 - in /subversion/branches/fs-py/subversion:
libsvn_fs_py/fs_fs.c python/svn/_lock.py python/svn/fs/__init__.py
Author: hwright
Date: Wed Aug 24 21:54:12 2011
New Revision: 1161297
URL: http://svn.apache.org/viewvc?rev=1161297&view=rev
Log:
On the fs-py branch:
Implement the outer look of fsfs packing in Python, including notification.
This doesn't yet implement the "guts", nor remove any C implementation...that
will come shortly.
* subversion/python/svn/fs/__init__.py
(FS._pack_shard): New skeleton.
(FS.pack): Implement a few checks, and call the real worker method.
* subversion/python/svn/_lock.py
(Lock.is_locked): New.
* subversion/libsvn_fs_py/fs_fs.c
(pack_body): Don't do notification (to keep the tests passing).
Modified:
subversion/branches/fs-py/subversion/libsvn_fs_py/fs_fs.c
subversion/branches/fs-py/subversion/python/svn/_lock.py
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=1161297&r1=1161296&r2=1161297&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 24 21:54:12 2011
@@ -7311,7 +7311,8 @@ pack_body(void *baton,
SVN_ERR(pb->cancel_func(pb->cancel_baton));
SVN_ERR(pack_shard(data_path, pb->fs->path, i, max_files_per_dir,
- pb->notify_func, pb->notify_baton,
+ /*pb->notify_func, pb->notify_baton,*/
+ NULL, NULL,
pb->cancel_func, pb->cancel_baton, iterpool));
}
Modified: subversion/branches/fs-py/subversion/python/svn/_lock.py
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/python/svn/_lock.py?rev=1161297&r1=1161296&r2=1161297&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/python/svn/_lock.py (original)
+++ subversion/branches/fs-py/subversion/python/svn/_lock.py Wed Aug 24 21:54:12 2011
@@ -70,6 +70,9 @@ class Lock(object):
del self._fd
self._is_locked = False
+ def is_locked(self):
+ return self._is_locked
+
def __enter__(self):
if not self._is_locked:
self.acquire()
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=1161297&r1=1161296&r2=1161297&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 24 21:54:12 2011
@@ -443,14 +443,49 @@ class FS(object):
self._write_lock = svn._lock.Lock(self.__path_lock)
+ def _pack_shard(self, shard, notify, cancel):
+ assert self._write_lock.is_locked()
+
+ if notify:
+ notify(shard, 0)
+ notify(shard, 1)
+
+
def pack(self, notify=None, cancel=None):
'Pack the filesystem, calling NOTIFY and CANCEL as appropriate.'
with self._write_lock:
- if notify:
- notify(0, 0)
- if cancel:
- cancel()
+ (format, max_files_per_dir) = _read_format(self.__path_format)
+ _check_format(format)
+
+ # If the repository isn't a new enough format, we don't support
+ # packing. Return a friendly error to that effect.
+ if format < MIN_PACKED_FORMAT:
+ raise svn.SubversionException(svn.err.UNSUPPORTED_FEATURE,
+ "FSFS format (%d) too old to " +
+ "pack; please upgrade the " +
+ "filesystem." % format)
+
+ # If we aren't using sharding, we can't do any packing, so quit.
+ if not max_files_per_dir:
+ return
+
+ self.__update_min_unpacked_rev()
+ youngest = self._get_youngest()
+ completed_shards = (youngest + 1) / max_files_per_dir
+
+ # See if we've already completed all possible shards thus far.
+ if self.__min_unpacked_rev == \
+ (completed_shards * max_files_per_dir):
+ return
+
+ data_path = os.path.join(self.path, PATH_REVS_DIR)
+ for shard in range(self.__min_unpacked_rev / max_files_per_dir,
+ completed_shards):
+ if cancel:
+ cancel()
+
+ self._pack_shard(shard, notify, cancel)