Search

meld: graphical tool to diff and merge files

May 2nd, 2007 edited by Tincho

Entry submitted by Bart van Kuik. DPOTD needs your help, please contribute!

Every now and then we need to see the differences between two files. You forgot exactly what you changed in that Perl script, or you’d like to check what changes the intern made in Apache’s configuration, et cetera.

For seeing changes between two files, diff used to be your friend for the command line. Although hard core hackers may disagree, diff its output takes quite a bit of exercise to parse with the human eye. And although diff has a side-by-side mode, a text terminal only offers so much freedom.

A graphical display offers much more possibilities and Meld tries to use them in an admirable fashion. It’s a utility that lets you graphically see the differences between two or three files. And unlike diff, Meld lets you edit (or merge) the files straight away. With the click of a mouse you can copy or move differences between files.

meld httpd.conf httpd.conf.default

Diffing httpd.conf

Pressing and holding the Shift key will change the arrows to crosses, which lets you swiftly delete the additions that the intern made. (After sternly speaking to the lad!).

If you’re a programmer, you probably store your files in a version control repository like Subversion or CVS. Meld supports this, too. On the command line, type:

meld my/project/directory

Meld recognises a directory that’s under version control and will display any changed files. Double-clicking the file will show the differences between the current file that you’ve been working on, and the file in the repository. Meld is tab-based, so the changes will appear in a separate tab, making it easy to quickly return to the directory overview.

Meld in a subversion local copy

Although it’s not documented, meld seems to supports bzr, CVS, darcs, mercurial, monotone and subversion. Meld packs more features not discussed here, like a mode which displays the differences between directories, multiple languages et cetera. I encourage you to just install the package and look around.

Alternate tools

In the project’s homepage, one can find a little comparison with other similar tools:

Kdiff3
Very good for large merges. Automatic merge facility.
Xxdiff
Has some nice features such as CVS unmerge and good scriptability. Does 2 and 3 way file comparison but only 2 way directory comparison.
TkDiff
Two way file only diff viewer. Depends only on tk.
GtkDiff
Gtk1.x diff tool. Project seems dead.

Meld has been available in Debian since Sarge and in Ubuntu since Warty. It depends on the Python scripting language.

Posted in Debian, Ubuntu |

11 Responses

  1. Leandro Lucarella Says:

    Alternative tools: What about vimdiff??? :)

  2. Eugene Morozov Says:

    Alternative tool: ediff (Emacs diff tool).

  3. outreal Says:

    Hi,
    meld seems to be GTK-based. Those looking for a Qt-based software should try Kompare, which is an excellent piece of software (I never used meld, so I can’t compare)

  4. Roy Says:

    Yes, it uses GTK; but more than that, it needs Gnome!

  5. mysurface Says:

    I usually use vimdiff on svn, will probably try out meld on svn later, thanks.

  6. Poppy Says:

    Kompare (http://www.caffeinated.me.uk/kompare/) is the most well known KDE diff frontend

  7. Matthias Says:

    Great, I’ve been looking for an alternative to KDiff3 for some time, and meld looks promising ;O)

  8. Giles Says:

    On my system (sans GNOME and KDE) it required something like 75Mb of dependencies - and that’s the compressed size! Too bad - it looks good.

  9. akaihola Says:

    Actually the subversion front-end feature is very good. I’ve tried all free software svn front-ends for Linux, and meld is clearly the best one for me. Only the lack of keyboard shortcuts is a minus.

  10. Seb Says:

    Almost perfect under Ubuntu (7.10), it doesn’t come with gnome-vfs support yet.

  11. RzR Says:

    Meld is good, but I am looking a diff tool that works also when blocks are shuffled this mean a diff that support crossed correspondencies …
    Am I clear enough ?

    Ie :

    cat ordered.txt

    This
    is part 1

    and 2d part

    before
    the 3rd
    one

    cat shuffled.txt

    This
    is part 1

    before
    the 3rd
    one

    and 2d part

    same files different line/block order

    Well I bet this can be scripted

    Regard

    http://rzr.online.fr/q/diff