Rev 2969: Test that reconciling a repository can be done twice in a row. in http://people.ubuntu.com/~robertc/baz2.0/reconcile
Robert Collins
robertc at robertcollins.net
Thu Nov 29 01:45:23 GMT 2007
At http://people.ubuntu.com/~robertc/baz2.0/reconcile
------------------------------------------------------------
revno: 2969
revision-id:robertc at robertcollins.net-20071129014512-qwfvultxzo9w6ot4
parent: robertc at robertcollins.net-20071128233626-7prd9kkgj1l0kmk1
committer: Robert Collins <robertc at robertcollins.net>
branch nick: reconcile.packs
timestamp: Thu 2007-11-29 12:45:12 +1100
message:
Test that reconciling a repository can be done twice in a row.
modified:
bzrlib/repofmt/pack_repo.py pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
bzrlib/tests/repository_implementations/test_reconcile.py test_reconcile.py-20060223022332-572ef70a3288e369
=== modified file 'bzrlib/repofmt/pack_repo.py'
--- a/bzrlib/repofmt/pack_repo.py 2007-11-28 23:36:26 +0000
+++ b/bzrlib/repofmt/pack_repo.py 2007-11-29 01:45:12 +0000
@@ -704,7 +704,7 @@
time.ctime(), self._pack_collection._upload_transport.base, new_pack.random_name,
new_pack.signature_index.key_count(),
time.time() - new_pack.start_time)
- if not new_pack.data_inserted():
+ if not self._use_pack(new_pack):
new_pack.abort()
return None
self.pb.update("Finishing pack", 5)
@@ -832,6 +832,14 @@
pb.update("Copied record", record_index)
record_index += 1
+ def _use_pack(self, new_pack):
+ """Return True if new_pack should be used.
+
+ :param new_pack: The pack that has just been created.
+ :return: True if the pack should be used.
+ """
+ return new_pack.data_inserted()
+
class ReconcilePacker(Packer):
"""A packer which regenerates indices etc as it copies.
@@ -840,6 +848,21 @@
regenerated.
"""
+ def _use_pack(self, new_pack):
+ """Override _use_pack to check for reconcile having changed content."""
+ self._data_changed = False
+ # XXX: we might be better checking this at the copy time.
+ original_inventory_keys = set()
+ inv_index = self._pack_collection.inventory_index.combined_index
+ for entry in inv_index.iter_all_entries():
+ original_inventory_keys.add(entry[1])
+ new_inventory_keys = set()
+ for entry in new_pack.inventory_index.iter_all_entries():
+ new_inventory_keys.add(entry[1])
+ if new_inventory_keys != original_inventory_keys:
+ self._data_changed = True
+ return new_pack.data_inserted() and self._data_changed
+
class RepositoryPackCollection(object):
"""Management of packs within a repository."""
=== modified file 'bzrlib/tests/repository_implementations/test_reconcile.py'
--- a/bzrlib/tests/repository_implementations/test_reconcile.py 2007-11-03 14:26:37 +0000
+++ b/bzrlib/tests/repository_implementations/test_reconcile.py 2007-11-29 01:45:12 +0000
@@ -390,3 +390,11 @@
self.assertFalse(reconciler.aborted,
"reconcile should not have aborted on an unbroken repository.")
+
+class TestRepeatedReconcile(TestReconcile):
+
+ def test_trivial_two_reconciles_no_error(self):
+ tree = self.make_branch_and_tree('.')
+ tree.commit('first post')
+ tree.branch.repository.reconcile(thorough=True)
+ tree.branch.repository.reconcile(thorough=True)
More information about the bazaar-commits
mailing list