[PATCH 2 of 2] cmdserver: mask return code of runcommand in the same way as dispatch.run

Yuya Nishihara yuya at tcha.org
Mon Mar 3 00:59:52 CST 2014


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1393829451 -32400
#      Mon Mar 03 15:50:51 2014 +0900
# Node ID e9b1daa0dd45da91343b1466792b875d24543e09
# Parent  2051c10042dd53ea3a3071e59eb0a33baba0b822
cmdserver: mask return code of runcommand in the same way as dispatch.run

"hg help" does not state that the code for abort is 255, but it's confusing
to have different code between hg command and command server.

Tests of python-hglib 1.2 passed with this change.

diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py
--- a/mercurial/commandserver.py
+++ b/mercurial/commandserver.py
@@ -194,7 +194,7 @@ class server(object):
         req = dispatch.request(args[:], copiedui, self.repo, self.cin,
                                self.cout, self.cerr)
 
-        ret = dispatch.dispatch(req) or 0 # might return None
+        ret = (dispatch.dispatch(req) or 0) & 255 # might return None
 
         # restore old cwd
         if '--cwd' in args:
diff --git a/tests/test-commandserver.py b/tests/test-commandserver.py
--- a/tests/test-commandserver.py
+++ b/tests/test-commandserver.py
@@ -104,6 +104,9 @@ def checkruncommand(server):
     # make sure --config doesn't stick
     runcommand(server, ['id'])
 
+    # negative return code should be masked
+    runcommand(server, ['id', '-runknown'])
+
 def inputeof(server):
     readchannel(server)
     server.stdin.write('runcommand\n')
diff --git a/tests/test-commandserver.py.out b/tests/test-commandserver.py.out
--- a/tests/test-commandserver.py.out
+++ b/tests/test-commandserver.py.out
@@ -43,6 +43,9 @@ 000000000000 tip
 000000000000
  runcommand id
 000000000000 tip
+ runcommand id -runknown
+abort: unknown revision 'unknown'!
+ [255]
 
 testing inputeof:
 


More information about the Mercurial-devel mailing list