Rev 4464: Start working on 'annotate_flat' which conforms to the original spec. in http://bazaar.launchpad.net/~jameinel/bzr/1.17-rework-annotate

John Arbash Meinel john at arbash-meinel.com
Thu Jun 18 19:48:54 BST 2009


At http://bazaar.launchpad.net/~jameinel/bzr/1.17-rework-annotate

------------------------------------------------------------
revno: 4464
revision-id: john at arbash-meinel.com-20090618184833-sbl535idwmrhh833
parent: john at arbash-meinel.com-20090618184206-11b6qc9z8qrgfcah
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 1.17-rework-annotate
timestamp: Thu 2009-06-18 13:48:33 -0500
message:
  Start working on 'annotate_flat' which conforms to the original spec.
-------------- next part --------------
=== modified file 'bzrlib/_annotator_py.py'
--- a/bzrlib/_annotator_py.py	2009-06-18 18:42:06 +0000
+++ b/bzrlib/_annotator_py.py	2009-06-18 18:48:33 +0000
@@ -151,3 +151,18 @@
         except KeyError:
             raise errors.RevisionNotPresent(key, self._vf)
         return annotations, self._text_cache[key]
+
+    def annotate_flat(self, key):
+        """Determine the single-best-revision to source for each line.
+
+        This is meant as a compatibility thunk to how annotate() used to work.
+        """
+        graph = _mod_graph.KnownGraph(self._parent_map)
+        heads = graph.heads
+        annotations, lines = self.annotate(key)
+        assert len(annotations) == len(lines)
+        out = []
+        for annotation, line in zip(annotations, lines):
+            if len(annotation) == 1:
+                out.append((annotation[0], line))
+        return out

=== modified file 'bzrlib/tests/test__annotator.py'
--- a/bzrlib/tests/test__annotator.py	2009-06-17 20:32:50 +0000
+++ b/bzrlib/tests/test__annotator.py	2009-06-18 18:48:33 +0000
@@ -167,3 +167,13 @@
         ann = self.module.Annotator(self.vf)
         self.assertAnnotateEqual([(self.fa_key,), (self.fa_key, self.fc_key)],
                                  ann, self.fd_key)
+
+    def test_annotate_flat_simple(self):
+        self.make_simple_text()
+        ann = self.module.Annotator(self.vf)
+        self.assertEqual([(self.fa_key, 'simple\n'),
+                          (self.fa_key, 'content\n'),
+                         ], ann.annotate_flat(self.fa_key))
+        self.assertEqual([(self.fa_key, 'simple\n'),
+                          (self.fb_key, 'new content\n'),
+                         ], ann.annotate_flat(self.fb_key))



More information about the bazaar-commits mailing list