Patchwork [2,of,2] dispatch: mask negative exit code recorded in blackbox log

login
register
mail settings
Submitter Yuya Nishihara
Date May 16, 2018, 12:19 p.m.
Message ID <a548e75b75e778f26a50.1526473178@mimosa>
Download mbox | patch
Permalink /patch/31626/
State Accepted
Headers show

Comments

Yuya Nishihara - May 16, 2018, 12:19 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1526469743 -32400
#      Wed May 16 20:22:23 2018 +0900
# Node ID a548e75b75e778f26a50b429fc7b31618cc34d3f
# Parent  d5956b687bbc39c686390b45d08caea976b8b7dd
dispatch: mask negative exit code recorded in blackbox log

That's what we do for the exit code delivered to the environment.
via Mercurial-devel - May 16, 2018, 4:38 p.m.
On Wed, May 16, 2018 at 5:19 AM Yuya Nishihara <yuya@tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1526469743 -32400
> #      Wed May 16 20:22:23 2018 +0900
> # Node ID a548e75b75e778f26a50b429fc7b31618cc34d3f
> # Parent  d5956b687bbc39c686390b45d08caea976b8b7dd
> dispatch: mask negative exit code recorded in blackbox log
>

Queued, thanks!

Patch

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -239,7 +239,7 @@  def dispatch(req):
             req.ui.log('uiblocked', 'ui blocked ms',
                        **pycompat.strkwargs(req.ui._blockedtimes))
         req.ui.log("commandfinish", "%s exited %d after %0.2f seconds\n",
-                   msg, ret, duration)
+                   msg, ret & 255, duration)
         try:
             req._runexithandlers()
         except: # exiting, so no re-raises
diff --git a/tests/test-blackbox.t b/tests/test-blackbox.t
--- a/tests/test-blackbox.t
+++ b/tests/test-blackbox.t
@@ -7,6 +7,9 @@  setup
   > @command(b'crash', [], b'hg crash')
   > def crash(ui, *args, **kwargs):
   >     raise Exception("oops")
+  > @command(b'abort', [], b'hg abort')
+  > def abort(ui, *args, **kwargs):
+  >     raise error.Abort(b"oops")
   > EOF
   $ abspath=`pwd`/myextension.py
 
@@ -44,6 +47,14 @@  failure exit code
   1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add non-existent exited 1 after * seconds (glob)
   1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
 
+abort exit code
+  $ rm ./.hg/blackbox.log
+  $ hg abort 2> /dev/null
+  [255]
+  $ hg blackbox -l 2
+  1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> abort exited 255 after * seconds (glob)
+  1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox -l 2
+
 unhandled exception
   $ rm ./.hg/blackbox.log
   $ hg crash 2> /dev/null