Implementing 'git show' in Mercurial

by Scott Hebert

Mercurial logo -rightOne of my frequently used git commands is 'git show <rev>'. As in, "show me what the heck this guy did here." Unfortunately, Mercurial doesn't have the same command, but it's easy enough to implement it using an alias in your .hgrc.

The command you would run from the command line to get the output is: hg log --patch --rev <rev>. All, you need to do is drop this into the [alias] stanza of your .hgrc and you'll have the hg show command.

Below I have cleverly used my new 'hg show' command to show you the changes I made to my .hgrc in order to get the new alias working.

UPDATE: A buddy of mine pointed out another way to implement this alias is to replace log --patch --rev with diff -c in the snippet above. In my testing, both options seem to work perfectly well. The alias that uses log gives you the changeset metadata in addition to the diff, so that might be only thing that plays into your adoption of one over the other.

I use Git in my daily work, but prefer Mercurial for personal projects.