Rev 4519: Tests that VF implementations support .get_annotator() in http://bazaar.launchpad.net/~jameinel/bzr/1.17-rework-annotate
John Arbash Meinel
john at arbash-meinel.com
Mon Jul 6 21:22:03 BST 2009
At http://bazaar.launchpad.net/~jameinel/bzr/1.17-rework-annotate
------------------------------------------------------------
revno: 4519
revision-id: john at arbash-meinel.com-20090706202134-19iakgxrs3yxi7k7
parent: john at arbash-meinel.com-20090706193707-ipgtqgtlkua2pxno
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 1.17-rework-annotate
timestamp: Mon 2009-07-06 15:21:34 -0500
message:
Tests that VF implementations support .get_annotator()
This also meant supporting no-graph style VF implementations, which
wasn't too bad.
-------------- next part --------------
=== modified file 'bzrlib/_annotator_pyx.pyx'
--- a/bzrlib/_annotator_pyx.pyx 2009-07-06 19:16:19 +0000
+++ b/bzrlib/_annotator_pyx.pyx 2009-07-06 20:21:34 +0000
@@ -289,6 +289,9 @@
needed_keys = set()
next_parent_map.update(self._vf.get_parent_map(parent_lookup))
for key, parent_keys in next_parent_map.iteritems():
+ if parent_keys is None:
+ parent_keys = ()
+ next_parent_map[key] = ()
self._update_needed_children(key, parent_keys)
for key in parent_keys:
if key not in parent_map:
=== modified file 'bzrlib/groupcompress.py'
--- a/bzrlib/groupcompress.py 2009-07-02 21:43:05 +0000
+++ b/bzrlib/groupcompress.py 2009-07-06 20:21:34 +0000
@@ -1072,6 +1072,9 @@
ann = annotate.Annotator(self)
return ann.annotate_flat(key)
+ def get_annotator(self):
+ return annotate.Annotator(self)
+
def check(self, progress_bar=None):
"""See VersionedFiles.check()."""
keys = self.keys()
=== modified file 'bzrlib/knit.py'
--- a/bzrlib/knit.py 2009-07-06 19:37:07 +0000
+++ b/bzrlib/knit.py 2009-07-06 20:21:34 +0000
@@ -1042,6 +1042,9 @@
"""See VersionedFiles.annotate."""
return self._factory.annotate(self, key)
+ def get_annotator(self):
+ return _KnitAnnotator(self)
+
def check(self, progress_bar=None):
"""See VersionedFiles.check()."""
# This doesn't actually test extraction of everything, but that will
@@ -3422,7 +3425,7 @@
pending.update([p for p in parent_keys
if p not in self._all_build_details])
else:
- raise ValueError('i dont handle ghosts')
+ raise errors.RevisionNotPresent(key, self._vf)
# Generally we will want to read the records in reverse order, because
# we find the parent nodes after the children
records.reverse()
=== modified file 'bzrlib/tests/test_versionedfile.py'
--- a/bzrlib/tests/test_versionedfile.py 2009-06-22 15:37:06 +0000
+++ b/bzrlib/tests/test_versionedfile.py 2009-07-06 20:21:34 +0000
@@ -1557,6 +1557,42 @@
self.assertRaises(RevisionNotPresent,
files.annotate, prefix + ('missing-key',))
+ def test_get_annotator(self):
+ files = self.get_versionedfiles()
+ self.get_diamond_files(files)
+ origin_key = self.get_simple_key('origin')
+ base_key = self.get_simple_key('base')
+ left_key = self.get_simple_key('left')
+ right_key = self.get_simple_key('right')
+ merged_key = self.get_simple_key('merged')
+ # annotator = files.get_annotator()
+ # introduced full text
+ origins, lines = files.get_annotator().annotate(origin_key)
+ self.assertEqual([(origin_key,)], origins)
+ self.assertEqual(['origin\n'], lines)
+ # a delta
+ origins, lines = files.get_annotator().annotate(base_key)
+ self.assertEqual([(base_key,)], origins)
+ # a merge
+ origins, lines = files.get_annotator().annotate(merged_key)
+ if self.graph:
+ self.assertEqual([
+ (base_key,),
+ (left_key,),
+ (right_key,),
+ (merged_key,),
+ ], origins)
+ else:
+ # Without a graph everything is new.
+ self.assertEqual([
+ (merged_key,),
+ (merged_key,),
+ (merged_key,),
+ (merged_key,),
+ ], origins)
+ self.assertRaises(RevisionNotPresent,
+ files.get_annotator().annotate, self.get_simple_key('missing-key'))
+
def test_construct(self):
"""Each parameterised test can be constructed on a transport."""
files = self.get_versionedfiles()
=== modified file 'bzrlib/versionedfile.py'
--- a/bzrlib/versionedfile.py 2009-06-22 15:47:25 +0000
+++ b/bzrlib/versionedfile.py 2009-07-06 20:21:34 +0000
@@ -30,6 +30,7 @@
import urllib
from bzrlib import (
+ annotate,
errors,
groupcompress,
index,
@@ -1122,6 +1123,9 @@
result.append((prefix + (origin,), line))
return result
+ def get_annotator(self):
+ return annotate.Annotator(self)
+
def check(self, progress_bar=None):
"""See VersionedFiles.check()."""
for prefix, vf in self._iter_all_components():
More information about the bazaar-commits
mailing list