Patchwork D6552: statecheck: added support for cmdutil.afterresolvedstates

mail settings
Submitter phabricator
Date June 20, 2019, 6:13 a.m.
Message ID <>
Download mbox | patch
Permalink /patch/40618/
State Superseded
Headers show


phabricator - June 20, 2019, 6:13 a.m.
taapas1128 created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: martinvonz.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

  This removes `afterresolvedstates` from `` 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.

  rHG Mercurial




To: taapas1128, durin42, martinvonz, #hg-reviewers
Cc: mercurial-devel


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -98,8 +98,8 @@ 
     def __init__(self, opname, fname, clearable=False, allowcommit=False,
-                 reportonly=False, cmdmsg="", cmdhint="", statushint="",
-                 stopflag=False):
+                 reportonly=False, doesnotcontinue=False, cmdmsg="", cmdhint="",
+                 statushint="", stopflag=False):
         """opname is the name the command or operation
         fname is the file name in which data should be stored in .hg directory.
         It is None for merge command.
@@ -111,6 +111,8 @@ 
         reportonly flag is used for operations like bisect where we just
         need to detect the operation using 'hg status --verbose'
         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.
         cmdhint is used to pass a different hint message in case standard
         message of the format "To continue: hg cmdname --continue
@@ -132,6 +134,7 @@ 
         self._cmdmsg = cmdmsg
         self._stopflag = stopflag
         self._reportonly = reportonly
+        self._doesnotcontinue = doesnotcontinue
     def statusmsg(self):
         """returns the hint message corresponding to the command for
@@ -162,6 +165,10 @@ 
             return _('%s in progress') % (self._opname)
         return self._cmdmsg
+    def continuemsg(self):
+        """ returns appropriate continue message corresponding to command"""
+        return _('hg %s --continue') % (self._opname)
     def isunfinished(self, repo):
         """determines whether a multi-step operation is in progress
         or not
@@ -188,19 +195,20 @@ 
     cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop"),
-    'update',fname='updatestate', clearable=True,
+    'update',fname='updatestate', clearable=True, doesnotcontinue=True,
     cmdmsg=_('last update was interrupted'),
     cmdhint=_("use 'hg update' to get a consistent checkout"),
     statushint=_("To continue:    hg update")
     'bisect', fname='bisect.state', allowcommit=True, reportonly=True,
+    doesnotcontinue=True,
     statushint=_('To mark the changeset good:    hg bisect --good\n'
                  'To mark the changeset bad:     hg bisect --bad\n'
                  'To abort:                      hg bisect --reset\n')
-    'merge', fname=None, clearable=True, allowcommit=True,
+    'merge', fname=None, clearable=True, allowcommit=True, doesnotcontinue=True,
     cmdmsg=_('outstanding uncommitted merge'),
     statushint=_('To continue:    hg commit\n'
                  'To abort:       hg merge --abort'),
@@ -253,11 +261,6 @@ 
         if state.isunfinished(repo):
             return (state._opname, state.statusmsg())
-afterresolvedstates = [
-    ('graftstate',
-     _('hg graft --continue')),
-    ]
 def howtocontinue(repo):
     '''Check for an unfinished operation and return the command to finish
@@ -269,9 +272,11 @@ 
     a boolean.
     contmsg = _("continue: %s")
-    for f, msg in afterresolvedstates:
-        if repo.vfs.exists(f):
-            return contmsg % msg, True
+    for state in _unfinishedstates:
+        if state._doesnotcontinue:
+            continue
+        if state.isunfinished(repo):
+            return contmsg % state.continuemsg(), True
     if repo[None].dirty(missing=True, merge=False, branch=False):
         return contmsg % _("hg commit"), False
     return None, None
diff --git a/hgext/ b/hgext/
--- a/hgext/
+++ b/hgext/
@@ -760,6 +760,7 @@ 
 def extsetup(ui):
     statemod.addunfinished (
         'transplant', fname='transplant/journal', clearable=True,
+        doesnotcontinue=True,
         statushint=_('To continue:    hg transplant --continue\n'
                      'To abort:       hg update'),
         cmdhint=_("use 'hg transplant --continue' or 'hg update' to abort")
diff --git a/hgext/ b/hgext/
--- a/hgext/
+++ b/hgext/
@@ -1142,5 +1142,4 @@ 
         'unshelve', fname=shelvedstate._filename,
         cmdmsg=_('unshelve already in progress')
-    statemod.afterresolvedstates.append(
-        [shelvedstate._filename, _('hg unshelve --continue')])
diff --git a/hgext/ b/hgext/
--- a/hgext/
+++ b/hgext/
@@ -1951,5 +1951,3 @@ 
                      _("specify merge tool for rebase")))
     cmdutil.summaryhooks.add('rebase', summaryhook)
     statemod.addunfinished('rebase', fname='rebasestate', stopflag=True)
-    statemod.afterresolvedstates.append(
-        ['rebasestate', _('hg rebase --continue')])
diff --git a/hgext/ b/hgext/
--- a/hgext/
+++ b/hgext/
@@ -2314,5 +2314,4 @@ 
 def extsetup(ui):
     cmdutil.summaryhooks.add('histedit', summaryhook)
     statemod.addunfinished('histedit', fname='histedit-state', allowcommit=True)
-    statemod.afterresolvedstates.append(
-        ['histedit-state', _('hg histedit --continue')])