Patchwork [3,of,8,v2] merge: use the right ancestor when both sides copied the same file

login
register
mail settings
Submitter Mads Kiilerich
Date Feb. 25, 2014, 7:40 p.m.
Message ID <f8d9cb25960bcdbef913.1393357225@mk-desktop>
Download mbox | patch
Permalink /patch/3764/
State Superseded
Commit 0dc7a50345c2c64539837a4645f1aa3c162fb4e9
Headers show

Comments

Mads Kiilerich - Feb. 25, 2014, 7:40 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1393356586 -3600
#      Tue Feb 25 20:29:46 2014 +0100
# Node ID f8d9cb25960bcdbef913cfc181496bb22dee3ba2
# Parent  36b081141969ba169f691d6df77c0c3b4bfbc707
merge: use the right ancestor when both sides copied the same file

The tests shows no real changes because of this ... but there must be some
weird corner cases where using the right ancestor for the merge planning is
better than using the wrong one.

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -273,9 +273,14 @@  def manifestmerge(repo, wctx, p2, pa, br
         if partial and not partial(f):
             continue
         if n1 and n2:
-            fla = ma.flags(f)
+            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)
             nol = 'l' not in fl1 + fl2 + fla
-            a = ma.get(f, nullid)
             if n2 == a and fl2 == fla:
                 pass # remote unchanged - keep local
             elif n1 == a and fl1 == fla: # local unchanged - use remote