Patchwork [1,of,4] dispatch: take over SignalInterrupt handling from scmutil

login
register
mail settings
Submitter Jun Wu
Date May 3, 2017, 12:09 a.m.
Message ID <59296cf853f194570bfa.1493770175@x1c>
Download mbox | patch
Permalink /patch/20371/
State Accepted
Headers show

Comments

Jun Wu - May 3, 2017, 12:09 a.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1492898417 25200
#      Sat Apr 22 15:00:17 2017 -0700
# Node ID 59296cf853f194570bfa4e714e412c427851c4ca
# Parent  6cacc271ee0a9385be483314dc73be176a13c891
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 59296cf853f1
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).
Yuya Nishihara - May 3, 2017, 1:46 a.m.
On Tue, 2 May 2017 17:09:35 -0700, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark@fb.com>
> # Date 1492898417 25200
> #      Sat Apr 22 15:00:17 2017 -0700
> # Node ID 59296cf853f194570bfa4e714e412c427851c4ca
> # Parent  6cacc271ee0a9385be483314dc73be176a13c891
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r 59296cf853f1
> dispatch: take over SignalInterrupt handling from scmutil

Queued these, thanks.

Patch

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -163,7 +163,11 @@  def dispatch(req):
     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
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -187,6 +187,4 @@  def callcatch(ui, func):
     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)