More Mercurial – Remote Repositories

I’ve spent some more time tinkering with Mercurial, and essentially wanted the master repository to behave a bit more like Subversion. I know this is a Bad Thing, but I want to be able to effectively commit, i.e. push, my changes back to the master repository without having to manually update it and commit it. The answer is rather simple but does seem to be that well publicised, probably because either everyone knows how to do this (e.g. hosted services), or no-one does this.

The solution is simply to add some hooks to your Mercurial set up as described here and here.

To summarise:

To act on changesets of a push/pull/unbundle, put this in .hg/hgrc:

[hooks]
changegroup = hg update >&2

This goes in .hg/hgrc on the remote repository. Output has to be redirected to stderr (or /dev/null), because stdout is used for the data stream.