diff mercurial/merge.py @ 23396:6a254a2dd37c

merge: separate out "both created" cases When 'f' is not in 'ma', 'a' will be 'nullid' and all the if/elif conditions that check whether some one nodeid is equal to 'a' will fail, and the else-clause will instead apply. We can make that more explicit by creating a separate 'm' action for the case where 'a' is 'nullid'. While it does mean copying some code, perhaps it makes it a little clearer which codepaths are possible, and which cases the "Note:" in the code refers to. It also lets us make the debug action messages a little more specific.
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 24 Nov 2014 16:16:34 -0800
parents d9ebb475eede
children c7c95838be9a
line wrap: on
line diff
--- a/mercurial/merge.py	Mon Nov 24 16:11:22 2014 -0800
+++ b/mercurial/merge.py	Mon Nov 24 16:16:34 2014 -0800
@@ -415,14 +415,15 @@
         if partial and not partial(f):
             continue
         if n1 and n2:
-            if True:
-                fa = f
-                a = ma.get(f, nullid)
-                if a == nullid:
-                    fa = copy.get(f, f)
-                    # Note: f as default is wrong - we can't really make a 3-way
-                    # merge without an ancestor file.
-                fla = ma.flags(fa)
+            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"))
+            else:
+                a = ma[f]
+                fla = ma.flags(f)
                 nol = 'l' not in fl1 + fl2 + fla
                 if n2 == a and fl2 == fla:
                     actions['k'].append((f, (), "keep")) # remote unchanged
@@ -436,7 +437,7 @@
                 elif nol and n1 == a: # local only changed 'x'
                     actions['g'].append((f, (fl1,), "remote is newer"))
                 else: # both changed something
-                    actions['m'].append((f, (f, f, fa, False, pa.node()),
+                    actions['m'].append((f, (f, f, f, False, pa.node()),
                                    "versions differ"))
         elif f in copied: # files we'll deal with on m2 side
             pass