Find the latest merge point of two branches

后端 未结 7 2189
旧时难觅i
旧时难觅i 2021-02-01 05:16

Having two branches, how can I find the latest revision(s) where the two branches were merged? Is there a standard Mercurial command to do that?

This is the same as ques

7条回答
  •  情书的邮戳
    2021-02-01 05:52

    You can find all the merges from a source branch into a destination branch with this revset query:

    children(p2(::DESTINATION and merge()) and branch(SOURCE)) and branch(DESTINATION)
    
    • ::DESTINATION and merge() gets all merges in the destination branch.
    • p2(set) returns the second parent of each merge, which is always the changeset on the source branch which was merged into the destination branch
    • and branch(SOURCE) filters all those merges into just those that came from the source branch.
    • children(set) returns all the children of p2(), one of which is the merge we're looking for
    • and branch(DESTINATION) filters the children of p2() to just show changesets on the destination branch, which, it just so happens, are the merges we're looking for.

    So, to get the last merge from source into destination, wrap the above query with the max(set) query. So the final command would be:

    max(children(p2(::DESTINATION and merge()) and branch(SOURCE)) and branch(DESTINATION))
    

提交回复
热议问题