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
+++ b/mercurial/merge.py
@@ -401,12 +401,12 @@ def applyupdates(repo, action, wctx, mct
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]
new file mode 100755
--- /dev/null
+++ b/tests/test-merge9
@@ -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
new file mode 100644
--- /dev/null
+++ b/tests/test-merge9.out
@@ -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