Reputation: 11
In the picture below I found Mozilla's mercurial repository graph with a situation that I thought was not possible. They have two commits that have the same parent where one is a merge. I have wanted to do this, but cannot find an answer.
@ merge pull request from foo polish text
|\
| o bug 1 - add text ...
|/
o merge pull request from bar bug 2
How did they get this to occur? Usually when you pull changes in that add onto the head, if you attempt to merge you get "nothing to merge".
Upvotes: 1
Views: 361
Reputation: 7074
One method for achieving this is to use Mercurials built-in "debug" commands. They're effectively commands you should never need to use unless you're, you know, debugging Mercurial. Using them could in theory destroy your repository, so work on a clone if you really need to.
$ hg help --debug
...
debugsetparents
manually set the parents of the current working directory
What this command does is allow us to, as you can see, manually set the parents of the working directory - using this we can fake a merge.
So, with this knowledge, and with a degree of caution, we can do:
$ hg log --graph
@ 1[tip] Change by A.N.Other
|
o 0 Local Change
$ hg debugsetparents 0 1
$ hg log --graph
@ 1[tip] Change by A.N.Other
|
@ 0 Local Change
$ hg commit -m "Merged"
$ hg log --graph
@ 2[tip] Merged
|\
| o 1 Change by A.N.Other
|/
o 0 Local Change
It's not something that I would normally advise, but it would allow you to illustrate that you're pulling in some changes from "another branch", when that branch is actually at the tip of your changes, which I guess is the aim.
Also, note shambulator's comment below - for this to include the changes in 1
, you need to have that as your working directory when performing the debugsetparents
, otherwise you'll lose those changes. Unless of course your plan is to discard those changes, in which case you should update
to changeset 0
, and then fake the merge.
Upvotes: 4