Rev 4465: Add a hint parameter to Repository.pack. in http://people.ubuntu.com/~robertc/baz2.0/pending/autopack-cross-format-fetch
Robert Collins
robertc at robertcollins.net
Mon Jun 22 00:51:29 BST 2009
At http://people.ubuntu.com/~robertc/baz2.0/pending/autopack-cross-format-fetch
------------------------------------------------------------
revno: 4465
revision-id: robertc at robertcollins.net-20090621235117-zvjywxin20usblpn
parent: robertc at robertcollins.net-20090619042602-dicz171b8vhj1s71
committer: Robert Collins <robertc at robertcollins.net>
branch nick: autopack-cross-format-fetch
timestamp: Mon 2009-06-22 09:51:17 +1000
message:
Add a hint parameter to Repository.pack.
=== modified file 'NEWS'
--- a/NEWS 2009-06-19 04:19:22 +0000
+++ b/NEWS 2009-06-21 23:51:17 +0000
@@ -63,6 +63,10 @@
properly fetch the minimum number of texts for non-smart fetching.
(John Arbash Meinel)
+* ``Repository.pack`` now takes an optional ``hint`` parameter
+ which will support doing partial packs for repositories that can do
+ that. (Robert Collins)
+
* RepositoryFormat has a new attribute 'pack_compresses' which is True
when doing a pack operation changes the compression of content in the
repository. (Robert Collins)
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py 2009-06-19 04:19:22 +0000
+++ b/bzrlib/remote.py 2009-06-21 23:51:17 +0000
@@ -1496,13 +1496,13 @@
return self._real_repository.inventories
@needs_write_lock
- def pack(self):
+ def pack(self, hint=None):
"""Compress the data within the repository.
This is not currently implemented within the smart server.
"""
self._ensure_real()
- return self._real_repository.pack()
+ return self._real_repository.pack(hint=hint)
@property
def revisions(self):
=== modified file 'bzrlib/repofmt/pack_repo.py'
--- a/bzrlib/repofmt/pack_repo.py 2009-06-19 04:26:02 +0000
+++ b/bzrlib/repofmt/pack_repo.py 2009-06-21 23:51:17 +0000
@@ -1556,7 +1556,7 @@
"""Is the collection already packed?"""
return not (self.repo._format.pack_compresses or (len(self._names) > 1))
- def pack(self):
+ def pack(self, hint=None):
"""Pack the pack collection totally."""
self.ensure_loaded()
total_packs = len(self._names)
@@ -2348,13 +2348,13 @@
raise NotImplementedError(self.dont_leave_lock_in_place)
@needs_write_lock
- def pack(self):
+ def pack(self, hint=None):
"""Compress the data within the repository.
This will pack all the data to a single pack. In future it may
recompress deltas or do other such expensive operations.
"""
- self._pack_collection.pack()
+ self._pack_collection.pack(hint=hint)
@needs_write_lock
def reconcile(self, other=None, thorough=False):
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2009-06-19 04:19:22 +0000
+++ b/bzrlib/repository.py 2009-06-21 23:51:17 +0000
@@ -2427,7 +2427,7 @@
keys = tsort.topo_sort(parent_map)
return [None] + list(keys)
- def pack(self):
+ def pack(self, hint=None):
"""Compress the data within the repository.
This operation only makes sense for some repository types. For other
@@ -2436,6 +2436,13 @@
This stub method does not require a lock, but subclasses should use
@needs_write_lock as this is a long running call its reasonable to
implicitly lock for the user.
+
+ :param hint: If not supplied, the whole repository is packed.
+ If supplied, the repository may use the hint parameter as a
+ hint for the parts of the repository to pack. A hint can be
+ obtained from the result of commit_write_group(). Out of
+ date hints are simply ignored, because concurrent operations
+ can obsolete them rapidly.
"""
def get_transaction(self):
=== modified file 'bzrlib/tests/per_repository/test_pack.py'
--- a/bzrlib/tests/per_repository/test_pack.py 2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/per_repository/test_pack.py 2009-06-21 23:51:17 +0000
@@ -24,3 +24,14 @@
def test_pack_empty_does_not_error(self):
repo = self.make_repository('.')
repo.pack()
+
+ def test_pack_accepts_opaque_hint(self):
+ # For requesting packs of a repository where some data is known to be
+ # unoptimal we permit packing just some data via a hint. If the hint is
+ # illegible it is ignored.
+ tree = self.make_branch_and_tree('tree')
+ rev1 = tree.commit('1')
+ rev2 = tree.commit('2')
+ rev3 = tree.commit('3')
+ rev4 = tree.commit('4')
+ tree.branch.repository.pack(hint=[rev3, rev4])
More information about the bazaar-commits
mailing list