Rev 4712: Reverse the .BASE values for --lca and conflicted lines. in http://bazaar.launchpad.net/~jameinel/bzr/2.0-40412-show-base-weave

John Arbash Meinel john at arbash-meinel.com
Fri Dec 4 04:02:26 GMT 2009


At http://bazaar.launchpad.net/~jameinel/bzr/2.0-40412-show-base-weave

------------------------------------------------------------
revno: 4712
revision-id: john at arbash-meinel.com-20091204040211-7a2ki1g5y2rbmq89
parent: john at arbash-meinel.com-20091204015626-s3igiwbj5qiirwoa
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.0-40412-show-base-weave
timestamp: Thu 2009-12-03 22:02:11 -0600
message:
  Reverse the .BASE values for --lca and conflicted lines.
  
  It is a bit of an option whether we include or remove them. But including
  them in BASE means they will likely be removed in the final target,
  and we would rather have them and remove them manually, than the opposite.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_merge.py'
--- a/bzrlib/tests/test_merge.py	2009-12-04 01:56:26 +0000
+++ b/bzrlib/tests/test_merge.py	2009-12-04 04:02:11 +0000
@@ -920,7 +920,7 @@
                           ('unchanged', 'f\n'),
                          ], plan)
         pwm = versionedfile.PlanWeaveMerge(plan)
-        self.assertEqualDiff('\n'.join('abcdhghef') + '\n',
+        self.assertEqualDiff('\n'.join('abcdgef') + '\n',
                              ''.join(pwm.base_from_plan()))
         # Reversing it changes what line is doubled, but still gives a
         # double-conflict
@@ -937,7 +937,7 @@
                           ('unchanged', 'f\n'),
                          ], plan)
         pwm = versionedfile.PlanWeaveMerge(plan)
-        self.assertEqualDiff('\n'.join('abcdghgef') + '\n',
+        self.assertEqualDiff('\n'.join('abcdhef') + '\n',
                              ''.join(pwm.base_from_plan()))
 
     def assertRemoveExternalReferences(self, filtered_parent_map,

=== modified file 'bzrlib/versionedfile.py'
--- a/bzrlib/versionedfile.py	2009-12-04 01:56:26 +0000
+++ b/bzrlib/versionedfile.py	2009-12-04 04:02:11 +0000
@@ -1518,24 +1518,26 @@
             #      The BASE in both cases is just the current text, with the
             #      'other' 'b' line shown as killed-in-other. Which is why it
             #      merges cleanly.
-            if state in ('killed-a', 'killed-b', 'killed-both', 'unchanged',
-                         'conflicted-a', 'conflicted-b'):
+            if state in ('killed-a', 'killed-b', 'killed-both', 'unchanged'):
                 # If unchanged, then this line is straight from base. If a or b
                 # or both killed the line, then it *used* to be in base.
-                # If 'conflicted-a' or b, then it is new vs one base, but old
-                # versus another base. Which means it was present in *one* of
-                # the bases, so we'll include it.
                 base_lines.append(line)
             else:
                 if state not in ('killed-base', 'irrelevant',
                                  'ghost-a', 'ghost-b',
-                                 'new-a', 'new-b'):
+                                 'new-a', 'new-b',
+                                 'conflicted-a', 'conflicted-b'):
                     # killed-base, irrelevant means it doesn't apply
                     # ghost-a/ghost-b are harder to say for sure, but they
                     # aren't in the 'inc_c' which means they aren't in the
                     # shared base of a & b. So we don't include them.
                     # And obviously if the line is newly inserted, it isn't in
                     # base
+                    # If 'conflicted-a' or b, then it is new vs one base, but old
+                    # versus another base. However, if we make it present in
+                    # the base, it will be deleted from the target, and it
+                    # seems better to get a line doubled in the merge result,
+                    # rather than have it deleted entirely.
                     raise AssertionError('Unknown state: %s' % (state,))
         return base_lines
 



More information about the bazaar-commits mailing list