Rev 3806: Add a test that KnitPackRepository.get_record_stream retries when appropriate. in http://bzr.arbash-meinel.com/branches/bzr/1.9-dev/pack_retry_153786
John Arbash Meinel
john at arbash-meinel.com
Sat Oct 25 01:27:35 BST 2008
At http://bzr.arbash-meinel.com/branches/bzr/1.9-dev/pack_retry_153786
------------------------------------------------------------
revno: 3806
revision-id: john at arbash-meinel.com-20081025002729-m1a8c7gdfr1v2ezb
parent: john at arbash-meinel.com-20081024220902-ubncv0s37s7npwvp
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: pack_retry_153786
timestamp: Fri 2008-10-24 19:27:29 -0500
message:
Add a test that KnitPackRepository.get_record_stream retries when appropriate.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_pack_repository.py'
--- a/bzrlib/tests/test_pack_repository.py 2008-10-23 19:39:59 +0000
+++ b/bzrlib/tests/test_pack_repository.py 2008-10-25 00:27:29 +0000
@@ -406,7 +406,7 @@
r2.lock_read()
try:
# Now r2 has read the pack-names file, but will need to reload
- # it after r1 has repacked
+ # it after 'tree' has packed.
tree.branch.repository.pack()
self.assertEqual({rev2:(rev1,)}, r2.get_parent_map([rev2]))
finally:
@@ -414,6 +414,35 @@
finally:
tree.unlock()
+ def test_concurrent_pack_during_get_record_reloads(self):
+ tree = self.make_branch_and_tree('tree')
+ tree.lock_write()
+ try:
+ rev1 = tree.commit('one')
+ rev2 = tree.commit('two')
+ r2 = repository.Repository.open('tree')
+ r2.lock_read()
+ try:
+ # At this point, we will start grabbing a record stream, and
+ # trigger a repack mid-way
+ packed = False
+ result = {}
+ keys = [(rev1,), (rev2,)]
+ record_stream = r2.revisions.get_record_stream(keys,
+ 'unordered', False)
+ for record in record_stream:
+ result[record.key] = record
+ if not packed:
+ tree.branch.repository.pack()
+ packed = True
+ # The first record will be found in the original location, but
+ # after the pack, we have to reload to find the next record
+ self.assertEqual(sorted([rev1, rev2]), sorted(result.keys()))
+ finally:
+ r2.unlock()
+ finally:
+ tree.unlock()
+
def test_lock_write_does_not_physically_lock(self):
repo = self.make_repository('.', format=self.get_format())
repo.lock_write()
More information about the bazaar-commits
mailing list