Wednesday, February 3, 2016

HG: What Changesets Are Not In This Tag?

I still love Mercurial.  You git people can pry it from my cold dead hands!

Mercurial has a search feature called revsets (hg help revsets) which is a simple and powerful query language for searching the changeset history graph.  I probably don't use it as often as I should, instead wasting time scrolling through the thg graph hunting for things or following branch lines.  But I did use it today and thought I'd share.

We have a release branch and we tag changesets with version numbers when we release.  We're in a rather unusual period of chaos at the moment which had led to changesets on the release branch that had not been included in the last tagged release because the release was done from an anonymous head.  As a result, it was hard to know exactly what changesets were not included in that tag.  Enter revsets:

hg sl -r "sort(branch(release) and not ancestors(tag-name) and not merge(), -rev)"

This gets all changesets on the release branch which are not an ancestor of the given tag (AKA were not included in the release represented by that tag) and are not a merge changeset sorted by revision number descending.