Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 751
Joel Spolsky Avatar asked Feb 14 '09 05:02

Joel Spolsky


1 Answers

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
like image 136
Joel Spolsky Avatar answered Oct 06 '22 21:10

Joel Spolsky