mercurial/merge.py
changeset 20897 0b50788c160c
parent 20870 6500a2eebee8
child 20943 003cb972178d
--- a/mercurial/merge.py	Wed Apr 02 00:01:21 2014 -0700
+++ b/mercurial/merge.py	Tue Feb 25 20:30:08 2014 +0100
@@ -340,7 +340,7 @@
             pmmf.discard(f)
         pmmf.add(fd)
     def mergeop(f, args):
-        f2, fd, move = args
+        f2, fa, fd, move = args
         if move:
             pmmf.discard(f)
         pmmf.add(fd)
@@ -468,7 +468,7 @@
             elif nol and n1 == a: # local only changed 'x'
                 actions.append((f, "g", (fl1,), "remote is newer"))
             else: # both changed something
-                actions.append((f, "m", (f, f, False), "versions differ"))
+                actions.append((f, "m", (f, fa, f, False), "versions differ"))
         elif f in copied: # files we'll deal with on m2 side
             pass
         elif n1 and f in movewithdir: # directory rename
@@ -477,7 +477,7 @@
                             "remote renamed directory to " + f2))
         elif n1 and f in copy:
             f2 = copy[f]
-            actions.append((f, "m", (f2, f, False),
+            actions.append((f, "m", (f2, f2, f, False),
                             "local copied/moved to " + f2))
         elif n1 and f in ma: # clean, a different, no remote
             if n1 != ma[f]:
@@ -496,10 +496,10 @@
         elif n2 and f in copy:
             f2 = copy[f]
             if f2 in m2:
-                actions.append((f2, "m", (f, f, False),
+                actions.append((f2, "m", (f, f2, f, False),
                                 "remote copied to " + f))
             else:
-                actions.append((f2, "m", (f, f, True),
+                actions.append((f2, "m", (f, f2, f, True),
                                 "remote moved to " + f))
         elif n2 and f not in ma:
             # local unknown, remote created: the logic is described by the
@@ -519,7 +519,8 @@
             else:
                 different = _checkunknownfile(repo, wctx, p2, f)
                 if force and branchmerge and different:
-                    actions.append((f, "m", (f, f, False),
+                    # FIXME: This is wrong - f is not in ma ...
+                    actions.append((f, "m", (f, f, f, False),
                                     "remote differs from untracked local"))
                 elif not force and different:
                     aborts.append((f, "ud"))
@@ -617,7 +618,7 @@
         f, m, args, msg = a
         repo.ui.debug(" %s: %s -> %s\n" % (f, msg, m))
         if m == "m": # merge
-            f2, fd, move = args
+            f2, fa, fd, move = args
             if fd == '.hgsubstate': # merged internally
                 continue
             repo.ui.debug("  preserving %s for resolve of %s\n" % (f, fd))
@@ -628,9 +629,9 @@
                     fca = fcl.p1()
                 else:
                     fca = repo.filectx(f, fileid=nullrev)
+            elif fa in actx:
+                fca = actx[fa]
             else:
-                fca = fcl.ancestor(fco, actx)
-            if not fca:
                 fca = repo.filectx(f, fileid=nullrev)
             ms.add(fcl, fco, fca, fd)
             if f != fd and move:
@@ -682,7 +683,7 @@
         f, m, args, msg = a
         progress(_updating, z + i + 1, item=f, total=numupdates, unit=_files)
         if m == "m": # merge
-            f2, fd, move = args
+            f2, fa, fd, move = args
             if fd == '.hgsubstate': # subrepo states need updating
                 subrepo.submerge(repo, wctx, mctx, wctx.ancestor(mctx),
                                  overwrite)
@@ -792,7 +793,7 @@
             else:
                 repo.dirstate.normal(f)
         elif m == "m": # merge
-            f2, fd, move = args
+            f2, fa, fd, move = args
             if branchmerge:
                 # We've done a branch merge, mark this file as merged
                 # so that we properly record the merger later