[PATCH 05 of 19] dispatch: exit with 8-bit exit code

Mads Kiilerich mads at kiilerich.com
Sun Nov 6 20:40:55 CST 2011


# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1320632093 -3600
# Node ID c8ed4f9ca20ade50ce0e69ed492ba6eb282cac0b
# Parent  d7b0597c09fa77e77083626c9aa350979aebc69b
dispatch: exit with 8-bit exit code

The exit code returned from a program to the shell is unsigned 8-bit, but
Mercurial would sometimes try to exit with negative numbers or None. sys.exit
on Unix will convert that to 8-bit exit codes, but on Windows negative values
showed up as 0.

The exit code is now explicitly converted to unsigned 8-bit.

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -24,7 +24,7 @@
 
 def run():
     "run the command in sys.argv"
-    sys.exit(dispatch(request(sys.argv[1:])))
+    sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
 
 def dispatch(req):
     "run the command specified in req.args"


More information about the Mercurial-devel mailing list