Rev 2294: Define Repository.revision_tree() as raising NoSuchRevision in http://bzr.arbash-meinel.com/branches/bzr/0.15-dev/revision_tree_errors
John Arbash Meinel
john at arbash-meinel.com
Sat Feb 17 03:03:02 GMT 2007
At http://bzr.arbash-meinel.com/branches/bzr/0.15-dev/revision_tree_errors
------------------------------------------------------------
revno: 2294
revision-id: john at arbash-meinel.com-20070217030255-3c28dk4caoq3phm0
parent: pqm at pqm.ubuntu.com-20070216064835-76166d68f1750e11
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: revision_tree_errors
timestamp: Fri 2007-02-16 21:02:55 -0600
message:
Define Repository.revision_tree() as raising NoSuchRevision
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/tests/repository_implementations/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS 2007-02-15 15:11:31 +0000
+++ b/NEWS 2007-02-17 03:02:55 +0000
@@ -94,6 +94,11 @@
you pass a Unicode string rather than an 8-bit string. Callers need
to be updated to encode first. (John Arbash Meinel)
+ * ``Repository.revision_tree()`` now defined as raising
+ ``NoSuchRevision`` when a given revision cannot be found.
+ (Previously it could raise ``RevisionNotPresent``).
+ (John Arbash Meinel)
+
BUGFIXES:
* ``bzr annotate`` now uses dotted revnos from the viewpoint of the
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2007-02-14 20:28:01 +0000
+++ b/bzrlib/repository.py 2007-02-17 03:02:55 +0000
@@ -710,8 +710,7 @@
return RevisionTree(self, Inventory(root_id=None),
_mod_revision.NULL_REVISION)
else:
- inv = self.get_revision_inventory(revision_id)
- return RevisionTree(self, inv, revision_id)
+ return list(self.revision_trees([revision_id]))[0]
@needs_read_lock
def revision_trees(self, revision_ids):
@@ -720,7 +719,11 @@
`revision_id` may not be None or 'null:'"""
assert None not in revision_ids
assert _mod_revision.NULL_REVISION not in revision_ids
- texts = self.get_inventory_weave().get_texts(revision_ids)
+ try:
+ texts = self.get_inventory_weave().get_texts(revision_ids)
+ except errors.RevisionNotPresent, e:
+ # Translate a weave's RevisionNotPresent into NoSuchRevision
+ raise errors.NoSuchRevision(self, e.revision_id)
for text, revision_id in zip(texts, revision_ids):
inv = self.deserialise_inventory(revision_id, text)
yield RevisionTree(self, inv, revision_id)
=== modified file 'bzrlib/tests/repository_implementations/test_repository.py'
--- a/bzrlib/tests/repository_implementations/test_repository.py 2007-02-06 08:16:13 +0000
+++ b/bzrlib/tests/repository_implementations/test_repository.py 2007-02-17 03:02:55 +0000
@@ -170,6 +170,31 @@
self.assertEqual([], list(tree.list_files(include_root=True)))
tree = wt.branch.repository.revision_tree(NULL_REVISION)
self.assertEqual([], list(tree.list_files(include_root=True)))
+ self.assertRaises(errors.NoSuchRevision,
+ wt.branch.repository.revision_tree,
+ 'non-existent-rev')
+
+ def test_empty_revision_tree(self):
+ wt = self.make_branch_and_tree('.')
+ tree = wt.branch.repository.revision_tree(NULL_REVISION)
+ self.assertIs(None, tree.inventory.root)
+
+ def test_revision_trees(self):
+ wt = self.make_branch_and_tree('.')
+ self.build_tree(['a'])
+ wt.add('a')
+ wt.commit('a', rev_id='rev-1')
+ self.build_tree(['b'])
+ wt.add('b')
+ wt.commit('b', rev_id='rev-2')
+ trees = list(wt.branch.repository.revision_trees(['rev-2', 'rev-1']))
+ self.assertEqual('rev-2', trees[0].get_revision_id())
+ self.assertEqual('rev-1', trees[1].get_revision_id())
+ self.assertRaises(errors.NoSuchRevision, list,
+ wt.branch.repository.revision_trees(['non-existent-rev']))
+ self.assertRaises(errors.NoSuchRevision, list,
+ wt.branch.repository.revision_trees(
+ ['rev-1', 'non-existent-rev', 'rev-2']))
def test_fetch(self):
# smoke test fetch to ensure that the convenience function works.
More information about the bazaar-commits
mailing list