You have already gotten some input to your question on the Mercurial mailing list -- I went ahead and tried making the script suggested in the thread. It's been a long while since I've used Subversion, but I think this simple script does the trick:
#!/bin/sh
cp "$1" "$1.mine"
cp "$2" "$1.base"
cp "$3" "$1.other"
false
The final false
command makes the script return a non-zero exit code, signaling to Mercurial that the merge failed. For Windows it looks like this (thanks Pavel):
@copy %1 %1.mine
@copy %2 %1.base
@copy %3 %1.other
exit 1
I saved the Unix version in ~/tmp/m.sh
and tried it with no other merge settings configured than
[ui]
merge = ~/tmp/m.sh
I made a repository with two heads, each with a conflicting change to a JPEG file (mg.jpg
). I also added a non-conflicting change to a text file (a.txt
). Merging gave:
% hg --debug merge
searching for copies back to rev 1
resolving manifests
overwrite None partial False
ancestor 0848c2f8f8f8 local 845b8aa076bd+ remote f611c55aa8ec
mg.jpg: versions differ -> m
a.txt: versions differ -> m
preserving a.txt for resolve of a.txt
preserving mg.jpg for resolve of mg.jpg
picked tool '~/tmp/m.sh' for a.txt (binary False symlink False)
merging a.txt
my a.txt@845b8aa076bd+ other a.txt@f611c55aa8ec ancestor a.txt@0848c2f8f8f8
premerge successful
picked tool '~/tmp/m.sh' for mg.jpg (binary True symlink False)
merging mg.jpg
my mg.jpg@845b8aa076bd+ other mg.jpg@f611c55aa8ec ancestor mg.jpg@0848c2f8f8f8
merging mg.jpg failed!
0 files updated, 1 files merged, 0 files removed, 1 files unresolved
use 'hg resolve' to retry unresolved file merges or 'hg up --clean' to abandon
The nice thing is that the pre-merge could merge a.txt
by itself and so no a.txt.*
files were created:
% hg stat
M a.txt
M mg.jpg
? mg.jpg.base
? mg.jpg.mine
? mg.jpg.orig
? mg.jpg.other
You can probably fine-tune this script further to suit your needs -- if you do so, then consider adding the information to the Mercurial wiki or at least post your finding on the mailing list.