Using Meld with Mercurial

A quick tooltip.

Meld is a nice diff and file comparison tool. It can be used instead of WinMerge or the built in Mercurial diff tool – KDiff3. Where it improves upon WinMerge and KDiff3 is the visualization of differences between files and versions. The differences expand or balloon out from comparison to comparison. This makes it easier to understand where code has been added and removed. It also supports 3 way merging.

Meld Screnshot

It is primarily a Linux tool but as its written in Python it will run under Windows with the right supporting tools. The notes for installing under Windows are here: https://live.gnome.org/Meld/Windows

Once you have installed: Python, PyGTK All-in-one installer and Meld you can get it to work under Mercurial by:

1. Create a batch file called meld.bat. In the batch file use the following command (change the path to the path of your Meld installation):

C:\Python27\python.exe "C:\Program Files (x86)\meld-1.5.4\bin\meld" %*

Put the meld.bat file somewhere in your PATH environment variable.

2. Edit your mercurial.ini file (found in your C:\Users\<username> directory) and add the following:

[ui]
merge = meld

[extensions]
cmd.extdiff=

[extdiff]
cmd.vdiff = meld
[merge-tools]
meld.args = $local $base $other $output

Fairly, simple. Type “hg vdiff” in a repository to see the diffs in Meld. As Meld notes – version control support under Windows is hit and miss. This “works on my machine” for Mercurial in Windows.

Tagged with: , ,
Posted in Programming, Tools
6 comments on “Using Meld with Mercurial
  1. yossi says:

    you may want to fix up the layout of this page. the way it is now the %* on the end of the batch line spills over into the sidebar and is quite hard to see.

    so much so that i missed it and had to figure out that part myself. i came back here to tell you to add it but this time i looked closer and saw that the %* was indeed there.

  2. Fixed it now so that the complete line is more visible. (No whitespace at start of line.)

    Thank you for bringing it to my attention.

  3. RCC says:

    Thanks! On Ubuntu Linux, I had to change the line below [extensions] to say:
    hgext.extdiff =

    • Glad to hear that this is useful for Linux. I have not tried Mercurial on Linux so I’m not sure how different the config is. Thank you for pointing out the config required.

  4. John Calcote says:

    Hi – this blog post should be updated to reflect the latest mercurial interface for configuring external commands – all you need to change is the [extensions] command – is should say simple “extdiff =” rather than “cmd.extdiff =”

  5. cayohimuga says:

    -o flag missed in [merge-tools] example

    meld.args = $base $local $other -o $output

Leave a comment