Rev 4466: Finish fleshing out the ability to determine a revision after conflicts. in http://bazaar.launchpad.net/~jameinel/bzr/1.17-rework-annotate

John Arbash Meinel john at arbash-meinel.com
Thu Jun 18 20:01:10 BST 2009


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

------------------------------------------------------------
revno: 4466
revision-id: john at arbash-meinel.com-20090618190050-npw99yywixsccaok
parent: john at arbash-meinel.com-20090618185855-9b9u711hgm7vtfkz
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 1.17-rework-annotate
timestamp: Thu 2009-06-18 14:00:50 -0500
message:
  Finish fleshing out the ability to determine a revision after conflicts.
-------------- next part --------------
=== modified file 'bzrlib/_annotator_py.py'
--- a/bzrlib/_annotator_py.py	2009-06-18 18:48:33 +0000
+++ b/bzrlib/_annotator_py.py	2009-06-18 19:00:50 +0000
@@ -157,12 +157,22 @@
 
         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 = []
+        graph = _mod_graph.KnownGraph(self._parent_map)
+        heads = graph.heads
         for annotation, line in zip(annotations, lines):
             if len(annotation) == 1:
                 out.append((annotation[0], line))
+            else:
+                the_heads = heads(annotation)
+                if len(the_heads) == 1:
+                    for head in the_heads:
+                        break
+                    out.append((head, line))
+                else:
+                    # We need to resolve the ambiguity, for now just pick the
+                    # sorted smallest
+                    out.append((sorted(the_heads)[0], line))
         return out

=== modified file 'bzrlib/tests/test__annotator.py'
--- a/bzrlib/tests/test__annotator.py	2009-06-18 18:48:33 +0000
+++ b/bzrlib/tests/test__annotator.py	2009-06-18 19:00:50 +0000
@@ -65,6 +65,8 @@
     fb_key = ('f-id', 'b-id')
     fc_key = ('f-id', 'c-id')
     fd_key = ('f-id', 'd-id')
+    fe_key = ('f-id', 'e-id')
+    ff_key = ('f-id', 'f-id')
 
     def make_simple_text(self):
         self.repo = self.make_repository('repo')
@@ -113,6 +115,24 @@
         else:
             self.repo.commit_write_group()
 
+    def make_many_way_common_merge_text(self):
+        self.make_simple_text()
+        self.repo.start_write_group()
+        try:
+            self.vf.add_lines(self.fc_key, [self.fa_key],
+                              ['simple\n', 'new content\n'])
+            self.vf.add_lines(self.fd_key, [self.fb_key, self.fc_key],
+                              ['simple\n', 'new content\n'])
+            self.vf.add_lines(self.fe_key, [self.fa_key],
+                              ['simple\n', 'new content\n'])
+            self.vf.add_lines(self.ff_key, [self.fd_key, self.fe_key],
+                              ['simple\n', 'new content\n'])
+        except:
+            self.repo.abort_write_group()
+            raise
+        else:
+            self.repo.commit_write_group()
+
     def make_merge_and_restored_text(self):
         self.make_simple_text()
         self.repo.start_write_group()
@@ -162,6 +182,13 @@
         self.assertAnnotateEqual([(self.fa_key,), (self.fb_key, self.fc_key)],
                                  ann, self.fd_key)
 
+    def test_annotate_many_way_common_merge_text(self):
+        self.make_many_way_common_merge_text()
+        ann = self.module.Annotator(self.vf)
+        self.assertAnnotateEqual([(self.fa_key,),
+                                  (self.fb_key, self.fc_key, self.fe_key)],
+                                 ann, self.ff_key)
+
     def test_annotate_merge_and_restored(self):
         self.make_merge_and_restored_text()
         ann = self.module.Annotator(self.vf)
@@ -177,3 +204,28 @@
         self.assertEqual([(self.fa_key, 'simple\n'),
                           (self.fb_key, 'new content\n'),
                          ], ann.annotate_flat(self.fb_key))
+
+    def test_annotate_flat_merge_and_restored_text(self):
+        self.make_merge_and_restored_text()
+        ann = self.module.Annotator(self.vf)
+        # fc is a simple dominator of fa
+        self.assertEqual([(self.fa_key, 'simple\n'),
+                          (self.fc_key, 'content\n'),
+                         ], ann.annotate_flat(self.fd_key))
+
+    def test_annotate_common_merge_text(self):
+        self.make_common_merge_text()
+        ann = self.module.Annotator(self.vf)
+        # there is no common point, so we just pick the lexicographical lowest
+        # and 'b-id' comes before 'c-id'
+        self.assertEqual([(self.fa_key, 'simple\n'),
+                          (self.fb_key, 'new content\n'),
+                         ], ann.annotate_flat(self.fd_key))
+
+    def test_annotate_many_way_common_merge_text(self):
+        self.make_many_way_common_merge_text()
+        ann = self.module.Annotator(self.vf)
+        self.assertAnnotateEqual([(self.fa_key, 'simple\n'),
+                                  (self.fb_key, 'new content\n')],
+                                 ann, self.ff_key)
+



More information about the bazaar-commits mailing list