[PATCH 9 of 9] chgserver: implement a simple "runcommand"

Jun Wu quark at fb.com
Sun Nov 13 16:55:53 EST 2016


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1479073486 0
#      Sun Nov 13 21:44:46 2016 +0000
# Node ID b923b234b9032cdd87e6519dae7fbfdd292b7b40
# Parent  4660680374d24f7d46834b54de2fbbeec164e906
chgserver: implement a simple "runcommand"

Although the chgserver could just use command server's runcommand. The new
design could be very simple - no need to do ui copying etc. So let's write
it down explicitly to use the simple version.

Future patches improving the pager area also requires a different
"runcommand" from the "commandserver" version.

diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py
--- a/mercurial/chgserver.py
+++ b/mercurial/chgserver.py
@@ -438,4 +438,12 @@ class chgcmdserver(commandserver.server)
         os.chdir(path)
 
+    def runcommand(self):
+        """Reads a list of \0 terminated arguments, executes and writes the
+        return code to the result channel"""
+        args = self._readlist()
+        req = dispatch.request(args[:])
+        ret = (dispatch.dispatch(req) or 0) & 255 # might return None
+        self.cresult.write(struct.pack('>i', int(ret)))
+
     def setumask(self):
         """Change umask"""
@@ -461,4 +469,5 @@ class chgcmdserver(commandserver.server)
     capabilities.update({'attachio': attachio,
                          'chdir': chdir,
+                         'runcommand': runcommand,
                          'setenv': setenv,
                          'setumask': setumask})


More information about the Mercurial-devel mailing list