merge: fix unnecessary rename merges on linear update (
issue631)
If one side's revision is identical to the ancestor, we skip the rest
of the copy detection logic.
--- a/mercurial/merge.py Sun Jul 15 21:04:07 2007 +0200
+++ b/mercurial/merge.py Sun Jul 15 14:43:38 2007 -0500
@@ -157,7 +157,7 @@
fullcopy = {}
diverge = {}
- def checkcopies(c, man):
+ def checkcopies(c, man, aman):
'''check possible copies for filectx c'''
for of in findold(c):
fullcopy[c.path()] = of # remember for dir rename detection
@@ -165,6 +165,10 @@
if of in ma:
diverge.setdefault(of, []).append(c.path())
continue
+ # if the original file is unchanged on the other branch,
+ # no merge needed
+ if man[of] == aman.get(of):
+ continue
c2 = ctx(of, man[of])
ca = c.ancestor(c2)
if not ca: # unrelated?
@@ -186,10 +190,10 @@
u2 = nonoverlap(m2, m1, ma)
for f in u1:
- checkcopies(ctx(f, m1[f]), m2)
+ checkcopies(ctx(f, m1[f]), m2, ma)
for f in u2:
- checkcopies(ctx(f, m2[f]), m1)
+ checkcopies(ctx(f, m2[f]), m1, ma)
d2 = {}
for of, fl in diverge.items():
@@ -197,7 +201,6 @@
fo = list(fl)
fo.remove(f)
d2[f] = (of, fo)
- #diverge = d2
if not fullcopy or not repo.ui.configbool("merge", "followdirs", True):
return copy, diverge