D6504: statecheck: fix for hint message format

taapas1128 (Taapas Agrawal) phabricator at mercurial-scm.org
Tue Jun 18 13:08:35 EDT 2019


taapas1128 updated this revision to Diff 15585.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6504?vs=15571&id=15585

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6504/new/

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

AFFECTED FILES
  hgext/transplant.py
  mercurial/state.py
  tests/test-graft.t
  tests/test-histedit-fold.t
  tests/test-rebase-conflicts.t
  tests/test-shelve.t
  tests/test-strip.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
@@ -40,8 +40,7 @@
   (branch merge, don't forget to commit)
   $ hg transplant 1
   abort: merge in progress
-  (To continue:    hg commit
-  To abort:       hg merge --abort)
+  (use 'hg commit' or 'hg merge --abort')
   [255]
   $ hg up -qC tip
   $ echo b0 > b1
@@ -489,7 +488,8 @@
   ? foo.rej
   # The repository is in an unfinished *transplant* state.
   
-  # use 'hg transplant --continue' or 'hg update' to abort
+  # To continue:    hg transplant --continue
+  # To abort:       hg update
   
   $ echo fixed > baz
   $ hg transplant --continue
diff --git a/tests/test-strip.t b/tests/test-strip.t
--- a/tests/test-strip.t
+++ b/tests/test-strip.t
@@ -275,8 +275,7 @@
 ##strip not allowed with merge in progress
   $ hg strip 4
   abort: merge in progress
-  (To continue:    hg commit
-  To abort:       hg merge --abort)
+  (use 'hg commit' or 'hg merge --abort')
   [255]
 ##strip allowed --force with merge in progress
   $ hg strip 4 --force
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -375,7 +375,8 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # use 'hg unshelve --continue' or 'hg unshelve --abort'
+  # To continue:    hg unshelve --continue
+  # To abort:       hg unshelve --abort
   
 
 ensure that we have a merge with unresolved conflicts
@@ -1153,8 +1154,7 @@
 -- unshelve should abort otherwise, it'll eat my second parent.
   $ hg unshelve
   abort: merge in progress
-  (To continue:    hg commit
-  To abort:       hg merge --abort)
+  (use 'hg commit' or 'hg merge --abort')
   [255]
 
   $ cd ..
diff --git a/tests/test-rebase-conflicts.t b/tests/test-rebase-conflicts.t
--- a/tests/test-rebase-conflicts.t
+++ b/tests/test-rebase-conflicts.t
@@ -80,7 +80,8 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # use 'hg rebase --continue' or 'hg rebase --abort'
+  # To continue:    hg rebase --continue
+  # To abort:       hg rebase --abort
   
 
 Try to continue without solving the conflict:
diff --git a/tests/test-histedit-fold.t b/tests/test-histedit-fold.t
--- a/tests/test-histedit-fold.t
+++ b/tests/test-histedit-fold.t
@@ -306,7 +306,8 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # use 'hg histedit --continue' or 'hg histedit --abort'
+  # To continue:    hg histedit --continue
+  # To abort:       hg histedit --abort
   
   $ hg resolve -l
   U file
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -279,7 +279,9 @@
   # 
   # To mark files as resolved:  hg resolve --mark FILE
   
-  # 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
   
 
 Commit while interrupted should fail:
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -98,7 +98,7 @@
     """
 
     def __init__(self, opname, fname, clearable=False, allowcommit=False,
-                 cmdmsg="", cmdhint=""):
+                 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.
@@ -110,22 +110,40 @@
         cmdmsg is used to pass a different status message in case standard
         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 use 'hg cmdname --continue' or
-        'hg cmdname --abort'" is not desired.
+        message of the format "To continue: hg cmdname --continue
+        To abort: hg cmdname --abort" is not desired.
+        status hint is used to pass a different status message in case standard
+        message of the format ('To continue:    hg cmdname --continue'
+        'To abort:       hg cmdname --abort') is not desired
+        stopflag is a boolean that determines whether or not a command supports
+        --stop flag
         """
         self._opname = opname
         self._fname = fname
         self._clearable = clearable
         self._allowcommit = allowcommit
         self._cmdhint = cmdhint
+        self._statushint = statushint
         self._cmdmsg = cmdmsg
-
-    def hint(self):
+        self._stopflag = stopflag
+
+    def hint(self, status=False):
         """returns the hint message corresponding to the command"""
-        if not self._cmdhint:
-                return (_("use 'hg %s --continue' or 'hg %s --abort'") %
-                        (self._opname, self._opname))
-        return self._cmdhint
+        if status:
+            if not self._statushint:
+                hint = (_('To continue:    hg %s --continue\n'
+                          'To abort:       hg %s --abort') % (self._opname,
+                           self._opname))
+                if self._stopflag:
+                    hint = hint + (_('\nTo stop:        hg %s --stop') %
+                                (self._opname))
+                return hint
+            return self._statushint
+        else:
+            if not self._cmdhint:
+                    return (_("use 'hg %s --continue' or 'hg %s --abort'") %
+                            (self._opname, self._opname))
+            return self._cmdhint
 
     def msg(self):
         """returns the status message corresponding to the command"""
@@ -155,8 +173,8 @@
         _unfinishedstates.insert(0, statecheckobj)
 
 addunfinished(
-    'graft', fname='graftstate', clearable=True,
-    cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop")
+    'graft', fname='graftstate', clearable=True, stopflag=True,
+    cmdhint=_("use 'hg graft --continue' or 'hg graft --stop' to stop"),
 )
 addunfinished(
     'update',fname='updatestate', clearable=True,
@@ -165,14 +183,15 @@
 )
 addunfinished(
     'bisect', fname='bisect.state', allowcommit=True,
-    cmdhint=_('To mark the changeset good:    hg bisect --good\n'
-              'To mark the changeset bad:     hg bisect --bad\n'
-              'To abort:                      hg bisect --reset\n')
-)
-addunfinished(
-    'merge',fname=None, clearable=True, allowcommit=True,
-    cmdhint=_('To continue:    hg commit\n'
-              'To abort:       hg merge --abort')
+    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')
+)
+addunfinished(
+    'merge', fname=None, clearable=True, allowcommit=True,
+    statushint=_('To continue:    hg commit\n'
+                 'To abort:       hg merge --abort'),
+    cmdhint=_("use 'hg commit' or 'hg merge --abort'")
 )
 
 def checkunfinished(repo, commit=False, mergeskip=False):
@@ -219,4 +238,4 @@
         if state._opname in skip:
             continue
         if state.isunfinished(repo):
-            return (state._opname, state.hint())
+            return (state._opname, state.hint(status=True))
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -760,6 +760,8 @@
 def extsetup(ui):
     statemod.addunfinished (
         'transplant', fname='transplant/journal', clearable=True,
+        statushint=_('To continue:    hg transplant --continue\n'
+                     'To abort:       hg update'),
         cmdhint=_("use 'hg transplant --continue' or 'hg update' to abort")
     )
 



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


More information about the Mercurial-devel mailing list