merge: fix small bug with a failed merge across a rename
If $HGMERGE wasn't able to fix the conflicts, we wouldn't copy
f to fd, and util.set_exec wouldn't find the file.
--- a/mercurial/merge.py Fri Jun 22 19:43:29 2007 -0300
+++ b/mercurial/merge.py Fri Jun 22 20:44:40 2007 -0300
@@ -401,12 +401,12 @@
updated += 1
else:
merged += 1
- if f != fd:
- repo.ui.debug(_("copying %s to %s\n") % (f, fd))
- repo.wwrite(fd, repo.wread(f), flags)
- if move:
- repo.ui.debug(_("removing %s\n") % f)
- os.unlink(repo.wjoin(f))
+ if f != fd:
+ repo.ui.debug(_("copying %s to %s\n") % (f, fd))
+ repo.wwrite(fd, repo.wread(f), flags)
+ if move:
+ 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]
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-merge9 Fri Jun 22 20:44:40 2007 -0300
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+# test that we don't interrupt the merge session if
+# a file-level merge failed
+
+hg init repo
+cd repo
+
+echo foo > foo
+echo a > bar
+hg ci -Am 'add foo' -d '0 0'
+
+hg mv foo baz
+echo b >> bar
+echo quux > quux1
+hg ci -Am 'mv foo baz' -d '0 0'
+
+hg up -qC 0
+echo >> foo
+echo c >> bar
+echo quux > quux2
+hg ci -Am 'change foo' -d '0 0'
+
+# test with the rename on the remote side
+HGMERGE=false hg merge
+
+# test with the rename on the local side
+hg up -C 1
+HGMERGE=false hg merge
+
+true
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-merge9.out Fri Jun 22 20:44:40 2007 -0300
@@ -0,0 +1,21 @@
+adding bar
+adding foo
+adding quux1
+adding quux2
+merging bar
+merging bar failed!
+merging foo and baz
+merging foo failed!
+1 files updated, 0 files merged, 0 files removed, 2 files unresolved
+There are unresolved merges, you can redo the full merge using:
+ hg update -C 2
+ hg merge 1
+3 files updated, 0 files merged, 1 files removed, 0 files unresolved
+merging bar
+merging bar failed!
+merging baz and foo
+merging baz failed!
+1 files updated, 0 files merged, 0 files removed, 2 files unresolved
+There are unresolved merges, you can redo the full merge using:
+ hg update -C 1
+ hg merge 2