Always Use Git Diffs

posted by Steve Losh on October 22, 2009

The default style of diffs that Mercurial outputs for commands like hg diff is a style that’s compatible with the UNIX patch program. I suppose that’s nice if you use patch a lot, but most of us don’t.

Git introduced a new format that has some features that make certain diffs more readable, and Mercurial can take advantage of that.

The page on the Mercurial wiki explains how to use it, but we’ll show you right now in case you don’t want to read that. Edit your ~/.hgrc file to contain:

git = True

That’s it! All of Mercurial’s commands that output diffs will now use this better format. Now when you rename a file with hg rename the diffs will say “file X renamed to Y” instead of treating it as a separate remove and add.

Do you really need diffs that are compatible with a program released in 1985?