How to merge after reverting in mercurial?
I have had a bad merge. Now I want to start the merge all over again. I did a revert just before the merge. Now when I'm trying to add the bundle, I'm having the message and it can no more locate the changes. Wha开发者_JAVA百科t is wrong? Why isn't it finding any change?
c:\Documents and Settings\Desktop\New Folder\test_rev94_to_tip_hg\test_rev94_to_tip.hg
searching for changes
no changes found
[command completed successfully Tue Apr 13 16:10:37 2010]
Changesets:
105: default tip merge 104: backed out chageset 26e351596da9 103: revert error 102: revert 101: remove tabledata 100 Merge ........... Code from merging 99: assignment , changeset 26e351596da9 98: refactored code 97: 96: 95: ............... 94: version 1
I wanted to revert back to 94 and then do the merging again.
You can re-merge when you go back to an unmerged revision, and specify the other revision to merge there. Say the repo after the merge has the following layout:
o changeset: 4:a72f471ed717 |\ parent: 3:abd9c586bce0 | | parent: 2:6827b9817642 | | user: Rudi | | date: Wed Apr 14 12:09:39 2010 +0200 | | summary: Merged | | | o changeset: 3:abd9c586bce0 | | parent: 1:11e62ba50646 | | user: Rudi | | date: Wed Apr 14 12:09:29 2010 +0200 | | summary: branched | | o | changeset: 2:6827b9817642 |/ user: Rudi | date: Fri Feb 12 15:30:34 2010 +0100 | summary: Something other changed | o changeset: 1:11e62ba50646 | user: Rudi | date: Fri Feb 12 14:28:48 2010 +0100 | summary: Something changed | o changeset: 0:b42b1175ba6b user: Rudi date: Fri Feb 12 14:16:13 2010 +0100 summary: Initial
Here you go to rev with hg up -r 3
to the change set before the merge. There you issue hg merge -r 2
to redo the merge. After the commit the repo looks like this:
@ changeset: 5:65d010bb347a |\ tag: tip | | parent: 3:abd9c586bce0 | | parent: 2:6827b9817642 | | user: Rudi | | date: Wed Apr 14 12:54:42 2010 +0200 | | summary: merge redone | | +---o changeset: 4:a72f471ed717 | |/ parent: 3:abd9c586bce0 | | parent: 2:6827b9817642 | | user: Rudi | | date: Wed Apr 14 12:09:39 2010 +0200 | | summary: Merged | | | o changeset: 3:abd9c586bce0 | | parent: 1:11e62ba50646 | | user: Rudi | | date: Wed Apr 14 12:09:29 2010 +0200 | | summary: branched | | o | changeset: 2:6827b9817642 |/ user: Rudi | date: Fri Feb 12 15:30:34 2010 +0100 | summary: Something other changed | o changeset: 1:11e62ba50646 | user: Rudi | date: Fri Feb 12 14:28:48 2010 +0100 | summary: Something changed | o changeset: 0:b42b1175ba6b user: Rudi date: Fri Feb 12 14:16:13 2010 +0100 summary: Initial
Then you need to merge r4 and r5 to get the final head of this operation.
hg strip
your faulty merge and hg update -C
(-C for clean) to any of your previous heads. You can then do the merge again.
It's not clear to me what changesets should be in your bundle or not, it seems you either already have them in your repo or don't have a common ancestor rev with what's in the bundle?
If you do not specify a specific revision hg revert
will update a single file to its tip
version (the last rev touching that file).
Note that revert
is not the same as update
. If you want to retry a merge, don't try to revert
to the previous (pre-merge) head, update
to it. Then you can try the merge again.
For instance, assuming that A
is your common ancestor, B
is your branch, C
is a branch you've pulled in and want to merge and D
is the failed merge.
A -- B ------- D
\ /
------ C -
You were at B
, pulled in C
, merged C
into B
and committed as D
.
If you want to try the merge again, update to B
, merge again and commit as E
, leaving you with:
A -- B ------- D
\ X
------ C ----- E
Once you are happy that E
works, it's up to you whether you strip
out D
or leave it there for posterity.
精彩评论