diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -3426,6 +3426,28 @@ graftstate = statemod.cmdstate(repo, 'graftstate') return abortgraft(ui, repo, graftstate) +def continuegraft(ui, repo): + """logic to resume interrupted graft using 'hg continue'""" + with repo.wlock(): + graftstate = statemod.cmdstate(repo, 'graftstate') + opts = {} + statedata = {} + cont = True + basectx = None + revs = continuegraftstate(repo, graftstate, opts) + skipped = set() + if basectx is None: + # check for merges + for rev in repo.revs('%ld and merge()', revs): + ui.warn(_('skipping ungraftable merge revision %d\n') % rev) + skipped.add(rev) + revs = [r for r in revs if r not in skipped] + if not revs: + return -1 + finishgraft(repo, ui, basectx, revs, statedata, cont, opts) + graftstate.delete() + return 0 + def finishgraft(repo, ui, basectx, revs, statedata, cont, opts): """logic to execute graft once revs are generated""" graftstate = statemod.cmdstate(repo, 'graftstate') diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2628,6 +2628,7 @@ statemod.addunfinished( 'graft', fname='graftstate', clearable=True, stopflag=True, continueflag=True, abortfunc=cmdutil.hgabortgraft, + continuefunc=cmdutil.continuegraft, cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop") ) diff --git a/tests/test-graft.t b/tests/test-graft.t --- a/tests/test-graft.t +++ b/tests/test-graft.t @@ -1,4 +1,4 @@ -#testcases abortcommand abortflag +#testcases commandmode abortflag continueflag $ cat >> $HGRCPATH < [extdiff] @@ -13,6 +13,13 @@ > EOF #endif +#if continueflag + $ cat >> $HGRCPATH < [alias] + > continue = graft --continue + > EOF +#endif + Create a repo with some stuff in it: $ hg init a @@ -92,9 +99,11 @@ $ hg -q up -cr tip $ hg rm -q e - $ hg graft --continue - abort: no graft in progress - [255] + $ hg continue + abort: no graft in progress (continueflag !) + abort: no operation in progress (no-continueflag !) + [255] + $ hg revert -r . -q e Need to specify a rev: @@ -1697,7 +1706,13 @@ $ hg resolve -m (no more unresolved files) continue: hg graft --continue - $ hg graft --continue + +#if commandmode + $ hg continue --dry-run + graft in progress, will be resumed +#endif + + $ hg continue grafting 1:80e6d2c47cfe "added b" grafting 2:8be98ac1a569 "added c" @@ -1754,7 +1769,7 @@ (no more unresolved files) continue: hg graft --continue - $ hg graft --continue + $ hg continue grafting 1:80e6d2c47cfe "added b" grafting 2:8be98ac1a569 "added c" @@ -1803,7 +1818,7 @@ $ hg resolve -m (no more unresolved files) continue: hg graft --continue - $ hg graft --continue + $ hg continue grafting 1:80e6d2c47cfe "added b" grafting 2:8be98ac1a569 "added c" @@ -1843,7 +1858,7 @@ (no more unresolved files) continue: hg graft --continue - $ hg graft --continue + $ hg continue grafting 1:80e6d2c47cfe "added b" grafting 2:8be98ac1a569 "added c" @@ -1997,7 +2012,7 @@ $ hg abort abort: no interrupted graft to abort (abortflag !) - abort: no operation in progress (abortcommand !) + abort: no operation in progress (no-abortflag !) [255] when stripping is required @@ -2026,7 +2041,7 @@ abort: cannot specify any other flag with '--abort' [255] -#if abortcommand +#if commandmode when in dry-run mode $ hg abort --dry-run graft in progress, will be aborted @@ -2273,7 +2288,7 @@ (no more unresolved files) continue: hg graft --continue - $ hg graft --continue + $ hg continue grafting 3:09e253b87e17 "A in file a" $ hg log -GT "{rev}:{node|short} {desc}\n" @ 4:2aa9ad1006ff B in file a @@ -2350,7 +2365,7 @@ $ hg resolve --mark (no more unresolved files) continue: hg graft --continue - $ hg graft --continue + $ hg continue grafting 3:09e253b87e17 "A in file a" $ hg diff diff -r 2aa9ad1006ff a diff --git a/tests/test-issue1175.t b/tests/test-issue1175.t --- a/tests/test-issue1175.t +++ b/tests/test-issue1175.t @@ -1,3 +1,11 @@ +#testcases continueflag continuecommand +#if continueflag + $ cat >> $HGRCPATH < [alias] + > continue = graft --continue + > EOF +#endif + https://bz.mercurial-scm.org/1175 $ hg init @@ -80,7 +88,7 @@ $ hg resolve --mark b (no more unresolved files) continue: hg graft --continue - $ hg graft --continue + $ hg continue grafting 1:5974126fad84 "b1" warning: can't find ancestor for 'b' copied from 'a'! $ hg log -f b -T 'changeset: {rev}:{node|short}\nsummary: {desc}\n\n'