Saturday, 18 July 2009

Meld, a visual diff tool

When dealing with large diffs (several hundred or tens thousands of changes) I normally turn to Meld, a visual diff tool. It allows on to diff two or three files and it can cope with a variety of diff formats, such as Mercurial, CVS, Subversion and Bazaar-ng, diff2 and diff3.

One neat feature is that Meld allows one to diff entire directories; changed files highlighted in red, new files in green and missing files are crossed out. The directory diff is selected by File->New... and then select the Directory Comparison tab in the "Choose Files" dialogue box. Below is a meld comparison between different versions of Mplayer:

Although there are quite a few diff tools out there, I prefer to use meld as it is fairly intuitive to use and just does what I need - no more and no less. The downside is that it's not the speediest tool when computing diffs of very large files, but this is an O(N^2) comparison operation, so that is no surprise really.

To install Meld on a Ubuntu system use:

sudo apt-get install meld

Occasionally I use it to compare kernel dmesg logs to see the differences between working kernels and ones with regressions or different behaviour. I normally turn on the required kernel debug options for the driver or subsystem I'm looking at and then boot two different kernel versions and compare the dmesg output. One trick is to strip off the leading time stamps and then sort the dmesg log before comparing - that way one can quickly see which messages are new or missing between kernels using:

dmesg | cut -c16- | sort > dmesg1.log

and repeat and compare logs with meld.

Below is an example of diff'ing two git commit logs from different kernel versions with meld:

Anyone else got any favourite diff'ing tools such as Kdiff3, Xxdiff, TkDiff, GtkDiff that they would like to recommend?

No comments:

Post a Comment