D6487: states: created new class to handle multi-step unfinished states

taapas1128 (Taapas Agrawal) phabricator at mercurial-scm.org
Sat Jun 8 12:36:13 EDT 2019


taapas1128 updated this revision to Diff 15390.
taapas1128 retitled this revision from "states: created new class to handle multi-step operation states" to "states: created new class to handle multi-step unfinished states".
taapas1128 edited the summary of this revision.
Herald added a reviewer: durin42.
Herald added subscribers: Kwan, mjpieters.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6487?vs=15367&id=15390

REVISION DETAIL
  https://phab.mercurial-scm.org/D6487

AFFECTED FILES
  hgext/absorb.py
  hgext/fix.py
  hgext/histedit.py
  hgext/phabricator.py
  hgext/rebase.py
  hgext/record.py
  hgext/shelve.py
  hgext/strip.py
  hgext/transplant.py
  mercurial/cmdutil.py
  mercurial/commands.py
  mercurial/state.py
  tests/test-absorb-unfinished.t
  tests/test-fix.t
  tests/test-graft.t
  tests/test-histedit-arguments.t
  tests/test-histedit-edit.t
  tests/test-histedit-no-change.t
  tests/test-qrecord.t
  tests/test-rebase-abort.t
  tests/test-rebase-obsolete.t
  tests/test-rebase-pull.t
  tests/test-shelve.t
  tests/test-transplant.t

CHANGE DETAILS

diff --git a/tests/test-transplant.t b/tests/test-transplant.t
--- a/tests/test-transplant.t
+++ b/tests/test-transplant.t
@@ -479,7 +479,8 @@
   [255]
   $ hg transplant 1:3
   abort: transplant in progress
-  (use 'hg transplant --continue' or 'hg update' to abort)
+  (To continue:    hg transplant --continue
+  To abort:       hg update)
   [255]
   $ echo fixed > baz
   $ hg transplant --continue
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -426,8 +426,9 @@
   U a/a
 
   $ hg shelve
-  abort: unshelve already in progress
-  (use 'hg unshelve --continue' or 'hg unshelve --abort')
+  abort: unshelve in progress
+  (To continue:    hg unshelve --continue
+  To abort:       hg unshelve --abort)
   [255]
 
 abort the unshelve and be happy
@@ -484,8 +485,9 @@
   continue: hg unshelve --continue
 
   $ hg commit -m 'commit while unshelve in progress'
-  abort: unshelve already in progress
-  (use 'hg unshelve --continue' or 'hg unshelve --abort')
+  abort: unshelve in progress
+  (To continue:    hg unshelve --continue
+  To abort:       hg unshelve --abort)
   [255]
 
   $ hg graft --continue
diff --git a/tests/test-rebase-pull.t b/tests/test-rebase-pull.t
--- a/tests/test-rebase-pull.t
+++ b/tests/test-rebase-pull.t
@@ -93,7 +93,8 @@
   [1]
   $ hg pull --rebase
   abort: histedit in progress
-  (use 'hg histedit --continue' or 'hg histedit --abort')
+  (To continue:    hg histedit --continue
+  To abort:       hg histedit --abort)
   [255]
   $ hg histedit --abort --quiet
 
diff --git a/tests/test-rebase-obsolete.t b/tests/test-rebase-obsolete.t
--- a/tests/test-rebase-obsolete.t
+++ b/tests/test-rebase-obsolete.t
@@ -2054,7 +2054,8 @@
 
   $ hg rebase -s 3 -d 5
   abort: rebase in progress
-  (use 'hg rebase --continue' or 'hg rebase --abort')
+  (To continue:    hg rebase --continue
+  To abort:       hg rebase --abort)
   [255]
   $ hg rebase --stop --continue
   abort: cannot use --stop with --continue
diff --git a/tests/test-rebase-abort.t b/tests/test-rebase-abort.t
--- a/tests/test-rebase-abort.t
+++ b/tests/test-rebase-abort.t
@@ -319,7 +319,8 @@
   $ echo new > a
   $ hg up 1               # user gets an error saying to run hg rebase --abort
   abort: rebase in progress
-  (use 'hg rebase --continue' or 'hg rebase --abort')
+  (To continue:    hg rebase --continue
+  To abort:       hg rebase --abort)
   [255]
 
   $ cat a
@@ -389,20 +390,24 @@
 
   $ hg rebase -s 3 -d tip
   abort: rebase in progress
-  (use 'hg rebase --continue' or 'hg rebase --abort')
+  (To continue:    hg rebase --continue
+  To abort:       hg rebase --abort)
   [255]
   $ hg up .
   abort: rebase in progress
-  (use 'hg rebase --continue' or 'hg rebase --abort')
+  (To continue:    hg rebase --continue
+  To abort:       hg rebase --abort)
   [255]
   $ hg up -C .
   abort: rebase in progress
-  (use 'hg rebase --continue' or 'hg rebase --abort')
+  (To continue:    hg rebase --continue
+  To abort:       hg rebase --abort)
   [255]
 
   $ hg graft 3
   abort: rebase in progress
-  (use 'hg rebase --continue' or 'hg rebase --abort')
+  (To continue:    hg rebase --continue
+  To abort:       hg rebase --abort)
   [255]
 
   $ hg rebase --abort
diff --git a/tests/test-qrecord.t b/tests/test-qrecord.t
--- a/tests/test-qrecord.t
+++ b/tests/test-qrecord.t
@@ -459,5 +459,6 @@
   > n
   > EOF
   abort: histedit in progress
-  (use 'hg histedit --continue' or 'hg histedit --abort')
-  [255]
+  (To continue:    hg histedit --continue
+  To abort:       hg histedit --abort)
+  [255]
diff --git a/tests/test-histedit-no-change.t b/tests/test-histedit-no-change.t
--- a/tests/test-histedit-no-change.t
+++ b/tests/test-histedit-no-change.t
@@ -168,7 +168,8 @@
 abort editing session, after first forcibly updating away
   $ hg up 0
   abort: histedit in progress
-  (use 'hg histedit --continue' or 'hg histedit --abort')
+  (To continue:    hg histedit --continue
+  To abort:       hg histedit --abort)
   [255]
   $ mv .hg/histedit-state .hg/histedit-state-ignore
   $ hg up 0
diff --git a/tests/test-histedit-edit.t b/tests/test-histedit-edit.t
--- a/tests/test-histedit-edit.t
+++ b/tests/test-histedit-edit.t
@@ -81,7 +81,8 @@
 try to update and get an error
   $ hg update tip
   abort: histedit in progress
-  (use 'hg histedit --continue' or 'hg histedit --abort')
+  (To continue:    hg histedit --continue
+  To abort:       hg histedit --abort)
   [255]
 
 edit the plan via the editor
@@ -135,7 +136,8 @@
   3+
   $ hg up 0
   abort: histedit in progress
-  (use 'hg histedit --continue' or 'hg histedit --abort')
+  (To continue:    hg histedit --continue
+  To abort:       hg histedit --abort)
   [255]
 
 Try to delete necessary commit
@@ -152,7 +154,8 @@
 
   $ hg --config extensions.mq= qnew please-fail
   abort: histedit in progress
-  (use 'hg histedit --continue' or 'hg histedit --abort')
+  (To continue:    hg histedit --continue
+  To abort:       hg histedit --abort)
   [255]
   $ HGEDITOR='echo foobaz > ' hg histedit --continue 2>&1 | fixbundle
 
diff --git a/tests/test-histedit-arguments.t b/tests/test-histedit-arguments.t
--- a/tests/test-histedit-arguments.t
+++ b/tests/test-histedit-arguments.t
@@ -494,7 +494,8 @@
   continue: hg histedit --continue
   $ hg commit --amend -m 'reject this fold'
   abort: histedit in progress
-  (use 'hg histedit --continue' or 'hg histedit --abort')
+  (To continue:    hg histedit --continue
+  To abort:       hg histedit --abort)
   [255]
 
 With markers enabled, histedit does not get confused, and
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -287,7 +287,9 @@
 
   $ hg ci -m 'commit interrupted graft'
   abort: graft in progress
-  (use 'hg graft --continue' or 'hg graft --stop' to stop)
+  (To continue:    hg graft --continue
+  To abort:       hg graft --abort
+  To stop:        hg graft --stop)
   [255]
 
 Abort the graft and try committing:
diff --git a/tests/test-fix.t b/tests/test-fix.t
--- a/tests/test-fix.t
+++ b/tests/test-fix.t
@@ -831,7 +831,8 @@
 
   $ hg --config extensions.rebase= fix -r .
   abort: rebase in progress
-  (use 'hg rebase --continue' or 'hg rebase --abort')
+  (To continue:    hg rebase --continue
+  To abort:       hg rebase --abort)
   [255]
 
   $ cd ..
diff --git a/tests/test-absorb-unfinished.t b/tests/test-absorb-unfinished.t
--- a/tests/test-absorb-unfinished.t
+++ b/tests/test-absorb-unfinished.t
@@ -25,6 +25,7 @@
 
   $ hg --config extensions.rebase= absorb
   abort: rebase in progress
-  (use 'hg rebase --continue' or 'hg rebase --abort')
+  (To continue:    hg rebase --continue
+  To abort:       hg rebase --abort)
   [255]
 
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -19,6 +19,8 @@
 
 from __future__ import absolute_import
 
+from .i18n import _
+
 from . import (
     error,
     util,
@@ -85,3 +87,104 @@
     def exists(self):
         """check whether the state file exists or not"""
         return self._repo.vfs.exists(self.fname)
+
+class statecheck(object):
+    """a utility class that will to deal with multistep operations
+       like graft, histedit, bisect, update etc and check whether such commands
+       are in an unfinished conditition of not and return appropriate message
+       and hint.
+       It also has the ability to register and determine the states of any new
+       multistep operation or multistep command extension.
+    """
+
+    def __init__(self, cmdname, fname, clearable=False, allowcommit=False,
+                 stopflag=False):
+        """cmdname is the name the command
+        fname is the file name in which data should be stored in .hg directory.
+        It is None for merge command.
+        clearable boolean determines whether or not interrupted states can be
+        cleared by running `hg update -C .`
+        allowcommit boolean decides whether commit is allowed during interrupted
+        state or not.
+        stopflag is a boolean that determines whether or not a command supports
+        --stop flag
+        """
+        self.cmdname = cmdname
+        self.fname = fname
+        self.clearable = clearable
+        self.allowcommit = allowcommit
+        self.stopflag = stopflag
+
+    def hint(self):
+        """returns the hint message corresponding to the command"""
+        if self.cmdname == 'bisect':
+            msg = _('To mark the changeset good:    hg bisect --good\n'
+                    'To mark the changeset bad:     hg bisect --bad\n'
+                    'To abort:                      hg bisect --reset\n')
+        elif self.cmdname == 'update':
+            msg = _("use 'hg update' to get a consistent checkout")
+        elif self.cmdname == 'transplant':
+                msg = _('To continue:    hg %s --continue\n'
+                        'To abort:       hg update') % (self.cmdname)
+        else:
+            msg = (_('To continue:    hg %s --continue\n'
+                    'To abort:       hg %s --abort') % (self.cmdname,
+                    self.cmdname))
+            if self.stopflag:
+                msg = msg + (_('\nTo stop:        hg %s --stop') %
+                     (self.cmdname))
+        return msg
+
+    def msg(self):
+        """returns the status message corresponding to the command"""
+        if self.cmdname == 'update':
+            return _('last update was interrupted')
+        else:
+            return _('%s in progress') % (self.cmdname)
+
+    def isunfinished(self, repo, mergecheck=False):
+        """determines whether a multi-step operation is in progress
+        or not
+        mergecheck flag helps in determining state specifically for merge
+        """
+        if self.cmdname == 'merge' or mergecheck:
+            return len(repo[None].parents()) > 1
+        else:
+            return repo.vfs.exists(self.fname)
+
+unfinishedstates=[]
+unfinishedstates.append(statecheck('graft','graftstate', clearable=True,
+                                    allowcommit=False, stopflag=True))
+unfinishedstates.append(statecheck('update', 'updatestate', clearable=True,
+                                    allowcommit=False, stopflag=False))
+
+def checkunfinished(repo, commit=False):
+    '''Look for an unfinished multistep operation, like graft, and abort
+    if found. It's probably good to check this right before
+    bailifchanged().
+    '''
+    # Check for non-clearable states first, so things like rebase will take
+    # precedence over update.
+    for state in unfinishedstates:
+        if state.clearable or (commit and state.allowcommit):
+            continue
+        if state.isunfinished(repo):
+            raise error.Abort(state.msg(), hint=state.hint())
+
+    for s in unfinishedstates:
+        if not s.clearable or (commit and s.allowcommit):
+            continue
+        if s.isunfinished(repo):
+            raise error.Abort(s.msg(), hint=s.hint())
+
+def clearunfinished(repo):
+    '''Check for unfinished operations (as above), and clear the ones
+    that are clearable.
+    '''
+    for state in unfinishedstates:
+        if not state.clearable and state.isunfinished(repo):
+            raise error.Abort(state.msg(), hint=state.hint())
+
+    for s in unfinishedstates:
+        if s.clearable and s.isunfinished(repo):
+            util.unlink(repo.vfs.join(s.fname))
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -618,7 +618,7 @@
     if date:
         opts['date'] = dateutil.parsedate(date)
 
-    cmdutil.checkunfinished(repo)
+    statemod.checkunfinished(repo)
     cmdutil.bailifchanged(repo)
     node = scmutil.revsingle(repo, rev).node()
 
@@ -847,7 +847,7 @@
         """common used update sequence"""
         if noupdate:
             return
-        cmdutil.checkunfinished(repo)
+        statemod.checkunfinished(repo)
         cmdutil.bailifchanged(repo)
         return hg.clean(repo, node, show_stats=show_stats)
 
@@ -1664,7 +1664,7 @@
         # Let --subrepos on the command line override config setting.
         ui.setconfig('ui', 'commitsubrepos', True, 'commit')
 
-    cmdutil.checkunfinished(repo, commit=True)
+    statemod.checkunfinished(repo, commit=True)
 
     branch = repo[None].branch()
     bheads = repo.branchheads(branch)
@@ -1696,7 +1696,7 @@
         # Note: eventually this guard will be removed. Please do not expect
         # this behavior to remain.
         if not obsolete.isenabled(repo, obsolete.createmarkersopt):
-            cmdutil.checkunfinished(repo)
+            statemod.checkunfinished(repo)
 
         node = cmdutil.amend(ui, repo, old, extra, pats, opts)
         if node == old.node():
@@ -2479,7 +2479,7 @@
     else:
         if not revs:
             raise error.Abort(_('no revisions specified'))
-        cmdutil.checkunfinished(repo)
+        statemod.checkunfinished(repo)
         cmdutil.bailifchanged(repo)
         revs = scmutil.revrange(repo, revs)
 
@@ -3481,7 +3481,7 @@
 
     with repo.wlock():
         if update:
-            cmdutil.checkunfinished(repo)
+            statemod.checkunfinished(repo)
             if (exact or not opts.get('force')):
                 cmdutil.bailifchanged(repo)
 
@@ -6130,8 +6130,7 @@
         updatecheck = 'none'
 
     with repo.wlock():
-        cmdutil.clearunfinished(repo)
-
+        statemod.clearunfinished(repo)
         if date:
             rev = cmdutil.finddate(ui, repo, date)
 
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -42,6 +42,7 @@
     rewriteutil,
     scmutil,
     smartset,
+    state as statemod,
     subrepoutil,
     templatekw,
     templater,
@@ -265,7 +266,7 @@
         will be left in place, so the user can continue working.
         """
 
-        checkunfinished(repo, commit=True)
+        statemod.checkunfinished(repo, commit=True)
         wctx = repo[None]
         merge = len(wctx.parents()) > 1
         if merge:
@@ -3295,47 +3296,6 @@
 #  - (desturl,   destbranch,   destpeer,   outgoing)
 summaryremotehooks = util.hooks()
 
-# A list of state files kept by multistep operations like graft.
-# Since graft cannot be aborted, it is considered 'clearable' by update.
-# note: bisect is intentionally excluded
-# (state file, clearable, allowcommit, error, hint)
-unfinishedstates = [
-    ('graftstate', True, False, _('graft in progress'),
-     _("use 'hg graft --continue' or 'hg graft --stop' to stop")),
-    ('updatestate', True, False, _('last update was interrupted'),
-     _("use 'hg update' to get a consistent checkout"))
-    ]
-
-def checkunfinished(repo, commit=False):
-    '''Look for an unfinished multistep operation, like graft, and abort
-    if found. It's probably good to check this right before
-    bailifchanged().
-    '''
-    # Check for non-clearable states first, so things like rebase will take
-    # precedence over update.
-    for f, clearable, allowcommit, msg, hint in unfinishedstates:
-        if clearable or (commit and allowcommit):
-            continue
-        if repo.vfs.exists(f):
-            raise error.Abort(msg, hint=hint)
-
-    for f, clearable, allowcommit, msg, hint in unfinishedstates:
-        if not clearable or (commit and allowcommit):
-            continue
-        if repo.vfs.exists(f):
-            raise error.Abort(msg, hint=hint)
-
-def clearunfinished(repo):
-    '''Check for unfinished operations (as above), and clear the ones
-    that are clearable.
-    '''
-    for f, clearable, allowcommit, msg, hint in unfinishedstates:
-        if not clearable and repo.vfs.exists(f):
-            raise error.Abort(msg, hint=hint)
-    for f, clearable, allowcommit, msg, hint in unfinishedstates:
-        if clearable and repo.vfs.exists(f):
-            util.unlink(repo.vfs.join(f))
-
 afterresolvedstates = [
     ('graftstate',
      _('hg graft --continue')),
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -35,6 +35,7 @@
     revset,
     scmutil,
     smartset,
+    state as statemod,
     util,
     vfs as vfsmod,
 )
@@ -675,7 +676,7 @@
         if not tp.canresume():
             raise error.Abort(_('no transplant to continue'))
     else:
-        cmdutil.checkunfinished(repo)
+        statemod.checkunfinished(repo)
         cmdutil.bailifchanged(repo)
 
     sourcerepo = opts.get('source')
@@ -757,9 +758,8 @@
     return n and nodemod.hex(n) or ''
 
 def extsetup(ui):
-    cmdutil.unfinishedstates.append(
-        ['transplant/journal', True, False, _('transplant in progress'),
-         _("use 'hg transplant --continue' or 'hg update' to abort")])
+    statemod.unfinishedstates.append(statemod.statecheck('transplant',
+    'transplant/journal', clearable=True, allowcommit=False, stopflag=False))
 
 # tell hggettext to extract docstrings from these functions:
 i18nfunctions = [revsettransplanted, kwtransplanted]
diff --git a/hgext/strip.py b/hgext/strip.py
--- a/hgext/strip.py
+++ b/hgext/strip.py
@@ -18,6 +18,7 @@
     registrar,
     repair,
     scmutil,
+    state as statemod,
     util,
 )
 nullid = nodemod.nullid
@@ -47,7 +48,7 @@
     return inclsubs
 
 def checklocalchanges(repo, force=False, excsuffix=''):
-    cmdutil.checkunfinished(repo)
+    statemod.checkunfinished(repo)
     s = repo.status()
     if not force:
         if s.modified or s.added or s.removed or s.deleted:
diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -48,6 +48,7 @@
     registrar,
     repair,
     scmutil,
+    state as statemod,
     templatefilters,
     util,
     vfs as vfsmod,
@@ -445,7 +446,7 @@
 def createcmd(ui, repo, pats, opts):
     """subcommand that creates a new shelve"""
     with repo.wlock():
-        cmdutil.checkunfinished(repo)
+        statemod.checkunfinished(repo)
         return _docreatecmd(ui, repo, pats, opts)
 
 def _docreatecmd(ui, repo, pats, opts):
@@ -935,7 +936,7 @@
     abortf = opts.get('abort')
     continuef = opts.get('continue')
     if not abortf and not continuef:
-        cmdutil.checkunfinished(repo)
+        statemod.checkunfinished(repo)
     shelved = list(shelved)
     if opts.get("name"):
         shelved.append(opts["name"])
@@ -1139,9 +1140,7 @@
         return createcmd(ui, repo, pats, opts)
 
 def extsetup(ui):
-    cmdutil.unfinishedstates.append(
-        [shelvedstate._filename, False, False,
-         _('unshelve already in progress'),
-         _("use 'hg unshelve --continue' or 'hg unshelve --abort'")])
+    statemod.unfinishedstates.append(statemod.statecheck('unshelve',
+    shelvedstate._filename, clearable=False, allowcommit=False, stopflag=False))
     cmdutil.afterresolvedstates.append(
         [shelvedstate._filename, _('hg unshelve --continue')])
diff --git a/hgext/record.py b/hgext/record.py
--- a/hgext/record.py
+++ b/hgext/record.py
@@ -19,6 +19,7 @@
     error,
     extensions,
     registrar,
+    state as statemod,
 )
 
 cmdtable = {}
@@ -119,7 +120,7 @@
 
     overrides = {('experimental', 'crecord'): False}
     with ui.configoverride(overrides, 'record'):
-        cmdutil.checkunfinished(repo)
+        statemod.checkunfinished(repo)
         cmdutil.dorecord(ui, repo, committomq, cmdsuggest, False,
                          cmdutil.recordfilter, *pats, **opts)
 
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -1066,7 +1066,7 @@
         raise error.Abort(_('cannot specify both a revision and a source'))
 
     if not inmemory:
-        cmdutil.checkunfinished(repo)
+        statemod.checkunfinished(repo)
         cmdutil.bailifchanged(repo)
 
     if ui.configbool('commands', 'rebase.requiredest') and not destf:
@@ -1146,7 +1146,7 @@
            rebase_rebasing_wcp=rebasingwcp)
     if inmemory and rebasingwcp:
         # Check these since we did not before.
-        cmdutil.checkunfinished(repo)
+        statemod.checkunfinished(repo)
         cmdutil.bailifchanged(repo)
 
     if not destf:
@@ -1821,7 +1821,7 @@
                 ui.debug('--update and --rebase are not compatible, ignoring '
                          'the update flag\n')
 
-            cmdutil.checkunfinished(repo)
+            statemod.checkunfinished(repo)
             cmdutil.bailifchanged(repo, hint=_('cannot pull with rebase: '
                 'please commit or shelve your changes first'))
 
@@ -1949,8 +1949,7 @@
     entry[1].append(('t', 'tool', '',
                      _("specify merge tool for rebase")))
     cmdutil.summaryhooks.add('rebase', summaryhook)
-    cmdutil.unfinishedstates.append(
-        ['rebasestate', False, False, _('rebase in progress'),
-         _("use 'hg rebase --continue' or 'hg rebase --abort'")])
+    statemod.unfinishedstates.append(statemod.statecheck('rebase',
+    'rebasestate', clearable=False, allowcommit=False, stopflag=False))
     cmdutil.afterresolvedstates.append(
         ['rebasestate', _('hg rebase --continue')])
diff --git a/hgext/phabricator.py b/hgext/phabricator.py
--- a/hgext/phabricator.py
+++ b/hgext/phabricator.py
@@ -64,6 +64,7 @@
     registrar,
     scmutil,
     smartset,
+    state as statemod,
     tags,
     templatefilters,
     templateutil,
@@ -534,7 +535,7 @@
     if not revs:
         raise error.Abort(_(b'phabsend requires at least one changeset'))
     if opts.get(b'amend'):
-        cmdutil.checkunfinished(repo)
+        statemod.checkunfinished(repo)
 
     # {newnode: (oldnode, olddiff, olddrev}
     oldmap = getoldnodedrevmap(repo, [repo[r].node() for r in revs])
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1508,7 +1508,7 @@
     try:
         keep = opts.get('keep')
         revs = opts.get('rev', [])[:]
-        cmdutil.checkunfinished(repo)
+        statemod.checkunfinished(repo)
         cmdutil.bailifchanged(repo)
 
         if os.path.exists(os.path.join(repo.path, 'histedit-state')):
@@ -1940,7 +1940,7 @@
     rules = opts.get('commands', '')
     force = opts.get('force')
 
-    cmdutil.checkunfinished(repo)
+    statemod.checkunfinished(repo)
     cmdutil.bailifchanged(repo)
 
     topmost = repo.dirstate.p1()
@@ -2313,8 +2313,7 @@
 
 def extsetup(ui):
     cmdutil.summaryhooks.add('histedit', summaryhook)
-    cmdutil.unfinishedstates.append(
-        ['histedit-state', False, True, _('histedit in progress'),
-         _("use 'hg histedit --continue' or 'hg histedit --abort'")])
+    statemod.unfinishedstates.append(statemod.statecheck('histedit',
+    'histedit-state', clearable=False, allowcommit=True, stopflag=False))
     cmdutil.afterresolvedstates.append(
         ['histedit-state', _('hg histedit --continue')])
diff --git a/hgext/fix.py b/hgext/fix.py
--- a/hgext/fix.py
+++ b/hgext/fix.py
@@ -132,6 +132,7 @@
     pycompat,
     registrar,
     scmutil,
+    state as statemod,
     util,
     worker,
 )
@@ -349,7 +350,7 @@
     for rev in revs:
         checkfixablectx(ui, repo, repo[rev])
     if revs:
-        cmdutil.checkunfinished(repo)
+        statemod.checkunfinished(repo)
         checknodescendants(repo, revs)
     if opts.get('working_dir'):
         revs.add(wdirrev)
diff --git a/hgext/absorb.py b/hgext/absorb.py
--- a/hgext/absorb.py
+++ b/hgext/absorb.py
@@ -51,6 +51,7 @@
     pycompat,
     registrar,
     scmutil,
+    state as statemod,
     util,
 )
 from mercurial.utils import (
@@ -1011,7 +1012,7 @@
 
     with repo.wlock(), repo.lock():
         if not opts['dry_run']:
-            cmdutil.checkunfinished(repo)
+            statemod.checkunfinished(repo)
 
         state = absorb(ui, repo, pats=pats, opts=opts)
         if sum(s[0] for s in state.chunkstats.values()) == 0:



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


More information about the Mercurial-devel mailing list