cmdserver: mask return code of runcommand in the same way as dispatch.run
authorYuya Nishihara <yuya@tcha.org>
Mon, 03 Mar 2014 15:50:51 +0900
changeset 20631 5d4606bec54c
parent 20630 0b04ee8e789d
child 20632 e993f065e17c
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.
mercurial/commandserver.py
tests/test-commandserver.py
tests/test-commandserver.py.out
--- a/mercurial/commandserver.py	Mon Mar 03 15:50:48 2014 +0900
+++ b/mercurial/commandserver.py	Mon Mar 03 15:50:51 2014 +0900
@@ -193,7 +193,7 @@
         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:
--- a/tests/test-commandserver.py	Mon Mar 03 15:50:48 2014 +0900
+++ b/tests/test-commandserver.py	Mon Mar 03 15:50:51 2014 +0900
@@ -104,6 +104,9 @@
     # 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')
--- a/tests/test-commandserver.py.out	Mon Mar 03 15:50:48 2014 +0900
+++ b/tests/test-commandserver.py.out	Mon Mar 03 15:50:51 2014 +0900
@@ -43,6 +43,9 @@
 000000000000
  runcommand id
 000000000000 tip
+ runcommand id -runknown
+abort: unknown revision 'unknown'!
+ [255]
 
 testing inputeof: