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 question How to find the common ancestor of two branches in SVN?, but for Mercurial instead of subversion.
I didn't understand why Lazy Badger's answer was the right one, so I had to make a little drawing, and now I get it:
When two branches are merged, they are not really "merged", but the changes from one branch are integrated into a second branch. This means that the merge commit only belongs to the originating branch, and not to the merged branch. This is why the merge revision is one of the two children of the ancestor revision.
This is probably best seen with a picture:
default o----o----a---b---o---o \ \ other `-o---o---m---o ancestor(default,other) == a children(ancestor(default,other)) == (b,m) children(ancestor(default,other)) and merge() == m
Try simply git whatchanged master.. staging to see what changed on staging since you last merged from staging to master.
DESCRIPTION. git merge-base finds best common ancestor(s) between two commits to use in a three-way merge. One common ancestor is better than another common ancestor if the latter is an ancestor of the former. A common ancestor that does not have any better common ancestor is a best common ancestor, i.e. a merge base.
`git merge` command is used for this task. This command finds out the common base commit command by examining the two commit pointers of the merging branches and generates a new merge to combine the changes after running the command.
Each time a branch is created, a pointer to the original point is created too, the tail ref. This ref gets updated every time the branch is rebased.
hg log -r "children(ancestor(default, Cleanup)) and merge()" --template "{rev}\n"
is latest merge for default and Cleanup branches (polished version of Tim Henigan's answer).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With