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?
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 whenhg 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).Example usage (uses my own logging template):