Rev 3037: Add an interrepository test that when we are missing a basis text, in http://bzr.arbash-meinel.com/branches/bzr/0.93-dev/fetch_check_parents_165290
John Arbash Meinel
john at arbash-meinel.com
Thu Nov 29 22:42:52 GMT 2007
At http://bzr.arbash-meinel.com/branches/bzr/0.93-dev/fetch_check_parents_165290
------------------------------------------------------------
revno: 3037
revision-id:john at arbash-meinel.com-20071129224130-m720z00xtmovmj06
parent: john at arbash-meinel.com-20071129222729-cq78j0uzbqzvnm7z
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: fetch_check_parents_165290
timestamp: Thu 2007-11-29 16:41:30 -0600
message:
Add an interrepository test that when we are missing a basis text,
we either complain or fetch the missing text.
Currently fails for pack repositories.
modified:
bzrlib/tests/interrepository_implementations/test_interrepository.py test_interrepository.py-20060220061411-1ec13fa99e5e3eee
-------------- next part --------------
=== modified file 'bzrlib/tests/interrepository_implementations/test_interrepository.py'
--- a/bzrlib/tests/interrepository_implementations/test_interrepository.py 2007-11-26 20:18:50 +0000
+++ b/bzrlib/tests/interrepository_implementations/test_interrepository.py 2007-11-29 22:41:30 +0000
@@ -158,7 +158,50 @@
# makes a target version repo
repo_b = self.make_to_repository('b')
check_push_rev1(repo_b)
-
+
+ def test_fetch_missing_basis_text(self):
+ """If fetching a delta, we should die if a basis is not present."""
+ tree = self.make_branch_and_tree('tree')
+ self.build_tree(['tree/a'])
+ tree.add(['a'], ['a-id'])
+ tree.commit('one', rev_id='rev-one')
+ self.build_tree_contents([('tree/a', 'new contents\n')])
+ tree.commit('two', rev_id='rev-two')
+
+ to_repo = self.make_to_repository('to_repo')
+ # We build a broken revision so that we can test the fetch code dies
+ # properly. So copy the inventory and revision, but not the text.
+ to_repo.lock_write()
+ try:
+ to_repo.start_write_group()
+ inv = tree.branch.repository.get_inventory('rev-one')
+ to_repo.add_inventory('rev-one', inv, [])
+ rev = tree.branch.repository.get_revision('rev-one')
+ to_repo.add_revision('rev-one', rev, inv=inv)
+ to_repo.commit_write_group()
+ finally:
+ to_repo.unlock()
+
+ # Implementations can either copy the missing basis text, or raise an
+ # exception
+ try:
+ to_repo.fetch(tree.branch.repository, 'rev-two')
+ except Exception:
+ # If an exception is raised, the revision should not be in the
+ # target.
+ self.assertRaises((errors.NoSuchRevision, errors.RevisionNotPresent),
+ to_repo.revision_tree, 'rev-two')
+ else:
+ # If not exception is raised, then the basis text should be
+ # available.
+ to_repo.lock_read()
+ try:
+ rt = to_repo.revision_tree('rev-one')
+ self.assertEqual('contents of tree/a\n',
+ rt.get_file_text('a-id'))
+ finally:
+ to_repo.unlock()
+
def test_fetch_missing_revision_same_location_fails(self):
repo_a = self.make_repository('.')
repo_b = repository.Repository.open('.')
More information about the bazaar-commits
mailing list