8

What is the mercurial equivalent to gits no-fast-forward merge (in case a fast forward would be possible)?

Edit

Assume you have a branch/bookmark at your head/tip of master/default:

 o feature
 |
 o
 |
 o master/default
 |
 ...

A simple fast forward merge would result in:

 o feature/master/default
 |
 o
 |
 o
 |
 ...

A no-fast-forward merge would look like:

 o merge commit - feature/master/default
 | \
 |  o     
 |  |
 |  o
 | /
 o
 |
 ...
mheinzerling
  • 1,035
  • 1
  • 10
  • 31

1 Answers1

8

It depends on how you committed your feature branch.

If the feature was developed on a named branch, then you can get the equivalent of a no fast-forward merge. In fact, named branches cannot be merged any other way.

hg update default
hg branch feature-1
...work...
hg commit -m "implemented feature on named branch"
hg update default
hg merge feature-1
hg commit -m "merged feature-1 to default"

This will result in a graph like this:

o   merged feature-1 to default
|\
| o feature-1: implemented feature on named branch
|/
o
|

This only works with named branches (i.e. branches created using the hg branch command). It does not work for anonymous branches or bookmarks.

You may also be interested in this thread (dead-link) on the Mercurial mail list that discusses the issue.

Shannon Matthews
  • 9,649
  • 7
  • 44
  • 75
Tim Henigan
  • 60,452
  • 11
  • 85
  • 78
  • 1
    That would be an idea for people who really like the 'punctuation' of a merge changeset for merging a feature. You have a named branch called 'newfeature' and then several bookmarks within that branch. – Omnifarious Mar 16 '13 at 03:10
  • By far the best part of this answer is the last line. – Ringding Mar 18 '13 at 12:29
  • You can do an Oedipus merge in Mercurial with anonymous heads using the 'debugsetparents' command. See: http://hgtip.com/tips/advanced/2010-04-23-debug-command-tricks/#3-simulate-gits-no-ff-merges-with-anonymous-heads. I think debug commands are not given the compatibility guarantees of the rest of Mercurial, though. – jwd Apr 09 '15 at 17:28