Monthly Archives: July 2011

Mercurial user interface tweaks

Although I vastly prefer Mercurial to Git overall, there are a few things in Git’s user interface that I like, in particular automatic paging of output and showing a change summary after pulling. Looking around Mercurial’s wiki gives some idea how to do these with Mercurial, but they don’t behave exactly like Git does and can be quite annoying. I’ve just spent some time tweaking things a little bit to behave more like Git does, so here’s the relavent parts of my ~/.hgrc file for anyone interested.

color =
pager =
progress =

# This enables a diffstat after pulling. The instructions given on the Mercurial
# wiki also cause a diffstat to be given when you first clone a repository from
# the first revision to the latest revision, which isn't particularly of any
# use. The conditional around this checks whether the old revision is the first
# revision in the repo, and if so doesn't perform the diffstat.
changegroup =
	if [ "$(hg id -n -r $HG_NODE)" -ne 0 ]; then
		hg diffstat -r $(hg parent -r $HG_NODE --template '{node}'):tip;

# The colour extension enables colouring of diff and status output.
status.added = green
status.removed = red
status.modified = none
status.deleted = none
status.unknown = none
status.ignored = none

# This enables paging of various commands. By default, it applies to the
# annotate, cat, diff, export, glog, log and qdiff commands, but this can
# be customised.
pager = LESS=FRSX less

# Use git's extended diff format (see 'hg help diffs' - adds extra information
# such as renames and mode changes to diffs).
git = True

# Makes an alias used by the changegroup hook above. The reason for doing this
# is so that the pager extension won't page the diffstat output, which I find
# annoying. You may want it to do this, in which case you can remove this alias
# and substitute diffstat with what's below in the changegroup hook.
diffstat = diff --stat

Update (26/07/11): Fixed diffstat of pulled changes.