merge: break out "both renamed a -> b" case
authorMartin von Zweigbergk <martinvonz@google.com>
Mon, 24 Nov 2014 16:42:36 -0800
changeset 23397 c7c95838be9a
parent 23396 6a254a2dd37c
child 23398 9da5a7413eb8
merge: break out "both renamed a -> b" case We can further limit the scope of the 2-way merge case by breaking out the case where the file was not created from scratch on both sides but rather renamed in the same way (and is therefore a 3-way merge). This involves copying some code, but it makes it clearer which case the "Note:" in the code refers to.
mercurial/merge.py
tests/test-rename-merge2.t
--- a/mercurial/merge.py	Mon Nov 24 16:16:34 2014 -0800
+++ b/mercurial/merge.py	Mon Nov 24 16:42:36 2014 -0800
@@ -416,11 +416,15 @@
             continue
         if n1 and n2:
             if f not in ma:
-                # Note: f as ancestor is wrong - we can't really make a 3-way
-                # merge without an ancestor file.
-                fa = copy.get(f, f)
-                actions['m'].append((f, (f, f, fa, False, pa.node()),
-                               "both created"))
+                fa = copy.get(f, None)
+                if fa is not None:
+                    actions['m'].append((f, (f, f, fa, False, pa.node()),
+                                   "both renamed from " + fa))
+                else:
+                    # Note: f as ancestor is wrong - we can't really make a
+                    # 3-way merge without an ancestor file.
+                    actions['m'].append((f, (f, f, f, False, pa.node()),
+                                   "both created"))
             else:
                 a = ma[f]
                 fla = ma.flags(f)
--- a/tests/test-rename-merge2.t	Mon Nov 24 16:16:34 2014 -0800
+++ b/tests/test-rename-merge2.t	Mon Nov 24 16:42:36 2014 -0800
@@ -343,7 +343,7 @@
    ancestor: 924404dff337, local: 62e7bf090eba+, remote: 49b6d8032493
    preserving b for resolve of b
    preserving rev for resolve of rev
-   b: both created -> m
+   b: both renamed from a -> m
   updating: b 1/2 files (50.00%)
   picked tool 'python ../merge' for b (binary False symlink False)
   merging b