Commit 9c9cfecd460 by Martin von Zweigbergk

rebase: don't use rebased node as dirstate p2 (BC)

When rebasing a node, we currently use the rebased node as p2 in the
dirstate until just before we commit it (we then change to the desired
parents). This p2 is visible to the user when the rebase gets
interrupted because of merge conflicts. That can be useful to the user
as a reminder of which commit is currently being rebased, but I
believe it's incorrect for a few reasons:

 * I think the dirstate parents should be the ones that will be set
   when the commit is created.

 * I think having two parents means that you're merging those two
   commits, but when rebasing, you're generally grafting, not merging.

 * When rebasing a merge commit, we should use the two desired parents
   as dirstate parents (and we clearly can't have the rebased node as
   a third dirstate parent).

 * `hg graft` (and `hg update --merge`) sets only one parent and `hg
   rebase` should be consistent with that.

I realize that this is a somewhat large user-visible change, but I
think it's worth it because it will simplify things quite a bit.

Differential Revision: https://phab.mercurial-scm.org/D7827
parent b42ce825308
......@@ -618,6 +618,7 @@ class rebaseruntime(object):
repo,
rev,
p1,
p2,
base,
self.collapsef,
dest,
......@@ -642,10 +643,6 @@ class rebaseruntime(object):
newnode = self._concludenode(rev, p1, p2, editor)
else:
# Skip commit if we are collapsing
if self.inmemory:
self.wctx.setbase(repo[p1])
else:
repo.setparents(repo[p1].node())
newnode = None
# Update the state
if newnode is not None:
......@@ -1468,7 +1465,7 @@ def commitnode(repo, p1, p2, editor, extra, user, date, commitmsg):
return newnode
def rebasenode(repo, rev, p1, base, collapse, dest, wctx):
def rebasenode(repo, rev, p1, p2, base, collapse, dest, wctx):
"""Rebase a single revision rev on top of p1 using base as merge ancestor"""
# Merge phase
# Update to destination and merge it with local
......@@ -1502,6 +1499,7 @@ def rebasenode(repo, rev, p1, base, collapse, dest, wctx):
labels=[b'dest', b'source'],
wc=wctx,
)
wctx.setparents(p1ctx.node(), repo[p2].node())
if collapse:
copies.graftcopies(wctx, ctx, repo[dest])
else:
......
......@@ -21,6 +21,11 @@
== Backwards Compatibility Changes ==
* When `hg rebase` pauses for merge conflict resolution, the working
copy will no longer have the rebased node as a second parent. You
can use the new `conflictparents()` revset for finding the other
parent during a conflict.
== Internal API Changes ==
......
......@@ -236,7 +236,7 @@ Rebase and abort without generating new changesets:
[1]
$ hg tglog
@ 4:draft 'C1'
% 4:draft 'C1'
|
o 3:draft 'B bis'
|
......
......@@ -712,7 +712,7 @@ Test aborted editor on final message
|
| @ 2: 82b8abf9c185 'D'
| |
@ | 1: f899f3910ce7 'B'
% | 1: f899f3910ce7 'B'
|/
o 0: 4a2df7238c3b 'A'
......@@ -736,7 +736,7 @@ Test aborted editor on final message
unresolved conflicts (see hg resolve, then hg rebase --continue)
[1]
$ hg tglog
@ 3: 63668d570d21 'C'
% 3: 63668d570d21 'C'
|
| @ 2: 82b8abf9c185 'D'
| |
......
......@@ -456,15 +456,14 @@ Test where the conflict happens when rebasing a merge commit
warning: conflicts while merging conflict! (edit, then use 'hg resolve --mark')
unresolved conflicts (see hg resolve, then hg rebase --continue)
[1]
The current parents are not 7 and 8 even though that's what we're merging
$ hg tglog
@ 8:draft 'E'
|
| o 7:draft 'D'
| @ 7:draft 'D'
|/
o 6:draft 'C'
|
| @ 5:draft 'F'
| % 5:draft 'F'
| |\
| | o 4:draft 'E'
| | |
......
......@@ -294,7 +294,7 @@ Test rebase interrupted by hooks
$ hg tglogp
@ 7: 401ccec5e39f secret 'C'
|
| @ 6: a0b2430ebfb8 secret 'F'
| o 6: a0b2430ebfb8 secret 'F'
| |
o | 5: 45396c49d53b public 'B'
| |
......@@ -345,7 +345,7 @@ Test rebase interrupted by hooks
$ hg tglogp
@ 7: 401ccec5e39f secret 'C'
|
| @ 6: a0b2430ebfb8 secret 'F'
| o 6: a0b2430ebfb8 secret 'F'
| |
o | 5: 45396c49d53b public 'B'
| |
......@@ -395,7 +395,7 @@ Test rebase interrupted by hooks
$ hg tglogp
@ 7: 401ccec5e39f secret 'C'
|
| @ 6: a0b2430ebfb8 secret 'F'
| o 6: a0b2430ebfb8 secret 'F'
| |
o | 5: 45396c49d53b public 'B'
| |
......
......@@ -1795,19 +1795,15 @@ rebasestate may contain hidden hashes. "rebase --abort" should work regardless.
$ hg log -G
@ 2:b18e25de2cf5 D
|
| @ 1:2ec65233581b B (pruned using prune)
|/
o 0:426bada5c675 A
$ hg summary
parent: 2:b18e25de2cf5 tip
D
parent: 1:2ec65233581b (obsolete)
B
branch: default
commit: 2 modified, 1 unknown, 1 unresolved (merge)
commit: 1 modified, 1 added, 1 unknown, 1 unresolved
update: (current)
phases: 3 draft
phases: 2 draft
rebase: 0 rebased, 2 remaining (rebase --continue)
$ hg rebase --abort
......
......@@ -481,11 +481,9 @@ Test --tool parameter:
$ hg summary
parent: 1:56daeba07f4b
c2
parent: 2:e4e3f3546619 tip
c2b
branch: default
commit: 1 modified, 1 unresolved (merge)
update: (current)
commit: 1 unresolved (clean)
update: 1 new changesets, 2 branch heads (merge)
phases: 3 draft
rebase: 0 rebased, 1 remaining (rebase --continue)
......
......@@ -114,7 +114,7 @@ continued
|
| @ 4: Z
| |
@ | 3: C
% | 3: C
| |
| o 2: Y
| |
......@@ -123,9 +123,9 @@ continued
o 0: A
$ hg st
M C
M conflict
A B
A C
? conflict.orig
$ echo resolved > conflict
$ hg resolve -m
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment