Mercurial > public > mercurial-scm > hg
comparison mercurial/state.py @ 42612:3c16b9c0b099
continue: added logic for hg continue
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
Differential Revision: https://phab.mercurial-scm.org/D6645
author | Taapas Agrawal <taapas2897@gmail.com> |
---|---|
date | Mon, 15 Jul 2019 22:23:31 +0530 |
parents | 3bc400ccbf99 |
children | 8c4f32b907e6 |
comparison
equal
deleted
inserted
replaced
42611:2f760da140ee | 42612:3c16b9c0b099 |
---|---|
97 multistep operation or multistep command extension. | 97 multistep operation or multistep command extension. |
98 """ | 98 """ |
99 | 99 |
100 def __init__(self, opname, fname, clearable, allowcommit, reportonly, | 100 def __init__(self, opname, fname, clearable, allowcommit, reportonly, |
101 continueflag, stopflag, cmdmsg, cmdhint, statushint, | 101 continueflag, stopflag, cmdmsg, cmdhint, statushint, |
102 abortfunc): | 102 abortfunc, continuefunc): |
103 self._opname = opname | 103 self._opname = opname |
104 self._fname = fname | 104 self._fname = fname |
105 self._clearable = clearable | 105 self._clearable = clearable |
106 self._allowcommit = allowcommit | 106 self._allowcommit = allowcommit |
107 self._reportonly = reportonly | 107 self._reportonly = reportonly |
109 self._stopflag = stopflag | 109 self._stopflag = stopflag |
110 self._cmdmsg = cmdmsg | 110 self._cmdmsg = cmdmsg |
111 self._cmdhint = cmdhint | 111 self._cmdhint = cmdhint |
112 self._statushint = statushint | 112 self._statushint = statushint |
113 self.abortfunc = abortfunc | 113 self.abortfunc = abortfunc |
114 self.continuefunc = continuefunc | |
114 | 115 |
115 def statusmsg(self): | 116 def statusmsg(self): |
116 """returns the hint message corresponding to the command for | 117 """returns the hint message corresponding to the command for |
117 hg status --verbose | 118 hg status --verbose |
118 """ | 119 """ |
157 # A list of statecheck objects for multistep operations like graft. | 158 # A list of statecheck objects for multistep operations like graft. |
158 _unfinishedstates = [] | 159 _unfinishedstates = [] |
159 | 160 |
160 def addunfinished(opname, fname, clearable=False, allowcommit=False, | 161 def addunfinished(opname, fname, clearable=False, allowcommit=False, |
161 reportonly=False, continueflag=False, stopflag=False, | 162 reportonly=False, continueflag=False, stopflag=False, |
162 cmdmsg="", cmdhint="", statushint="", abortfunc=None): | 163 cmdmsg="", cmdhint="", statushint="", abortfunc=None, |
164 continuefunc=None): | |
163 """this registers a new command or operation to unfinishedstates | 165 """this registers a new command or operation to unfinishedstates |
164 opname is the name the command or operation | 166 opname is the name the command or operation |
165 fname is the file name in which data should be stored in .hg directory. | 167 fname is the file name in which data should be stored in .hg directory. |
166 It is None for merge command. | 168 It is None for merge command. |
167 clearable boolean determines whether or not interrupted states can be | 169 clearable boolean determines whether or not interrupted states can be |
182 To abort: hg cmdname --abort" is not desired. | 184 To abort: hg cmdname --abort" is not desired. |
183 statushint is used to pass a different status message in case standard | 185 statushint is used to pass a different status message in case standard |
184 message of the format ('To continue: hg cmdname --continue' | 186 message of the format ('To continue: hg cmdname --continue' |
185 'To abort: hg cmdname --abort') is not desired | 187 'To abort: hg cmdname --abort') is not desired |
186 abortfunc stores the function required to abort an unfinished state. | 188 abortfunc stores the function required to abort an unfinished state. |
189 continuefunc stores the function required to finish an interrupted | |
190 operation. | |
187 """ | 191 """ |
188 statecheckobj = _statecheck(opname, fname, clearable, allowcommit, | 192 statecheckobj = _statecheck(opname, fname, clearable, allowcommit, |
189 reportonly, continueflag, stopflag, cmdmsg, | 193 reportonly, continueflag, stopflag, cmdmsg, |
190 cmdhint, statushint, abortfunc) | 194 cmdhint, statushint, abortfunc, continuefunc) |
191 if opname == 'merge': | 195 if opname == 'merge': |
192 _unfinishedstates.append(statecheckobj) | 196 _unfinishedstates.append(statecheckobj) |
193 else: | 197 else: |
194 _unfinishedstates.insert(0, statecheckobj) | 198 _unfinishedstates.insert(0, statecheckobj) |
195 | 199 |