Rev 3589: Simple patch to the annotate logic to handle bug #232188 in http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/simple_annotate

John Arbash Meinel john at arbash-meinel.com
Tue Jul 29 17:51:06 BST 2008


At http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/simple_annotate

------------------------------------------------------------
revno: 3589
revision-id: john at arbash-meinel.com-20080729165043-i7acukekx2luhcru
parent: pqm at pqm.ubuntu.com-20080729093250-b1g7zu2k1pj0mswe
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: simple_annotate
timestamp: Tue 2008-07-29 11:50:43 -0500
message:
  Simple patch to the annotate logic to handle bug #232188
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2008-07-29 09:32:50 +0000
+++ b/NEWS	2008-07-29 16:50:43 +0000
@@ -51,6 +51,13 @@
       smart server protocol to or from Windows.
       (Andrew Bennetts, #246180)
 
+    * The default ``annotate`` logic will now always assign the
+      last-modified value of a line to one of the revisions that modified
+      it, rather than a merge revision. This would happen when both sides
+      claimed to have modified the line resulting in the same text. The
+      choice is arbitrary but stable, so merges in different directions
+      will get the same results.  (John Arbash Meinel, #232188)
+
 
   DOCUMENTATION:
 

=== modified file 'bzrlib/annotate.py'
--- a/bzrlib/annotate.py	2008-06-18 07:56:09 +0000
+++ b/bzrlib/annotate.py	2008-07-29 16:50:43 +0000
@@ -285,16 +285,9 @@
                     if len(heads) == 1:
                         output_append((iter(heads).next(), left[1]))
                     else:
-                        # Both claim different origins
-                        output_append((revision_id, left[1]))
-                        # We know that revision_id is the head for
-                        # left and right, so cache it
-                        heads_provider.cache(
-                            (revision_id, left[0]),
-                            (revision_id,))
-                        heads_provider.cache(
-                            (revision_id, right[0]),
-                            (revision_id,))
+                        # Both claim different origins, sort lexicographically
+                        # so that we always get a stable result.
+                        output_append(sorted([left, right])[0])
         last_child_idx = child_idx + match_len
 
 

=== modified file 'bzrlib/tests/test_annotate.py'
--- a/bzrlib/tests/test_annotate.py	2008-02-18 22:19:41 +0000
+++ b/bzrlib/tests/test_annotate.py	2008-07-29 16:50:43 +0000
@@ -116,7 +116,7 @@
 #  |\
 #  A B  # line should be annotated as new for A and B
 #  |\|
-#  C D  # line should 'converge' and say D
+#  C D  # line should 'converge' and say A
 #  |/
 #  E    # D should supersede A and stay as D (not become E because C references
 #         A)
@@ -150,14 +150,14 @@
 
 duplicate_D = annotation("""\
 rev-base first
-rev-D alt-second
+rev-A alt-second
 rev-base third
 rev-D fourth-D
 """)
 
 duplicate_E = annotation("""\
 rev-base first
-rev-D alt-second
+rev-A alt-second
 rev-base third
 rev-E fourth-E
 """)
@@ -184,7 +184,7 @@
                      committer="joe at foo.com",
                      timestamp=1166046000.00, timezone=0)
 
-        tree2 = tree1.bzrdir.clone('tree2').open_workingtree()
+        tree2 = tree1.bzrdir.sprout('tree2').open_workingtree()
 
         self.build_tree_contents([('tree1/a', 'first\nsecond\n')])
         tree1.commit('b', rev_id='rev-2',
@@ -235,7 +235,7 @@
         tree1, tree2 = self.create_merged_trees()
         tree1.unlock()
 
-        tree3 = tree2.bzrdir.clone('tree3').open_workingtree()
+        tree3 = tree2.bzrdir.sprout('tree3').open_workingtree()
 
         tree2.commit('noop', rev_id='rev-1_1_2')
         self.assertEqual(0, tree1.merge_from_branch(tree2.branch))
@@ -246,7 +246,7 @@
                      committer='jerry at foo.com',
                      timestamp=1166046003.00, timezone=0)
 
-        tree4 = tree3.bzrdir.clone('tree4').open_workingtree()
+        tree4 = tree3.bzrdir.sprout('tree4').open_workingtree()
 
         tree3.commit('noop', rev_id='rev-1_2_2',
                      committer='jerry at foo.com',
@@ -275,7 +275,7 @@
         self.build_tree_contents([('tree1/file', base_text)])
         tree1.add(['file'], ['file-id'])
         tree1.commit('base', rev_id='rev-base')
-        tree2 = tree1.bzrdir.clone('tree2').open_workingtree()
+        tree2 = tree1.bzrdir.sprout('tree2').open_workingtree()
 
         self.build_tree_contents([('tree1/file', a_text),
                                   ('tree2/file', b_text)])



More information about the bazaar-commits mailing list