9

Git have merge-base command that show common ancestors of two or more branches.

What analog for Mercurial and bzr?

gavenkoa
  • 45,285
  • 19
  • 251
  • 303

3 Answers3

9

For Bazaar:

bzr find-merge-base /path/to/branch1 /path/to/branch2

(This command is hidden from the main set of commands that you can obtain with bzr help commands. Use bzr help hidden-commands to see other hidden commands).

bialix
  • 20,053
  • 8
  • 46
  • 63
  • It seems like this *should* work, however for me it always returns the current revid (when passing either revids or revnos). – Andy Hayden Jul 09 '14 at 04:09
8

Use revsets:

"ancestor(single, single)"
      Greatest common ancestor of the two changesets.

$ hg log -r 'ancestor(rev1, rev2)'
Idan K
  • 20,443
  • 10
  • 63
  • 83
6

For Mercurial:

hg debugancestor rev1 rev2

Peter Graham
  • 11,323
  • 7
  • 40
  • 42
  • Thanks for answer. This command hidden from **hg help** but can be viewed if type **hg debug**. Unhappily this command allow only TWO changesets, git-merge-base allow any number of changesets. – gavenkoa Jul 19 '11 at 07:19
  • 3
    @gavenkoa I believe Mercurial doesn't allow merging more than two branches in a single commit (a git octopus merge). Mercurial developers probably didn't see the need to have a command to find the common ancestor for a merge you aren't allowed to do. – Peter Graham Jul 19 '11 at 07:29
  • But this functioanality is useful. To find in which revision start bugfix/feature-development to avoid *cherry-picking* in case if you have 3 or more banches to propagate changes with **hg merge**. Look my question http://stackoverflow.com/questions/6709365/how-to-move-bugfixes-across-branches-in-dvcs – gavenkoa Jul 19 '11 at 08:04