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

login
register
mail settings
Submitter Yuya Nishihara
Date March 3, 2014, 6:59 a.m.
Message ID <e9b1daa0dd45da91343b.1393829992@gimlet>
Download mbox | patch
Permalink /patch/3832/
State Accepted
Commit 5d4606bec54ca81274ac3d70e48c7d01f0209e23
Headers show

Comments

Yuya Nishihara - March 3, 2014, 6:59 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.
Matt Mackall - March 3, 2014, 8:38 p.m.
On Mon, 2014-03-03 at 15:59 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@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

These are queued for default, thanks.

Patch

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: