Is there a Mercurial equivalent to git log --first-parent?
hg-log, mercurial
Solution
Direct equivalent: `hg log -r '_firstancestors(...)'`
There is a direct equivalent: the hidden revset `_firstancestors` follows the first-parent (p1) side of each merge. In Mercurial, like in Git, the first parent is the commit that was checked-out when `hg merge [second parent]` was called.
`hg log -r '_firstancestors(myfeature)'`
'hidden' means that it starts with an underscore, and is not listed in the help etc., but can still be used if you know it exists. I don't know why it is hidden.
Examples
This revset alias lists all commits on a feature branch while ignoring all the ancestry whenever `master` is merged into the branch to bring it up-to-date. (The shop I work prefers merging over rebasing).
[revsetalias]
feature($1) = _firstancestors($1) and not _firstancestors(master)
[alias]
f = log -r "feature($(echo $HG_ARGS| sed 's/^f //'))"
Example usage (uses my own logging template):
$ hg f myfeature
o 423 myfeature default/myfeature -- Esteis -- 2016-07-12 -- 123abc
| this
o 422 -- Esteis -- 2016-07-12 -- 123def
|\ merge master into myfeature
o ~ 421 -- Esteis -- 2016-07-12 -- 456abc
| that
o 420 -- Esteis -- 2016-07-12 -- 789def
| and the other
Problem
`git log --first-parent` omits all but the first parent of merge commits. Example: ``` $ git log --oneline --graph * 087f5ed Master C * 36c50a2 Merge branch 'feature' |\ | * 98c89df Feature B | * 89b3a7b Feature A * | 9a95133 Master B |/ * 766c9b0 Master A $ git log --oneline --graph --first-parent * 087f5ed Master C * 36c50a2 Merge branch 'feature' * 9a95133 Master B * 766c9b0 Master A ``` Is there a Mercurial equivalent?