Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find the latest merge point of two branches

Tags:

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 
like image 856
daniel kullmann Avatar asked Nov 09 '11 15:11

daniel kullmann


People also ask

How can I see last merge?

Try simply git whatchanged master.. staging to see what changed on staging since you last merged from staging to master.

What is a merge point git?

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.

Which command is used to merge two branches?

`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.

What does a newly created branch point to?

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.


1 Answers

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).

like image 96
Lazy Badger Avatar answered Oct 19 '22 07:10

Lazy Badger