Rev 3015: Test that missing_revision_ids handles the case of the source not having the requested revision correctly with and without find_ghosts. in http://people.ubuntu.com/~robertc/baz2.0/pack.read-locks
Robert Collins
robertc at robertcollins.net
Wed Nov 21 23:36:43 GMT 2007
At http://people.ubuntu.com/~robertc/baz2.0/pack.read-locks
------------------------------------------------------------
revno: 3015
revision-id:robertc at robertcollins.net-20071121233632-63hxiuhd5kcweg21
parent: robertc at robertcollins.net-20071121233532-6pr4b7vvq3s01b7m
committer: Robert Collins <robertc at robertcollins.net>
branch nick: pack.read-locks
timestamp: Thu 2007-11-22 10:36:32 +1100
message:
Test that missing_revision_ids handles the case of the source not having the requested revision correctly with and without find_ghosts.
modified:
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/tests/interrepository_implementations/test_interrepository.py test_interrepository.py-20060220061411-1ec13fa99e5e3eee
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2007-11-09 17:50:31 +0000
+++ b/bzrlib/repository.py 2007-11-21 23:36:32 +0000
@@ -792,14 +792,15 @@
(format, data_list, StringIO(knit_bytes).read))
@needs_read_lock
- def missing_revision_ids(self, other, revision_id=None):
+ def missing_revision_ids(self, other, revision_id=None, find_ghosts=True):
"""Return the revision ids that other has that this does not.
These are returned in topological order.
revision_id: only return revision ids included by revision_id.
"""
- return InterRepository.get(other, self).missing_revision_ids(revision_id)
+ return InterRepository.get(other, self).missing_revision_ids(
+ revision_id, find_ghosts)
@staticmethod
def open(base):
@@ -2032,7 +2033,7 @@
raise NotImplementedError(self.fetch)
@needs_read_lock
- def missing_revision_ids(self, revision_id=None):
+ def missing_revision_ids(self, revision_id=None, find_ghosts=True):
"""Return the revision ids that source has that target does not.
These are returned in topological order.
@@ -2199,7 +2200,7 @@
return f.count_copied, f.failed_revisions
@needs_read_lock
- def missing_revision_ids(self, revision_id=None):
+ def missing_revision_ids(self, revision_id=None, find_ghosts=True):
"""See InterRepository.missing_revision_ids()."""
# we want all revisions to satisfy revision_id in source.
# but we don't want to stat every file here and there.
@@ -2277,7 +2278,7 @@
return f.count_copied, f.failed_revisions
@needs_read_lock
- def missing_revision_ids(self, revision_id=None):
+ def missing_revision_ids(self, revision_id=None, find_ghosts=True):
"""See InterRepository.missing_revision_ids()."""
if revision_id is not None:
source_ids = self.source.get_ancestry(revision_id)
@@ -2354,7 +2355,7 @@
# sensibly detect 'new revisions' without doing a full index scan.
elif _mod_revision.is_null(revision_id):
# nothing to do:
- return
+ return (0, [])
else:
try:
revision_ids = self.missing_revision_ids(revision_id,
@@ -2370,9 +2371,9 @@
# a pack creation, but for now it is simpler to think about as
# 'upload data, then repack if needed'.
self.target._pack_collection.autopack()
- return pack.get_revision_count()
+ return (pack.get_revision_count(), [])
else:
- return 0
+ return (0, [])
@needs_read_lock
def missing_revision_ids(self, revision_id=None, find_ghosts=True):
@@ -2399,6 +2400,12 @@
target_index.iter_entries(target_keys))
missing_revs.update(next_revs - have_revs)
searcher.stop_searching_any(have_revs)
+ if next_revs - have_revs == set([revision_id]):
+ # we saw the start rev itself, but no parents from it (or
+ # next_revs would have been updated to e.g. set(). We remove
+ # have_revs because if we found revision_id locally we
+ # stop_searching at the first time around.
+ raise errors.NoSuchRevision(self.source, revision_id)
return missing_revs
elif revision_id is not None:
source_ids = self.source.get_ancestry(revision_id)
=== modified file 'bzrlib/tests/interrepository_implementations/test_interrepository.py'
--- a/bzrlib/tests/interrepository_implementations/test_interrepository.py 2007-10-30 17:39:11 +0000
+++ b/bzrlib/tests/interrepository_implementations/test_interrepository.py 2007-11-21 23:36:32 +0000
@@ -275,6 +275,20 @@
self.assertEqual(['rev2'],
repo_b.missing_revision_ids(repo_a))
+ def test_missing_revision_ids_absent_requested_raises(self):
+ # Asking for missing revisions with a tip that is itself absent in the
+ # source raises NoSuchRevision.
+ repo_b = self.make_to_repository('target')
+ repo_a = self.bzrdir.open_repository()
+ # No pizza revisions anywhere
+ self.assertFalse(repo_a.has_revision('pizza'))
+ self.assertFalse(repo_b.has_revision('pizza'))
+ # Asking specifically for an absent revision errors.
+ self.assertRaises(NoSuchRevision, repo_b.missing_revision_ids, repo_a,
+ revision_id='pizza', find_ghosts=True)
+ self.assertRaises(NoSuchRevision, repo_b.missing_revision_ids, repo_a,
+ revision_id='pizza', find_ghosts=False)
+
def test_missing_revision_ids_revision_limited(self):
# revision ids in repository A that are not referenced by the
# requested revision are not returned.
More information about the bazaar-commits
mailing list