Making Mercurial log
make sense

If you’re into Mercurial bookmarks, hailed as the Mercurial equivalent to git branches, my excellent colleague Andrew Halberstadt has written an extension that returns commits associated with a particular bookmark called bookbinder.

In his own words, “[a] book binder is a person or machine [that] binds pages to books. In a similar vein, bookbinder binds commits to bookmarks”. It does this by implementing a feature revset allowing bookbinder to subvert all commands that have a REV argument and replace any detected bookmark names with the feature revset.

This normally works by passing the name of your bookmark to any command that supports bookmarks, e.g. hg log -r BOOKMARK, and it will then replace BOOKMARK with a revset containing all changesets “within” this bookmark.

Because the stock hg log doesn’t make much sense to me, especially without passing --graph to graphically display the repository’s DAG, I highly recommend having a look at it to give hg log back some sanity.

Since I never get around to clean up my bookmarks, it would be quite convenient to instruct bookbinder to show me the commits associated with the bookmark of my latest commit.

For this I’ve added an alias to my .hgrc that tells it to pick the bookmark from my last commit, or tip:

[alias]
blog = log --rev 'feature(tip)'

If I have three commits on my bookmark, this will return something akin to what you would expect from git log:

% hg blog
changeset:   267448:66fae38273f2
bookmark:    bug_1202663_super
tag:         tip
user:        Andreas Tolfsen
date:        Tue Oct 13 16:52:26 2015 +0100
summary:     Bug 1213797: Refactor screen capture and SVG document support

changeset:   267447:3cc8741649af
user:        Andreas Tolfsen
date:        Fri Oct 09 12:02:42 2015 +0100
summary:     Bug 1202663: Use dispatcher for screen capture command in listener

changeset:   267446:880e2bdb24ff
parent:      267426:607a236c2299
user:        Andreas Tolfsen
date:        Tue Oct 13 16:58:40 2015 +0100
summary:     Bug 1213800: More exhaustive Marionette screen capture tests