D6645: continue: added logic for hg continue
pulkit added inline comments. INLINE COMMENTS > commands.py:1906 > +use --dry-run/-n to dry run the command. > +A new operation can be added to this by registering the operation and > +continue logic in the unfinishedstates list under statemod. This line should not be a part of user help. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6645/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6645 To: taapas1128, #hg-reviewers Cc: pulkit, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D6645: continue: added logic for hg continue
Closed by commit rHGb53633d3f809: continue: added logic for hg continue (authored by taapas1128). This revision was automatically updated to reflect the committed changes. This revision was not accepted when it landed; it landed in state "Needs Review". REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D6645?vs=15915=15941 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6645/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6645 AFFECTED FILES mercurial/commands.py mercurial/state.py tests/test-completion.t tests/test-help.t tests/test-hgweb-json.t CHANGE DETAILS diff --git a/tests/test-hgweb-json.t b/tests/test-hgweb-json.t --- a/tests/test-hgweb-json.t +++ b/tests/test-hgweb-json.t @@ -1895,6 +1895,10 @@ "topic": "commit" }, { +"summary": "resumes an interrupted operation (EXPERIMENTAL)", +"topic": "continue" + }, + { "summary": "diff repository (or selected files)", "topic": "diff" }, diff --git a/tests/test-help.t b/tests/test-help.t --- a/tests/test-help.t +++ b/tests/test-help.t @@ -408,6 +408,7 @@ show changeset information by line for each file clone make a copy of an existing repository commit, cicommit the specified files or all outstanding changes + continue resumes an interrupted operation (EXPERIMENTAL) diff diff repository (or selected files) exportdump the header and diffs for one or more changesets forgetforget the specified files on the next commit @@ -2389,6 +2390,13 @@ commit the specified files or all outstanding changes + + continue + + + resumes an interrupted operation (EXPERIMENTAL) + + diff diff --git a/tests/test-completion.t b/tests/test-completion.t --- a/tests/test-completion.t +++ b/tests/test-completion.t @@ -15,6 +15,7 @@ clone commit config + continue copy diff export @@ -252,6 +253,7 @@ clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, remotecmd, insecure commit: addremove, close-branch, amend, secret, edit, force-close-branch, interactive, include, exclude, message, logfile, date, user, subrepos config: untrusted, edit, local, global, template + continue: dry-run copy: after, force, include, exclude, dry-run debugancestor: debugapplystreamclonebundle: diff --git a/mercurial/state.py b/mercurial/state.py --- a/mercurial/state.py +++ b/mercurial/state.py @@ -99,7 +99,7 @@ def __init__(self, opname, fname, clearable, allowcommit, reportonly, continueflag, stopflag, cmdmsg, cmdhint, statushint, - abortfunc): + abortfunc, continuefunc): self._opname = opname self._fname = fname self._clearable = clearable @@ -111,6 +111,7 @@ self._cmdhint = cmdhint self._statushint = statushint self.abortfunc = abortfunc +self.continuefunc = continuefunc def statusmsg(self): """returns the hint message corresponding to the command for @@ -159,7 +160,8 @@ def addunfinished(opname, fname, clearable=False, allowcommit=False, reportonly=False, continueflag=False, stopflag=False, - cmdmsg="", cmdhint="", statushint="", abortfunc=None): + cmdmsg="", cmdhint="", statushint="", abortfunc=None, + continuefunc=None): """this registers a new command or operation to unfinishedstates opname is the name the command or operation fname is the file name in which data should be stored in .hg directory. @@ -184,10 +186,12 @@ message of the format ('To continue:hg cmdname --continue' 'To abort: hg cmdname --abort') is not desired abortfunc stores the function required to abort an unfinished state. +continuefunc stores the function required to finish an interrupted +operation. """ statecheckobj = _statecheck(opname, fname, clearable, allowcommit, reportonly, continueflag, stopflag, cmdmsg, -cmdhint, statushint, abortfunc) +cmdhint, statushint, abortfunc, continuefunc) if opname == 'merge': _unfinishedstates.append(statecheckobj) else: diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1893,6 +1893,32 @@ return 0 return 1 +@command('continue', +dryrunopts, helpcategory=command.CATEGORY_CHANGE_MANAGEMENT, +helpbasic=True) +def continuecmd(ui, repo, **opts): +"""resumes an interrupted operation (EXPERIMENTAL) + +Finishes a multistep operation like graft, histedit, rebase, merge, +and unshelve if they are in an interrupted state. + +use --dry-run/-n to dry run the command. +A new operation can be added to this
D6645: continue: added logic for hg continue
taapas1128 updated this revision to Diff 15915. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D6645?vs=15913=15915 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6645/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6645 AFFECTED FILES mercurial/commands.py mercurial/state.py tests/test-completion.t tests/test-help.t tests/test-hgweb-json.t CHANGE DETAILS diff --git a/tests/test-hgweb-json.t b/tests/test-hgweb-json.t --- a/tests/test-hgweb-json.t +++ b/tests/test-hgweb-json.t @@ -1895,6 +1895,10 @@ "topic": "commit" }, { +"summary": "resumes an interrupted operation (EXPERIMENTAL)", +"topic": "continue" + }, + { "summary": "diff repository (or selected files)", "topic": "diff" }, diff --git a/tests/test-help.t b/tests/test-help.t --- a/tests/test-help.t +++ b/tests/test-help.t @@ -408,6 +408,7 @@ show changeset information by line for each file clone make a copy of an existing repository commit, cicommit the specified files or all outstanding changes + continue resumes an interrupted operation (EXPERIMENTAL) diff diff repository (or selected files) exportdump the header and diffs for one or more changesets forgetforget the specified files on the next commit @@ -2389,6 +2390,13 @@ commit the specified files or all outstanding changes + + continue + + + resumes an interrupted operation (EXPERIMENTAL) + + diff diff --git a/tests/test-completion.t b/tests/test-completion.t --- a/tests/test-completion.t +++ b/tests/test-completion.t @@ -15,6 +15,7 @@ clone commit config + continue copy diff export @@ -252,6 +253,7 @@ clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, remotecmd, insecure commit: addremove, close-branch, amend, secret, edit, force-close-branch, interactive, include, exclude, message, logfile, date, user, subrepos config: untrusted, edit, local, global, template + continue: dry-run copy: after, force, include, exclude, dry-run debugancestor: debugapplystreamclonebundle: diff --git a/mercurial/state.py b/mercurial/state.py --- a/mercurial/state.py +++ b/mercurial/state.py @@ -99,7 +99,7 @@ def __init__(self, opname, fname, clearable, allowcommit, reportonly, continueflag, stopflag, cmdmsg, cmdhint, statushint, - abortfunc): + abortfunc, continuefunc): self._opname = opname self._fname = fname self._clearable = clearable @@ -111,6 +111,7 @@ self._cmdhint = cmdhint self._statushint = statushint self.abortfunc = abortfunc +self.continuefunc = continuefunc def statusmsg(self): """returns the hint message corresponding to the command for @@ -159,7 +160,8 @@ def addunfinished(opname, fname, clearable=False, allowcommit=False, reportonly=False, continueflag=False, stopflag=False, - cmdmsg="", cmdhint="", statushint="", abortfunc=None): + cmdmsg="", cmdhint="", statushint="", abortfunc=None, + continuefunc=None): """this registers a new command or operation to unfinishedstates opname is the name the command or operation fname is the file name in which data should be stored in .hg directory. @@ -184,10 +186,12 @@ message of the format ('To continue:hg cmdname --continue' 'To abort: hg cmdname --abort') is not desired abortfunc stores the function required to abort an unfinished state. +continuefunc stores the function required to finish an interrupted +operation. """ statecheckobj = _statecheck(opname, fname, clearable, allowcommit, reportonly, continueflag, stopflag, cmdmsg, -cmdhint, statushint, abortfunc) +cmdhint, statushint, abortfunc, continuefunc) if opname == 'merge': _unfinishedstates.append(statecheckobj) else: diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1893,6 +1893,32 @@ return 0 return 1 +@command('continue', +dryrunopts, helpcategory=command.CATEGORY_CHANGE_MANAGEMENT, +helpbasic=True) +def continuecmd(ui, repo, **opts): +"""resumes an interrupted operation (EXPERIMENTAL) + +Finishes a multistep operation like graft, histedit, rebase, merge, +and unshelve if they are in an interrupted state. + +use --dry-run/-n to dry run the command. +A new operation can be added to this by registering the operation and +continue logic in the unfinishedstates list under statemod. +""" +dryrun = opts.get(r'dry_run') +contstate = cmdutil.getunfinishedstate(repo) +if not
D6645: continue: added logic for hg continue
taapas1128 created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY This is part of GSoC19 project `Implement abort and continue commands`. This patch is part of the continue plan. This adds the basic logic for hg continue. This command aborts an multistep operation like graft, histedit, rebase, transplant and unshelve if they are in an unfinished state. The first part of the logic is determining the unfinished operation from the state detection API under statemod. This API is extended to support hg continue by adding a method to register the abort logic as a function (here continuefunc). Once the unfinished operation is determined the registered logic is used to resume the command in case it is interrupted. The benefit of this kind of framework is that any new extension developed can support hg continue by registering the command and logic under statedetection API. hg continue currently supports --dry-run/-n flag only. It is used to dry run hg abort REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D6645 AFFECTED FILES mercurial/commands.py mercurial/state.py CHANGE DETAILS diff --git a/mercurial/state.py b/mercurial/state.py --- a/mercurial/state.py +++ b/mercurial/state.py @@ -99,7 +99,7 @@ def __init__(self, opname, fname, clearable, allowcommit, reportonly, continueflag, stopflag, cmdmsg, cmdhint, statushint, - abortfunc): + abortfunc, continuefunc): self._opname = opname self._fname = fname self._clearable = clearable @@ -111,6 +111,7 @@ self._cmdhint = cmdhint self._statushint = statushint self.abortfunc = abortfunc +self.continuefunc = continuefunc def statusmsg(self): """returns the hint message corresponding to the command for @@ -159,7 +160,8 @@ def addunfinished(opname, fname, clearable=False, allowcommit=False, reportonly=False, continueflag=False, stopflag=False, - cmdmsg="", cmdhint="", statushint="", abortfunc=None): + cmdmsg="", cmdhint="", statushint="", abortfunc=None, + continuefunc=None): """this registers a new command or operation to unfinishedstates opname is the name the command or operation fname is the file name in which data should be stored in .hg directory. @@ -184,10 +186,12 @@ message of the format ('To continue:hg cmdname --continue' 'To abort: hg cmdname --abort') is not desired abortfunc stores the function required to abort an unfinished state. +continuefunc stores the function required to finish an interrupted +operation. """ statecheckobj = _statecheck(opname, fname, clearable, allowcommit, reportonly, continueflag, stopflag, cmdmsg, -cmdhint, statushint, abortfunc) +cmdhint, statushint, abortfunc, continuefunc) if opname == 'merge': _unfinishedstates.append(statecheckobj) else: diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1893,6 +1893,32 @@ return 0 return 1 +@command('continue', +dryrunopts, helpcategory=command.CATEGORY_CHANGE_MANAGEMENT, +helpbasic=True) +def continuecmd(ui, repo, **opts): +"""finishes an interrupted operation (EXPERIMENTAL) + +Finishes a multistep operation like graft, histedit, rebase, merge, +and unshelve if they are in an interrupted state. + +use --dry-run/-n to dry run the command. +A new operation can be added to this by registering the operation and +continue logic in the unfinishedstates list under statemod. +""" +dryrun = opts.get(r'dry_run') +contstate = cmdutil.getunfinishedstate(repo) +if not contstate: +raise error.Abort(_('no operation in progress')) +if not contstate.continuefunc: +raise error.Abort((_("%s in progress but does not support " + "'hg continue'") % (contstate._opname)), + hint=contstate.continuemsg()) +if dryrun: +ui.status(_('%s in progress, will be resumed\n') % (contstate._opname)) +return +return contstate.continuefunc(ui, repo) + @command('copy|cp', [('A', 'after', None, _('record a copy that has already occurred')), ('f', 'force', None, _('forcibly copy over an existing managed file')), To: taapas1128, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel