diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -415,10 +415,10 @@ def applyupdates(repo, action, wctx, mct updated += 1 else: merged += 1 - if f != fd and move: + util.set_exec(repo.wjoin(fd), "x" in flags) + if f != fd and move and util.lexists(repo.wjoin(f)): repo.ui.debug(_("removing %s\n") % f) os.unlink(repo.wjoin(f)) - util.set_exec(repo.wjoin(fd), "x" in flags) elif m == "g": # get flags = a[2] repo.ui.note(_("getting %s\n") % f) diff --git a/tests/test-copy-move-merge b/tests/test-copy-move-merge new file mode 100755 --- /dev/null +++ b/tests/test-copy-move-merge @@ -0,0 +1,30 @@ +#!/bin/sh + +mkdir t +cd t +hg init + +echo 1 > a +hg ci -qAm "first" -d "1000000 0" + +hg cp a b +hg mv a c +echo 2 >> b +echo 2 >> c + +hg ci -qAm "second" -d "1000000 0" + +hg co -C 0 + +echo 0 > a +echo 1 >> a + +hg ci -qAm "other" -d "1000000 0" + +hg merge --debug + +echo "-- b --" +cat b + +echo "-- c --" +cat c diff --git a/tests/test-copy-move-merge.out b/tests/test-copy-move-merge.out new file mode 100644 --- /dev/null +++ b/tests/test-copy-move-merge.out @@ -0,0 +1,23 @@ +1 files updated, 0 files merged, 2 files removed, 0 files unresolved +resolving manifests + overwrite None partial False + ancestor 583c7b748052 local fb3948d97f07+ remote 40da226db0f0 + a: remote moved to c -> m + a: remote moved to b -> m +copying a to b +copying a to c +merging a and b +my a@fb3948d97f07+ other b@40da226db0f0 ancestor a@583c7b748052 +removing a +merging a and c +my a@fb3948d97f07+ other c@40da226db0f0 ancestor a@583c7b748052 +0 files updated, 2 files merged, 0 files removed, 0 files unresolved +(branch merge, don't forget to commit) +-- b -- +0 +1 +2 +-- c -- +0 +1 +2