Long Vu
Long Vu

Reputation: 281

Mercurial: how to list merged changeset where the 2nd parent is from a specific branch?

I would like to find all changesets that are a merge from branchX to default.

So first parent of such changeset is on default and second parent of such changeset is on branchX.

Using hg log -r 'branch("default") & merge() we have all the merged changeset on default, regardless whether the second parent is branchX or not.

How can I modify the above revset to filter out merged changesets where the 2nd parent is on branchX only?

Upvotes: 8

Views: 1727

Answers (1)

Steve Kaye
Steve Kaye

Reputation: 6262

This does it in my tests:

hg log -r "children(p2(branch(default)) & branch(branchX)) & merge()"

Explained:

p2(branch(default)) & branch(branchX) gets the changesets on branchX that are the second parent of a changeset on the default branch.

children() gets the children of those changesets

& merge() limits those children to those which are merge changesets. Without this condition you also get the child that is continuing branchX

Edit this does it better I think:

hg log -r "children(p2(branch(default)) & branch(branchX)) & branch(default)"

The first version would include changes on branchX that were merges from other branches just after a merge from branchX to default.

Upvotes: 8

Related Questions