This removes afterresolvedstates from state.py and adds
support for it in _statecheck class.
A new flag doesnotcontinue 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 state.py and adds
support for it in _statecheck class.
A new flag doesnotcontinue is added to the class to check whether an
operation supports --continue option or not.
Tests remain unchanged.
| Lint Skipped |
| Unit Tests Skipped |
| Path | Packages | |||
|---|---|---|---|---|
| M | hgext/histedit.py (3 lines) | |||
| M | hgext/rebase.py (2 lines) | |||
| M | hgext/shelve.py (3 lines) | |||
| M | hgext/transplant.py (1 line) | |||
| M | mercurial/state.py (29 lines) |
| Commit | Parents | Author | Summary | Date |
|---|---|---|---|---|
| 167a852b90db | ad7f82ce2038 | Taapas Agrawal | Jun 20 2019, 2:10 AM |
| # 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) | ||||
| statemod.afterresolvedstates.append( | |||||
| ['histedit-state', _('hg histedit --continue')]) | |||||
| #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) | ||||
| statemod.afterresolvedstates.append( | |||||
| ['rebasestate', _('hg rebase --continue')]) | |||||
| 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, | ||||
| cmdmsg=_('unshelve already in progress') | cmdmsg=_('unshelve already in progress') | ||||
| ) | ) | ||||
| statemod.afterresolvedstates.append( | |||||
| [shelvedstate._filename, _('hg unshelve --continue')]) | |||||
| changeset if any.""" | changeset if any.""" | ||||
| ctx = context.resource(mapping, 'ctx') | ctx = context.resource(mapping, 'ctx') | ||||
| n = ctx.extra().get('transplant_source') | n = ctx.extra().get('transplant_source') | ||||
| return n and nodemod.hex(n) or '' | return n and nodemod.hex(n) or '' | ||||
| def extsetup(ui): | def extsetup(ui): | ||||
| statemod.addunfinished ( | statemod.addunfinished ( | ||||
| 'transplant', fname='transplant/journal', clearable=True, | 'transplant', fname='transplant/journal', clearable=True, | ||||
| doesnotcontinue=True, | |||||
| statushint=_('To continue: hg transplant --continue\n' | statushint=_('To continue: hg transplant --continue\n' | ||||
| 'To abort: hg update'), | 'To abort: hg update'), | ||||
| cmdhint=_("use 'hg transplant --continue' or 'hg update' to abort") | cmdhint=_("use 'hg transplant --continue' or 'hg update' to abort") | ||||
| ) | ) | ||||
| # tell hggettext to extract docstrings from these functions: | # tell hggettext to extract docstrings from these functions: | ||||
| i18nfunctions = [revsettransplanted, kwtransplanted] | i18nfunctions = [revsettransplanted, kwtransplanted] | ||||
| 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, cmdmsg="", cmdhint="", statushint="", | reportonly=False, doesnotcontinue=False, cmdmsg="", cmdhint="", | ||||
| stopflag=False): | statushint="", stopflag=False): | ||||
| """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' | ||||
| cmdmsg is used to pass a different status message in case standard | cmdmsg is used to pass a different status message in case standard | ||||
| doesnotcontinue flag determines whether a command supports `--continue` | |||||
| option or not. | |||||
| 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. | ||||
| status hint is used to pass a different status message in case standard | status hint 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 | ||||
| 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 | ||||
| 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' | ||||
| """ | """ | ||||
| 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._doesnotcontinue = doesnotcontinue | |||||
| 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) | ||||
| 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"), | cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop"), | ||||
| ) | ) | ||||
| addunfinished( | addunfinished( | ||||
| 'update',fname='updatestate', clearable=True, | 'update',fname='updatestate', clearable=True, doesnotcontinue=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( | ||||
| 'bisect', fname='bisect.state', allowcommit=True, reportonly=True, | 'bisect', fname='bisect.state', allowcommit=True, reportonly=True, | ||||
| doesnotcontinue=True, | |||||
| statushint=_('To mark the changeset good: hg bisect --good\n' | statushint=_('To mark the changeset good: hg bisect --good\n' | ||||
| 'To mark the changeset bad: hg bisect --bad\n' | 'To mark the changeset bad: hg bisect --bad\n' | ||||
| 'To abort: hg bisect --reset\n') | 'To abort: hg bisect --reset\n') | ||||
| ) | ) | ||||
| addunfinished( | addunfinished( | ||||
| 'merge', fname=None, clearable=True, allowcommit=True, | 'merge', fname=None, clearable=True, allowcommit=True, doesnotcontinue=True, | ||||
| cmdmsg=_('outstanding uncommitted merge'), | cmdmsg=_('outstanding uncommitted merge'), | ||||
| statushint=_('To continue: hg commit\n' | statushint=_('To continue: hg commit\n' | ||||
| 'To abort: hg merge --abort'), | 'To abort: hg merge --abort'), | ||||
| cmdhint=_("use 'hg commit' or 'hg merge --abort'") | cmdhint=_("use 'hg commit' or 'hg merge --abort'") | ||||
| ) | ) | ||||
| def checkunfinished(repo, commit=False, skipmerge=False): | def checkunfinished(repo, commit=False, skipmerge=False): | ||||
| '''Look for an unfinished multistep operation, like graft, and abort | '''Look for an unfinished multistep operation, like graft, and abort | ||||
| # experimental config: commands.status.skipstates | # experimental config: commands.status.skipstates | ||||
| skip = set(repo.ui.configlist('commands', 'status.skipstates')) | skip = set(repo.ui.configlist('commands', 'status.skipstates')) | ||||
| for state in _unfinishedstates: | for state in _unfinishedstates: | ||||
| if state._opname in skip: | if state._opname in skip: | ||||
| continue | continue | ||||
| if state.isunfinished(repo): | if state.isunfinished(repo): | ||||
| return (state._opname, state.statusmsg()) | return (state._opname, state.statusmsg()) | ||||
| afterresolvedstates = [ | |||||
| ('graftstate', | |||||
| _('hg graft --continue')), | |||||
| ] | |||||
| def howtocontinue(repo): | def howtocontinue(repo): | ||||
| '''Check for an unfinished operation and return the command to finish | '''Check for an unfinished operation and return the command to finish | ||||
| it. | it. | ||||
| afterresolvedstates tuples define a .hg/{file} and the corresponding | afterresolvedstates tuples define a .hg/{file} and the corresponding | ||||
| command needed to finish it. | command needed to finish it. | ||||
| Returns a (msg, warning) tuple. 'msg' is a string and 'warning' is | Returns a (msg, warning) tuple. 'msg' is a string and 'warning' is | ||||
| a boolean. | a boolean. | ||||
| ''' | ''' | ||||
| contmsg = _("continue: %s") | contmsg = _("continue: %s") | ||||
| for f, msg in afterresolvedstates: | for state in _unfinishedstates: | ||||
| if repo.vfs.exists(f): | if state._doesnotcontinue: | ||||
| return contmsg % msg, True | continue | ||||
| if state.isunfinished(repo): | |||||
| return contmsg % state.continuemsg(), True | |||||
| if repo[None].dirty(missing=True, merge=False, branch=False): | if repo[None].dirty(missing=True, merge=False, branch=False): | ||||
| return contmsg % _("hg commit"), False | return contmsg % _("hg commit"), False | ||||
| return None, None | return None, None | ||||