Friday, June 4, 2010

How to Use WinMerge as the Diff tool for Mercurial

Here is how you can setup TortoiseHg to use WinMerge for visual diffs and 3-way merges (instead of using KDiff):
  1. Open Mercurial.ini config file. On my WIN7 system, this file exists at C:\Users\MyUser\Mercurial.ini. If you are on an XP system, it's probably in C:\Documents and Settings\<your user name>\Mercurial.ini.
  2. Add the following lines:
    [extdiff]
    cmd.winmerge = C:\Program Files (x86)\WinMerge\WinMergeU.exe
    opts.winmerge = /e /x /ub /wl

    [merge-tools]
    winmergeu.executable = C:\Program Files (x86)\WinMerge\WinMergeU.exe
    winmergeu.priority= 1
    winmergeu.fixeol=True
    winmergeu.checkchanged=True
    winmergeu.args= /e /ub /dl other /dr local $other $local $output
    winmergeu.gui=False
    winmergeu.binary=True

    [tortoisehg]
    vdiff = winmerge
  3. Now run TortoiseHg's Global Settings tool. On the TortoiseHg tab, select winmerge for the Visual Diff Command, and winmergeu for the Three-way Merge Tool options, apply, close.
Sources:
http://superuser.com/questions/23576/how-to-use-winmerge-as-the-diff-tool-for-mercurial
http://stackoverflow.com/questions/2073543/use-winmerge-as-tortoisehg-merge-tool