Mercurial Revision Sets

Mercurial supports a functional language for selecting a set of revisions. You can do things like:

Find the greatest common ancestor between two changesets:

hg log -r "ancestor(2987, 1734)"

Find all heads that contain a particular changeset:

hg log -r "head() and descendants(1734)"

… or that do not contain it:

hg log -r "head() and not descendants(1734)"

… but that includes closed branches; to exclude them:

hg log -r "head() and not descendants(1734) and not closed()"

If changeset 1734 is a bug fix, the last query shows those still-active branches that have yet to receive it.

You can also type one of these expressions into TortoiseHg’s “### revision set query###” search string.

There’s a lot more to it, both predicates and set-arithmetic operators. hg help revsets has the details; you can find it online at

There’s also a similar functional language for selecting files; see hg help filesets or

It's only fair to share...
Share on FacebookGoogle+Tweet about this on TwitterShare on LinkedIn

Leave a Reply