merge: avoid double deletion mentioned in issue636
authorMatt Mackall <mpm@selenic.com>
Thu, 02 Aug 2007 12:29:10 -0500
changeset 5059 8d9bdcbb2b18
parent 5058 a3d6de2838de
child 5060 2ef14e29e538
child 5061 a49f2a4d5ff7
merge: avoid double deletion mentioned in issue636
mercurial/merge.py
tests/test-copy-move-merge
tests/test-copy-move-merge.out
--- a/mercurial/merge.py	Thu Aug 02 13:03:25 2007 +0200
+++ b/mercurial/merge.py	Thu Aug 02 12:29:10 2007 -0500
@@ -415,10 +415,10 @@
                     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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-copy-move-merge	Thu Aug 02 12:29:10 2007 -0500
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-copy-move-merge.out	Thu Aug 02 12:29:10 2007 -0500
@@ -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