Find the latest merge point of two branches

后端 未结 7 2016
旧时难觅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:47

    hg log -r "last(ancestors(target) & branch(source))"
    

    This gives you the least common ancestor of target and source branch ON source branch.

    source         o---a---o---m2---o
                        \      /
    intermediate   o--o--m1---b---o
                                   \
    target         o---o------------m3---o
    

    The least common ancestor of source and target branch in this example would be b, but b is not on the source branch, we therefore want to get a back.

    To get b back you can use the solution of Lasse:

    hg log -r "ancestor(source, target)"
    

    I often want to know the latest "default" revision in some task branch and I don't care if my task branch was directly merged with default or via some intermediate path.

提交回复
热议问题