changeset 32165:1208b74841ff

dispatch: take over SignalInterrupt handling from scmutil dispatch handles KeyboardInterrupt already. This makes the code more consistent, and makes worker not print "killed!" if it receives SIGTERM in most cases (in rare cases there is still "killed!" printed, which will be fixed by the next patch).
author Jun Wu <quark@fb.com>
date Sat, 22 Apr 2017 15:00:17 -0700
parents 6cacc271ee0a
children 31763785094b
files mercurial/dispatch.py mercurial/scmutil.py
diffstat 2 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dispatch.py	Tue May 02 17:29:01 2017 -0500
+++ b/mercurial/dispatch.py	Sat Apr 22 15:00:17 2017 -0700
@@ -162,9 +162,13 @@
     ret = None
     try:
         ret = _runcatch(req)
-    except KeyboardInterrupt:
+    except KeyboardInterrupt as inst:
         try:
-            req.ui.warn(_("interrupted!\n"))
+            if isinstance(inst, error.SignalInterrupt):
+                msg = _("killed!\n")
+            else:
+                msg = _("interrupted!\n")
+            req.ui.warn(msg)
         except error.SignalInterrupt:
             # maybe pager would quit without consuming all the output, and
             # SIGPIPE was raised. we cannot print anything in this case.
--- a/mercurial/scmutil.py	Tue May 02 17:29:01 2017 -0500
+++ b/mercurial/scmutil.py	Sat Apr 22 15:00:17 2017 -0700
@@ -186,8 +186,6 @@
         ui.warn(_("abort: file censored %s!\n") % inst)
     except error.RevlogError as inst:
         ui.warn(_("abort: %s!\n") % inst)
-    except error.SignalInterrupt:
-        ui.warn(_("killed!\n"))
     except error.InterventionRequired as inst:
         ui.warn("%s\n" % inst)
         if inst.hint: