From patchwork Wed May 3 00:09:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1,of,4] dispatch: take over SignalInterrupt handling from scmutil From: Jun Wu X-Patchwork-Id: 20371 Message-Id: <59296cf853f194570bfa.1493770175@x1c> To: Date: Tue, 2 May 2017 17:09:35 -0700 # HG changeset patch # User Jun Wu # 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). 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)