Reputation: 1255
Is there some Mercurial revision set magic that can be used to find the last changeset on the default
branch that merged a specific branch (let's call it mybranch
)?
Or equally good find the last revision of mybranch
that was merged into default`?
In addition a way to list changesets grafted from mybranch
to default
would be nice.
Upvotes: 4
Views: 408
Reputation: 97270
hg help revsets
as source, starting from the last question
"destination([set])"
Changesets that were created by a graft, transplant or rebase operation, with the given
revisions specified as the source.
Omitting the optional set is the same as passing all().
For "... changesets grafted from mybranch to default" revset will be
destination(branch("mybranch")) & branch("default")
Even better: you can store it as revsetalias (TBT!)
[revsetalias]
grafted(from, to) = destination(branch(from)) & branch(to)
and use it for any pair of branches (expandning to custom amount of sources will be your future task).
Step-by-step
merge() & branch("to")
- all mergepoints in TO
p2(merge() & branch("to")) & branch("from")
- parents of the above merges only FROM
child(p2(merge() & branch("to")) & branch("from")) & branch("to")
- childs of the above parents only in TO (because they can have childs in other branches too)
last(child(p2(merge() & branch("to")) & branch("from")) & branch("to"))
- latest mergepoint if merges happened more than once.
Set of revsetaliases (for better readability) as result
[revsetalias]
ms(to) = merge() & branch(to)
ms2b(to,from) = (child(p2(ms(to))) & branch(from)) & branch(to)
fp_ms(to,from) = p2(ms(to)) & branch(from)
and your revset for:
last(ms2b("default","mybranch"))
last(fp_ms("default","mybranch"))
Addition & Demonstration
I fixed my ms2b(), as shown in THG's repobrowser screenshot below. Merges from stable to default "as is"
children(p2(merge() & branch(default)) & branch(stable)) & branch(default)
With parameters and previously prepared revsetaliases
ms2b(to,from) = children(p2(ms(to)) & branch(from)) & branch(to)
Upvotes: 4