diff --git a/contrib/chg/hgclient.c b/contrib/chg/hgclient.c --- a/contrib/chg/hgclient.c +++ b/contrib/chg/hgclient.c @@ -237,10 +237,10 @@ static void handlesystemrequest(hgclient ctx->data[ctx->datasize] = '\0'; /* terminate last string */ const char **args = unpackcmdargsnul(ctx); - if (!args[0] || !args[1]) - abortmsg("missing command or cwd in system request"); - debugmsg("run '%s' at '%s'", args[0], args[1]); - int32_t r = runshellcmd(args[0], args + 2, args[1]); + if (!args[0] || !args[1] || !args[2]) + abortmsg("missing type or command or cwd in system request"); + debugmsg("run '%s' at '%s'", args[1], args[2]); + int32_t r = runshellcmd(args[1], args + 3, args[2]); free(args); uint32_t r_n = htonl(r); diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py --- a/mercurial/chgserver.py +++ b/mercurial/chgserver.py @@ -287,13 +287,14 @@ class channeledsystem(object): """Propagate ui.system() request in the following format: payload length (unsigned int), + type, '\0', cmd, '\0', cwd, '\0', envkey, '=', val, '\0', ... envkey, '=', val - and waits: + if type == 'system', waits for: exitcode length (unsigned int), exitcode (int) @@ -303,8 +304,8 @@ class channeledsystem(object): self.out = out self.channel = channel - def __call__(self, cmd, environ, cwd): - args = [util.quotecommand(cmd), os.path.abspath(cwd or '.')] + def __call__(self, cmd, environ, cwd, type='system'): + args = [type, util.quotecommand(cmd), os.path.abspath(cwd or '.')] args.extend('%s=%s' % (k, v) for k, v in environ.iteritems()) data = '\0'.join(args) self.out.write(struct.pack('>cI', self.channel, len(data)))