Commit fee6afd7 authored by Charles Chamberlain's avatar Charles Chamberlain
Browse files

graft-state: save --base in graft's state, fixing bug with graft --continue

Without this change, running graft --continue after grafting a merge commit using --base
(and encountering conflicts) will output "skipping ungraftable merge revision" even though
we specified a base in the initial graft command.

Graft's improve behaviour is reflected in test-graft.t.

Differential Revision: https://phab.mercurial-scm.org/D8578

--HG--
branch : stable
parent 91e509a12dbc
......@@ -2969,9 +2969,6 @@ def _dograft(ui, repo, *revs, **opts):
revs = list(revs)
revs.extend(opts.get(b'rev'))
basectx = None
if opts.get(b'base'):
basectx = scmutil.revsingle(repo, opts[b'base'], None)
# a dict of data to be stored in state file
statedata = {}
# list of new nodes created by ongoing graft
......@@ -3061,6 +3058,8 @@ def _dograft(ui, repo, *revs, **opts):
opts[b'log'] = True
if statedata.get(b'no_commit'):
opts[b'no_commit'] = statedata.get(b'no_commit')
if statedata.get(b'base'):
opts[b'base'] = statedata.get(b'base')
nodes = statedata[b'nodes']
revs = [repo[node].rev() for node in nodes]
else:
......@@ -3073,6 +3072,9 @@ def _dograft(ui, repo, *revs, **opts):
revs = scmutil.revrange(repo, revs)
skipped = set()
basectx = None
if opts.get(b'base'):
basectx = scmutil.revsingle(repo, opts[b'base'], None)
if basectx is None:
# check for merges
for rev in repo.revs(b'%ld and merge()', revs):
......@@ -3165,6 +3167,8 @@ def _dograft(ui, repo, *revs, **opts):
if opts.get(b'no_commit'):
statedata[b'no_commit'] = True
if opts.get(b'base'):
statedata[b'base'] = True
for pos, ctx in enumerate(repo.set(b"%ld", revs)):
desc = b'%d:%s "%s"' % (
ctx.rev(),
......
......@@ -853,6 +853,26 @@ graft --continue after --force
$ cat a
abc
graft --continue after --base with conflits
$ echo base > d
$ hg ci -m _
$ hg graft -r 6
skipping ungraftable merge revision 6
[255]
$ hg graft -r 6 --base 5
grafting 6:25a2b029d3ae "6"
merging d
merging e
warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
abort: unresolved conflicts, can't continue
(use 'hg resolve' and 'hg graft --continue')
[1]
$ echo a > d && hg resolve -qm
continue: hg graft --continue
$ hg graft --continue
grafting 6:25a2b029d3ae "6"
Continue testing same origin policy, using revision numbers from test above
but do some destructive editing of the repo:
......
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