changeset 42529:5f2f6912c9e6

states: moved cmdutil.unfinishedstates to state.py This moves `cmdutil.unfinishedstates`, `checkunfinished()`,`clearunfinished()` to `state.py`. the already existing users of this module are updated accordingly. Test results remain unchanged. Differential Revision: https://phab.mercurial-scm.org/D6484
author Taapas Agrawal <taapas2897@gmail.com>
date Sat, 08 Jun 2019 23:43:53 +0530
parents e079e001d536
children dc3fdd1b5af4
files hgext/histedit.py hgext/rebase.py hgext/shelve.py hgext/transplant.py mercurial/cmdutil.py mercurial/commands.py mercurial/state.py
diffstat 7 files changed, 25 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/histedit.py	Mon Jun 24 16:01:22 2019 -0700
+++ b/hgext/histedit.py	Sat Jun 08 23:43:53 2019 +0530
@@ -2313,7 +2313,7 @@
 
 def extsetup(ui):
     cmdutil.summaryhooks.add('histedit', summaryhook)
-    cmdutil.unfinishedstates.append(
+    statemod.unfinishedstates.append(
         ['histedit-state', False, True, _('histedit in progress'),
          _("use 'hg histedit --continue' or 'hg histedit --abort'")])
     cmdutil.afterresolvedstates.append(
--- a/hgext/rebase.py	Mon Jun 24 16:01:22 2019 -0700
+++ b/hgext/rebase.py	Sat Jun 08 23:43:53 2019 +0530
@@ -1950,7 +1950,7 @@
     entry[1].append(('t', 'tool', '',
                      _("specify merge tool for rebase")))
     cmdutil.summaryhooks.add('rebase', summaryhook)
-    cmdutil.unfinishedstates.append(
+    statemod.unfinishedstates.append(
         ['rebasestate', False, False, _('rebase in progress'),
          _("use 'hg rebase --continue' or 'hg rebase --abort'")])
     cmdutil.afterresolvedstates.append(
--- a/hgext/shelve.py	Mon Jun 24 16:01:22 2019 -0700
+++ b/hgext/shelve.py	Sat Jun 08 23:43:53 2019 +0530
@@ -48,6 +48,7 @@
     registrar,
     repair,
     scmutil,
+    state as statemod,
     templatefilters,
     util,
     vfs as vfsmod,
@@ -1139,9 +1140,10 @@
         return createcmd(ui, repo, pats, opts)
 
 def extsetup(ui):
-    cmdutil.unfinishedstates.append(
+    statemod.unfinishedstates.append(
         [shelvedstate._filename, False, False,
          _('unshelve already in progress'),
          _("use 'hg unshelve --continue' or 'hg unshelve --abort'")])
     cmdutil.afterresolvedstates.append(
         [shelvedstate._filename, _('hg unshelve --continue')])
+
--- a/hgext/transplant.py	Mon Jun 24 16:01:22 2019 -0700
+++ b/hgext/transplant.py	Sat Jun 08 23:43:53 2019 +0530
@@ -35,6 +35,7 @@
     revset,
     scmutil,
     smartset,
+    state as statemod,
     util,
     vfs as vfsmod,
 )
@@ -757,7 +758,7 @@
     return n and nodemod.hex(n) or ''
 
 def extsetup(ui):
-    cmdutil.unfinishedstates.append(
+    statemod.unfinishedstates.append(
         ['transplant/journal', True, False, _('transplant in progress'),
          _("use 'hg transplant --continue' or 'hg update' to abort")])
 
--- a/mercurial/cmdutil.py	Mon Jun 24 16:01:22 2019 -0700
+++ b/mercurial/cmdutil.py	Sat Jun 08 23:43:53 2019 +0530
@@ -42,6 +42,7 @@
     rewriteutil,
     scmutil,
     smartset,
+    state as statemod,
     subrepoutil,
     templatekw,
     templater,
@@ -3313,17 +3314,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
@@ -3331,13 +3321,13 @@
     '''
     # Check for non-clearable states first, so things like rebase will take
     # precedence over update.
-    for f, clearable, allowcommit, msg, hint in unfinishedstates:
+    for f, clearable, allowcommit, msg, hint in statemod.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:
+    for f, clearable, allowcommit, msg, hint in statemod.unfinishedstates:
         if not clearable or (commit and allowcommit):
             continue
         if repo.vfs.exists(f):
@@ -3347,10 +3337,10 @@
     '''Check for unfinished operations (as above), and clear the ones
     that are clearable.
     '''
-    for f, clearable, allowcommit, msg, hint in unfinishedstates:
+    for f, clearable, allowcommit, msg, hint in statemod.unfinishedstates:
         if not clearable and repo.vfs.exists(f):
             raise error.Abort(msg, hint=hint)
-    for f, clearable, allowcommit, msg, hint in unfinishedstates:
+    for f, clearable, allowcommit, msg, hint in statemod.unfinishedstates:
         if clearable and repo.vfs.exists(f):
             util.unlink(repo.vfs.join(f))
 
--- a/mercurial/commands.py	Mon Jun 24 16:01:22 2019 -0700
+++ b/mercurial/commands.py	Sat Jun 08 23:43:53 2019 +0530
@@ -6148,7 +6148,6 @@
 
     with repo.wlock():
         cmdutil.clearunfinished(repo)
-
         if date:
             rev = cmdutil.finddate(ui, repo, date)
 
--- a/mercurial/state.py	Mon Jun 24 16:01:22 2019 -0700
+++ b/mercurial/state.py	Sat Jun 08 23:43:53 2019 +0530
@@ -19,6 +19,8 @@
 
 from __future__ import absolute_import
 
+from .i18n import _
+
 from . import (
     error,
     util,
@@ -85,3 +87,14 @@
     def exists(self):
         """check whether the state file exists or not"""
         return self._repo.vfs.exists(self.fname)
+
+# 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"))
+    ]