Add support for mercurial changes.

Probably could do with a refactor to move the shared code into a module though.