_firstancestors() is a built-in revset of all ancestors down the p1 line
Sietse Brouwer
sbbrouwer at gmail.com
Fri Jun 3 17:09:53 UTC 2016
Dear list,
> I often think of a bookmark
> branch's 'mainline' as "all ancestors of this commit, but not
> ancestors that were brought in by merging". In other words,
> p1(master), p1(p1(master)), and so on back to the root.
> [...]
> Before I set about building this revset myself, does anyone know of an
> extension that provides it?
Found it! It's not part of Mercurials public API, but Mercurial
nonetheless has a `_firstancestors(...)` revset. Been there since
2.2, as far as I can tell. I understand this non-public interface
comes with no guarantees, but it does exactly what I want, and I shall
happily use it for as long as it is there.
Now I see all of a bookmark branch's main commits with a single command:
# hgrc:
#
# [revsetalias]
# feature($1) = _firstancestors($1) and not _firstancestors(master)
# feat($1) = feature($1)
hg log -r 'feat(myfeature)' --template ...
@ [myfeature] -- Jane Doe -- 2016-06-03 -- 7:8ae88c93cac9
| 7
o -- Jane Doe -- 2016-06-03 -- 6:0a4779dc0a0c
|\ merge master into feature
| ~
o -- Jane Doe -- 2016-06-03 -- 2:3f25c515e2e8
| 2
o -- Jane Doe -- 2016-06-03 -- 1:a03a37efa18b
| 1
~
In case Gmail mangles the formatting, here's the above example in a gist:
https://gist.github.com/sietse/ba4bdd81ac65a47af9b3634e85ec80e6
This is going to make my interaction (via hg-git) with remote git
repositories absolutely delightful. :-D
Thanks to everybody who took the time to read my question; I'm sorry I
didn't find the answer before posting. On the other hand, perhaps this
thread will help some other people, too.
Kind regards,
Sietse
More information about the Mercurial
mailing list