Mercurial > hg
changeset 3730:d377f8d25662
merge: only store one direction of copies in the copy map
simplify checkpair
generate copied hash from copy map
make copy cases more symmetrical
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 30 Nov 2006 17:36:33 -0600 |
parents | 581d20773326 |
children | b4af5f92e04b |
files | mercurial/merge.py tests/test-rename-merge2.out |
diffstat | 2 files changed, 21 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/merge.py Thu Nov 30 17:36:33 2006 -0600 +++ b/mercurial/merge.py Thu Nov 30 17:36:33 2006 -0600 @@ -136,25 +136,24 @@ def checkpair(c, f2, man): ''' check if an apparent pair actually matches ''' + if f2 not in man: + return c2 = ctx(f2, man[f2]) ca = c.ancestor(c2) if not ca or c == ca or c2 == ca: return if ca.path() == c.path() or ca.path() == c2.path(): copy[c.path()] = f2 - copy[f2] = c.path() for f in u1: c = ctx(dcopies.get(f, f), m1[f]) for of in findold(c, limit): - if of in m2: - checkpair(c, of, m2) + checkpair(c, of, m2) for f in u2: c = ctx(f, m2[f]) for of in findold(c, limit): - if of in m1: - checkpair(c, of, m1) + checkpair(c, of, m1) return copy @@ -176,7 +175,6 @@ backwards = (pa == p2) action = [] copy = {} - copied = {} def fmerge(f, f2=None, fa=None): """merge executable flags""" @@ -192,6 +190,7 @@ if pa and not (backwards or overwrite): copy = findcopies(repo, m1, m2, ma, pa.rev()) + copied = dict.fromkeys(copy.values()) # Compare manifests for f, n in m1.iteritems(): @@ -216,19 +215,16 @@ elif m1.execf(f) != m2.execf(f): if overwrite or fmerge(f) != m1.execf(f): act("update permissions", "e", f, m2.execf(f)) + elif f in copied: + continue elif f in copy: f2 = copy[f] - copied[f2] = True - if f in ma: # case 3,20 A/B/A - act("remote moved to " + f2, "m", - f, f2, f2, fmerge(f, f2, f), True) - else: - if f2 in m1: # case 2 A,B/B/B - act("local copied to " + f2, "m", - f, f2, f, fmerge(f, f2, f2), False) - else: # case 4,21 A/B/B - act("local moved to " + f2, "m", - f, f2, f, fmerge(f, f2, f2), False) + if f2 in m1: # case 2 A,B/B/B + act("local copied to " + f2, "m", + f, f2, f, fmerge(f, f2, f2), False) + else: # case 4,21 A/B/B + act("local moved to " + f2, "m", + f, f2, f, fmerge(f, f2, f2), False) elif f in ma: if n != ma[f] and not overwrite: if repo.ui.prompt( @@ -251,9 +247,12 @@ continue if f in copy: f2 = copy[f] - # rename case 1, A/A,B/A - act("remote copied to " + f, "m", - f2, f, f, fmerge(f2, f, f2), False) + if f2 in m2: # rename case 1, A/A,B/A + act("remote copied to " + f, "m", + f2, f, f, fmerge(f2, f, f2), False) + else: # case 3,20 A/B/A + act("remote moved to " + f, "m", + f2, f, f, fmerge(f2, f, f2), True) elif f in ma: if overwrite or backwards: act("recreating", "g", f, m2.execf(f))
--- a/tests/test-rename-merge2.out Thu Nov 30 17:36:33 2006 -0600 +++ b/tests/test-rename-merge2.out Thu Nov 30 17:36:33 2006 -0600 @@ -47,8 +47,8 @@ resolving manifests overwrite None partial False ancestor 924404dff337 local e300d1c794ec+ remote e03727d2d66b + rev: versions differ -> m a: remote moved to b -> m - rev: versions differ -> m merging a and b my a@e300d1c794ec+ other b@e03727d2d66b ancestor a@924404dff337 copying a to b @@ -351,8 +351,8 @@ resolving manifests overwrite None partial False ancestor 924404dff337 local e300d1c794ec+ remote 79cc6877a3b7 + rev: versions differ -> m a: remote moved to b -> m - rev: versions differ -> m merging a and b my a@e300d1c794ec+ other b@79cc6877a3b7 ancestor a@924404dff337 copying a to b