This removes afterresolvedstates from cmdutil and adds
support for it in _statecheck class.
A new flag continueflag is added to the class to check whether an
operation supports --continue option or not.
Tests remain unchanged.
durin42 | |
martinvonz |
hg-reviewers |
This removes afterresolvedstates from cmdutil and adds
support for it in _statecheck class.
A new flag continueflag is added to the class to check whether an
operation supports --continue option or not.
Tests remain unchanged.
Lint Skipped |
Unit Tests Skipped |
mercurial/state.py | ||
---|---|---|
135 | I'll move this up two lines in flight so it's consistent with the order above |
mercurial/state.py | ||
---|---|---|
135 | Oh, it still won't be consistent... Can you send a follow-up to reorder these assignments to be consistent? |
Path | Packages | |||
---|---|---|---|---|
M | hgext/histedit.py (6 lines) | |||
M | hgext/rebase.py (5 lines) | |||
M | hgext/shelve.py (5 lines) | |||
M | mercurial/cmdutil.py (13 lines) | |||
M | mercurial/state.py (14 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
69602809592a | 59b978555190 | Taapas Agrawal | Jun 20 2019, 2:10 AM |
Status | Author | Revision | |
---|---|---|---|
Closed | taapas1128 | ||
Closed | taapas1128 | ||
Closed | taapas1128 | ||
Closed | taapas1128 | ||
Closed | taapas1128 | ||
Closed | taapas1128 | ||
Closed | taapas1128 | ||
Closed | taapas1128 |
if state.actions: | if state.actions: | ||||
# i18n: column positioning for "hg summary" | # i18n: column positioning for "hg summary" | ||||
ui.write(_('hist: %s (histedit --continue)\n') % | ui.write(_('hist: %s (histedit --continue)\n') % | ||||
(ui.label(_('%d remaining'), 'histedit.remaining') % | (ui.label(_('%d remaining'), 'histedit.remaining') % | ||||
len(state.actions))) | len(state.actions))) | ||||
def extsetup(ui): | def extsetup(ui): | ||||
cmdutil.summaryhooks.add('histedit', summaryhook) | cmdutil.summaryhooks.add('histedit', summaryhook) | ||||
statemod.addunfinished('histedit', fname='histedit-state', allowcommit=True) | statemod.addunfinished('histedit', fname='histedit-state', allowcommit=True, | ||||
cmdutil.afterresolvedstates.append( | continueflag=True) | ||||
['histedit-state', _('hg histedit --continue')]) |
def uisetup(ui): | def uisetup(ui): | ||||
#Replace pull with a decorator to provide --rebase option | #Replace pull with a decorator to provide --rebase option | ||||
entry = extensions.wrapcommand(commands.table, 'pull', pullrebase) | entry = extensions.wrapcommand(commands.table, 'pull', pullrebase) | ||||
entry[1].append(('', 'rebase', None, | entry[1].append(('', 'rebase', None, | ||||
_("rebase working directory to branch head"))) | _("rebase working directory to branch head"))) | ||||
entry[1].append(('t', 'tool', '', | entry[1].append(('t', 'tool', '', | ||||
_("specify merge tool for rebase"))) | _("specify merge tool for rebase"))) | ||||
cmdutil.summaryhooks.add('rebase', summaryhook) | cmdutil.summaryhooks.add('rebase', summaryhook) | ||||
statemod.addunfinished('rebase', fname='rebasestate', stopflag=True) | statemod.addunfinished('rebase', fname='rebasestate', stopflag=True, | ||||
cmdutil.afterresolvedstates.append( | continueflag=True) | ||||
['rebasestate', _('hg rebase --continue')]) |
return listcmd(ui, repo, pats, opts) | return listcmd(ui, repo, pats, opts) | ||||
elif checkopt('patch') or checkopt('stat'): | elif checkopt('patch') or checkopt('stat'): | ||||
return patchcmds(ui, repo, pats, opts) | return patchcmds(ui, repo, pats, opts) | ||||
else: | else: | ||||
return createcmd(ui, repo, pats, opts) | return createcmd(ui, repo, pats, opts) | ||||
def extsetup(ui): | def extsetup(ui): | ||||
statemod.addunfinished( | statemod.addunfinished( | ||||
'unshelve', fname=shelvedstate._filename, | 'unshelve', fname=shelvedstate._filename, continueflag=True, | ||||
cmdmsg=_('unshelve already in progress') | cmdmsg=_('unshelve already in progress') | ||||
) | ) | ||||
cmdutil.afterresolvedstates.append( | |||||
[shelvedstate._filename, _('hg unshelve --continue')]) |
histedit, bisect, update etc and check whether such commands | histedit, bisect, update etc and check whether such commands | ||||
are in an unfinished conditition or not and return appropriate message | are in an unfinished conditition or not and return appropriate message | ||||
and hint. | and hint. | ||||
It also has the ability to register and determine the states of any new | It also has the ability to register and determine the states of any new | ||||
multistep operation or multistep command extension. | multistep operation or multistep command extension. | ||||
""" | """ | ||||
def __init__(self, opname, fname, clearable=False, allowcommit=False, | def __init__(self, opname, fname, clearable=False, allowcommit=False, | ||||
reportonly=False, stopflag=False, cmdmsg="", cmdhint="", | reportonly=False, continueflag=False, stopflag=False , | ||||
statushint=""): | cmdmsg="", cmdhint="", statushint=""): | ||||
"""opname is the name the command or operation | """opname is the name the command or operation | ||||
fname is the file name in which data should be stored in .hg directory. | fname is the file name in which data should be stored in .hg directory. | ||||
It is None for merge command. | It is None for merge command. | ||||
clearable boolean determines whether or not interrupted states can be | clearable boolean determines whether or not interrupted states can be | ||||
cleared by running `hg update -C .` which in turn deletes the | cleared by running `hg update -C .` which in turn deletes the | ||||
state file. | state file. | ||||
allowcommit boolean decides whether commit is allowed during interrupted | allowcommit boolean decides whether commit is allowed during interrupted | ||||
state or not. | state or not. | ||||
reportonly flag is used for operations like bisect where we just | reportonly flag is used for operations like bisect where we just | ||||
need to detect the operation using 'hg status --verbose' | need to detect the operation using 'hg status --verbose' | ||||
continueflag is a boolean determines whether or not a command supports | |||||
`--continue` option or not. | |||||
stopflag is a boolean that determines whether or not a command supports | stopflag is a boolean that determines whether or not a command supports | ||||
--stop flag | --stop flag | ||||
cmdmsg is used to pass a different status message in case standard | cmdmsg is used to pass a different status message in case standard | ||||
message of the format "abort: cmdname in progress" is not desired. | message of the format "abort: cmdname in progress" is not desired. | ||||
cmdhint is used to pass a different hint message in case standard | cmdhint is used to pass a different hint message in case standard | ||||
message of the format "To continue: hg cmdname --continue | message of the format "To continue: hg cmdname --continue | ||||
To abort: hg cmdname --abort" is not desired. | To abort: hg cmdname --abort" is not desired. | ||||
statushint is used to pass a different status message in case standard | statushint is used to pass a different status message in case standard | ||||
message of the format ('To continue: hg cmdname --continue' | message of the format ('To continue: hg cmdname --continue' | ||||
'To abort: hg cmdname --abort') is not desired | 'To abort: hg cmdname --abort') is not desired | ||||
""" | """ | ||||
self._opname = opname | self._opname = opname | ||||
self._fname = fname | self._fname = fname | ||||
self._clearable = clearable | self._clearable = clearable | ||||
self._allowcommit = allowcommit | self._allowcommit = allowcommit | ||||
self._cmdhint = cmdhint | self._cmdhint = cmdhint | ||||
self._statushint = statushint | self._statushint = statushint | ||||
self._cmdmsg = cmdmsg | self._cmdmsg = cmdmsg | ||||
self._stopflag = stopflag | self._stopflag = stopflag | ||||
self._reportonly = reportonly | self._reportonly = reportonly | ||||
self._continueflag = continueflag | |||||
martinvonzUnsubmitted Not Done I'll move this up two lines in flight so it's consistent with the order above martinvonz: I'll move this up two lines in flight so it's consistent with the order above | |||||
martinvonzUnsubmitted Not Done Oh, it still won't be consistent... Can you send a follow-up to reorder these assignments to be consistent? martinvonz: Oh, it still won't be consistent... Can you send a follow-up to reorder these assignments to be… | |||||
taapas1128AuthorUnsubmitted Not Done sure. taapas1128: sure. | |||||
taapas1128AuthorUnsubmitted Done resolved in D6583 taapas1128: resolved in D6583 | |||||
def statusmsg(self): | def statusmsg(self): | ||||
"""returns the hint message corresponding to the command for | """returns the hint message corresponding to the command for | ||||
hg status --verbose | hg status --verbose | ||||
""" | """ | ||||
if not self._statushint: | if not self._statushint: | ||||
hint = (_('To continue: hg %s --continue\n' | hint = (_('To continue: hg %s --continue\n' | ||||
'To abort: hg %s --abort') % (self._opname, | 'To abort: hg %s --abort') % (self._opname, | ||||
return self._cmdhint | return self._cmdhint | ||||
def msg(self): | def msg(self): | ||||
"""returns the status message corresponding to the command""" | """returns the status message corresponding to the command""" | ||||
if not self._cmdmsg: | if not self._cmdmsg: | ||||
return _('%s in progress') % (self._opname) | return _('%s in progress') % (self._opname) | ||||
return self._cmdmsg | return self._cmdmsg | ||||
def continuemsg(self): | |||||
""" returns appropriate continue message corresponding to command""" | |||||
return _('hg %s --continue') % (self._opname) | |||||
def isunfinished(self, repo): | def isunfinished(self, repo): | ||||
"""determines whether a multi-step operation is in progress | """determines whether a multi-step operation is in progress | ||||
or not | or not | ||||
""" | """ | ||||
if self._opname == 'merge': | if self._opname == 'merge': | ||||
return len(repo[None].parents()) > 1 | return len(repo[None].parents()) > 1 | ||||
else: | else: | ||||
return repo.vfs.exists(self._fname) | return repo.vfs.exists(self._fname) | ||||
# A list of statecheck objects for multistep operations like graft. | # A list of statecheck objects for multistep operations like graft. | ||||
_unfinishedstates = [] | _unfinishedstates = [] | ||||
def addunfinished(opname, **kwargs): | def addunfinished(opname, **kwargs): | ||||
"""this registers a new command or operation to unfinishedstates | """this registers a new command or operation to unfinishedstates | ||||
""" | """ | ||||
statecheckobj = _statecheck(opname, **kwargs) | statecheckobj = _statecheck(opname, **kwargs) | ||||
if opname == 'merge': | if opname == 'merge': | ||||
_unfinishedstates.append(statecheckobj) | _unfinishedstates.append(statecheckobj) | ||||
else: | else: | ||||
_unfinishedstates.insert(0, statecheckobj) | _unfinishedstates.insert(0, statecheckobj) | ||||
addunfinished( | addunfinished( | ||||
'graft', fname='graftstate', clearable=True, stopflag=True, | 'graft', fname='graftstate', clearable=True, stopflag=True, | ||||
cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop"), | continueflag=True, | ||||
cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop") | |||||
) | ) | ||||
addunfinished( | addunfinished( | ||||
'update', fname='updatestate', clearable=True, | 'update', fname='updatestate', clearable=True, | ||||
cmdmsg=_('last update was interrupted'), | cmdmsg=_('last update was interrupted'), | ||||
cmdhint=_("use 'hg update' to get a consistent checkout"), | cmdhint=_("use 'hg update' to get a consistent checkout"), | ||||
statushint=_("To continue: hg update") | statushint=_("To continue: hg update") | ||||
) | ) | ||||
addunfinished( | addunfinished( |
Now that afterresolvedstates has been removed, you need to update this docstring.