Mercurial > hg
changeset 3251:c93ce7f10f85
merge: fixes for merge+rename
findcopies: ignore files renamed on both branches
applyupdates: change remove flag to move
recordupdates: record copy actions, including local moves and deletions
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 04 Oct 2006 19:08:04 -0500 |
parents | 7c114915fbdb |
children | ae85272b59a4 53d6bcccdbef |
files | mercurial/merge.py tests/test-rename-merge1 tests/test-rename-merge1.out |
diffstat | 3 files changed, 36 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/merge.py Wed Oct 04 17:59:27 2006 -0500 +++ b/mercurial/merge.py Wed Oct 04 19:08:04 2006 -0500 @@ -151,7 +151,7 @@ ''' check if an apparent pair actually matches ''' c2 = ctx(f2, man[f2]) ca = c.ancestor(c2) - if ca: + if ca and ca.path() == c.path() or ca.path() == c2.path(): copy[c.path()] = f2 copy[f2] = c.path() @@ -284,8 +284,8 @@ (f, inst.strerror)) removed +=1 elif m == "c": # copy - f2, fd, my, other, flag, remove = a[2:] - if filemerge(repo, f, f2, fd, my, other, xp1, xp2, remove): + f2, fd, my, other, flag, move = a[2:] + if filemerge(repo, f, f2, fd, my, other, xp1, xp2, move): unresolved += 1 util.set_exec(repo.wjoin(fd), flag) merged += 1 @@ -339,6 +339,25 @@ fl = repo.file(f) f_len = fl.size(fl.rev(other)) repo.dirstate.update([f], 'n', st_size=f_len, st_mtime=-1) + elif m == "c": # copy + f2, fd, my, other, flag, move = a[2:] + if branchmerge: + # We've done a branch merge, mark this file as merged + # so that we properly record the merger later + repo.dirstate.update([fd], 'm') + else: + # We've update-merged a locally modified file, so + # we set the dirstate to emulate a normal checkout + # of that file some time in the past. Thus our + # merge will appear as a normal local file + # modification. + fl = repo.file(f) + f_len = fl.size(fl.rev(other)) + repo.dirstate.update([fd], 'n', st_size=f_len, st_mtime=-1) + if move: + repo.dirstate.update([f], 'r') + if f != fd: + repo.dirstate.copy(f, fd) def update(repo, node, branchmerge=False, force=False, partial=None, wlock=None, show_stats=True, remind=True):
--- a/tests/test-rename-merge1 Wed Oct 04 17:59:27 2006 -0500 +++ b/tests/test-rename-merge1 Wed Oct 04 19:08:04 2006 -0500 @@ -3,6 +3,8 @@ mkdir t cd t hg init +echo "[merge]" >> .hg/hgrc +echo "followcopies = 1" >> .hg/hgrc echo foo > a echo foo > a2 hg add a a2 @@ -18,6 +20,6 @@ hg ci -m "modify" -d "0 0" echo "merge" hg merge -y --debug -cat a +hg status -AC cat b hg ci -m "merge" -d "0 0"
--- a/tests/test-rename-merge1.out Wed Oct 04 17:59:27 2006 -0500 +++ b/tests/test-rename-merge1.out Wed Oct 04 19:08:04 2006 -0500 @@ -4,11 +4,18 @@ resolving manifests overwrite None branchmerge True partial False ancestor f26ec4fc3fa3 local 8e765a822af2 remote af1939970a1c - b: remote created -> g + a: remote moved -> c b2: remote created -> g -getting b +resolving a +my a@f26ec4fc3fa3 other b@8e765a822af2 ancestor a@af1939970a1c +copying a to b +removing a getting b2 -2 files updated, 0 files merged, 0 files removed, 0 files unresolved +1 files updated, 1 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) +M b + a +M b2 +R a +C c2 blahblah -foo