How can I configure Mercurial to use WinMerge for merges, under cygwin?
Asked Answered
O

2

9

When Mercurial is running under cygwin, it's a bit tricky to figure out how to spawn WinMerge to resolve merge conflicts. How can I do this?

Objectify answered 14/2, 2009 at 5:1 Comment(0)
O
15

The trick is that cygwin paths are not the same as Windows paths, so you need a little script that converts the cygwin paths to Windows paths before passing them as arguments to WinMerge.

Here's how to do it:

(1) Create a shell script in /usr/bin/winmerge as follows:

#!/bin/sh
"/cygdrive/c/Program Files/WinMerge/WinMergeU.EXE" /e /ub /dl other /dr local `cygpath -aw $1` `cygpath -aw $2` `cygpath -aw $3`

Note: cygpath converts path names. If WinMerge isn't in the default location, change the path here.

(2) Make that file executable

 chmod +x /usr/bin/winmerge

(3) Add the following to your ~/.hgrc file:

[ui]
merge = winmerge

[merge-tools]
winmergeu.executable=/usr/bin/winmerge
winmergeu.args=$other $local $output
winmergeu.fixeol=True
winmergeu.checkchanged=True
winmergeu.gui=False

Note! You probably already have a [ui] section with your name in it. Remember to merge my changes with yours, don't just add a new [ui] section. For example, my .hgrc looks like this:

[ui]
username = Joel Spolsky <[email protected]>
merge = winmergeu

[extensions]
fetch =

[merge-tools]
winmergeu.executable=/usr/bin/winmerge
winmergeu.args=$other $local $output
winmergeu.fixeol=True
winmergeu.checkchanged=True
winmergeu.gui=False
Objectify answered 14/2, 2009 at 5:6 Comment(1)
I'd probably not put that script in /usr/bin/. I was going to get after you for not using cygpath, but then I scrolled the code block and saw what you're doing.Neoplatonism
P
0

Here is the shell script line that works for Subversion/cygwin/WinMerge. The main difference is which arguments to use.

/cygdrive/c/Program\ Files/WinMerge/WinMergeU.exe /e /ub /dl "$3" /dr "$5" "`cygpath -aw $6`" "`cygpath -aw $7`" &

Note that this example also sets the description fields and launches the comparisons in the background, so that all diffs are launched at once. If you don't like that, remove the '&'.

If you don't know what your revision control program is passing you, try adding 'echo $@' to your shell script. It will print the arguments passed to the script.

Prostitute answered 24/12, 2009 at 21:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.