compat: fix `setupevolveunfinished` for upstream
authorSushil khanchi <sushilkhanchi97@gmail.com>
Sun, 30 Jun 2019 23:50:57 +0530
changeset 4696 7ac40b4ea24c
parent 4695 4c9f9dac8977
child 4697 cba3db7d7e96
compat: fix `setupevolveunfinished` for upstream
hgext3rd/evolve/__init__.py
--- a/hgext3rd/evolve/__init__.py	Sun Jun 16 23:39:55 2019 +0530
+++ b/hgext3rd/evolve/__init__.py	Sun Jun 30 23:50:57 2019 +0530
@@ -280,6 +280,7 @@
     patch,
     revset,
     scmutil,
+    state as statemod,
 )
 
 from mercurial.i18n import _
@@ -1355,14 +1356,28 @@
 
 @eh.uisetup
 def setupevolveunfinished(ui):
-    data = ('evolvestate', False, False, _('evolve in progress'),
-            _("use 'hg evolve --continue' or 'hg evolve --abort' to abort"))
-    cmdutil.unfinishedstates.append(data)
+    if not util.safehasattr(cmdutil, 'unfinishedstates'):
+        _msg = _('To continue:    hg evolve --continue\n'
+                 'To abort:       hg evolve --abort\n'
+                 'To stop:        hg evolve --stop\n'
+                 '(also see `hg help evolve.interrupted`)')
+        statemod.addunfinished('evolve', fname='evolvestate',
+                               continueflag=True, stopflag=True,
+                               cmdmsg=_('evolve in progress'),
+                               cmdhint=_("use 'hg evolve --continue' or "
+                                         "'hg evolve --abort' to abort"),
+                               statushint=_msg)
+        statemod.addunfinished('pick', fname='pickstate', continueflag=True)
+    else:
+        # compat <= hg-5.0 (5f2f6912c9e6)
+        data = ('evolvestate', False, False, _('evolve in progress'),
+                _("use 'hg evolve --continue' or 'hg evolve --abort' to abort"))
+        cmdutil.unfinishedstates.append(data)
 
-    afterresolved = ('evolvestate', _('hg evolve --continue'))
-    pickresolved = ('pickstate', _('hg pick --continue'))
-    cmdutil.afterresolvedstates.append(afterresolved)
-    cmdutil.afterresolvedstates.append(pickresolved)
+        afterresolved = ('evolvestate', _('hg evolve --continue'))
+        pickresolved = ('pickstate', _('hg pick --continue'))
+        cmdutil.afterresolvedstates.append(afterresolved)
+        cmdutil.afterresolvedstates.append(pickresolved)
 
     if util.safehasattr(cmdutil, 'STATES'):
         statedata = ('evolve', cmdutil.fileexistspredicate('evolvestate'),