How to Use WinMerge as the Diff tool for Mercurial

From the TortoiseHg FAQ:

Add these lines to your personal Mercurial.ini file

[extensions]
extdiff =

[extdiff]
cmd.winmerge = C:\Program Files\WinMerge\WinMergeU.exe
opts.winmerge = /e /x /u /wl

Now run the Global Settings tool. On the TortoiseHg tab, you should see winmerge available in the drop-down list for Visual Diff Command. Select winmerge, apply, then close.

This same approach can be used to add nearly any visual diff tool, but be aware that your diff tool must be able to support directory diffs if it is to be used by TortoiseHg, unless you are using release 0.8 or later.

Joel also provided a solution here in case you run Mercurial under Cygwin.

Explanation of WinMerge command line args here. Summary:

  • /e enables you to close WinMerge with a single Esc key press
  • /x closes WinMerge (after displaying an information dialog) when you start a comparison of identical files
  • /u prevents WinMerge from adding either path (left or right) to the Most Recently Used (MRU) list
  • /wl opens the left side as read-only

This is how it works for me -- pure mercurial command line other than tortoisehg

First, edit file (under a 64bit windows)

C:\Program Files (x86)\Mercurial\Mercurial.ini

[extensions]
; must uncomment this line
extdiff =

[extdiff]
; i'm using winmerge unicode version
cmd.winmerge = C:\Program Files (x86)\WinMerge\WinMergeU.exe
; it explains winmerge command line parameters here: http://winmerge.org/docs/manual/CommandLine.html
opts.winmerge = /r /e /x /u /wl

Then, you can use "hg winmerge ..." instead of "hg diff ..."


Well, the answers given earlier doesn't give me desired effects. They doesn't allow to make revisions diff and in place edit(I mean the same functionality which is available for TortoiseSVN from the box). To do that I've added additionally to mercurial.ini this section:

[merge-tools]
winmerge.regkey=Software\Thingamahoochie\WinMerge\
winmerge.regname=Executable
winmerge.priority=-10
winmerge.args=/e /x /wl /ub /dl other /dr local $other $local $output
winmerge.fixeol=True
winmerge.checkchanged=True
winmerge.gui=True
winmerge.diffargs=/r /e /x /ub /wl /dl '$plabel1' /dr '$clabel' $parent $child
winmerge.diff3args=
winmerge.dirdiff=True

This is taken from http://blog.stevehorn.cc/blog/easy-mercurial-visual-diff-between-two.html