changeset 38065:c3fd9a0f8277

dispatch: mask negative exit code recorded in blackbox log That's what we do for the exit code delivered to the environment.
author Yuya Nishihara <yuya@tcha.org>
date Wed, 16 May 2018 20:22:23 +0900
parents 48853a927757
children f5a1aa8c6987
files mercurial/dispatch.py tests/test-blackbox.t
diffstat 2 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dispatch.py	Wed May 16 20:17:50 2018 +0900
+++ b/mercurial/dispatch.py	Wed May 16 20:22:23 2018 +0900
@@ -239,7 +239,7 @@
             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
--- a/tests/test-blackbox.t	Wed May 16 20:17:50 2018 +0900
+++ b/tests/test-blackbox.t	Wed May 16 20:22:23 2018 +0900
@@ -7,6 +7,9 @@
   > @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 @@
   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