[PATCH 1 of 1] sshserver: add varargs capability

Sune Foldager cryo at cyanite.org
Tue Feb 9 05:56:59 CST 2010


On 09-02-2010 12:47, Dirkjan Ochtman wrote:
> On Tue, Feb 9, 2010 at 12:37, Sune Foldager <cryo at cyanite.org> wrote:
>> The SSH wire protocol is fairly rigid, and allows only a fixed number of
>> arguments for its commands. This capability signals that commands in the form
>> command#argc are accepted, where argc is a non-negative integer (represented as
>> a decimal number) denoting the number of arguments the command has.
>>
>> Future extensions to wire commands can use this to determine if certain
>> optional arguments were sent. Existing commands will work as before regardless
>> of the new command format being used or not.
> 
> Can we have it start talking in terms of JSON objects instead?

I guess we can :-p. That's a bigger change to the protocol; we also send
binary data, so we would only want to use JSON for argument data, I presume.

I suppose we could structure it like this:

commandname#argument-payload-size \n
<JSON argument payload>
[binary data, if applicable]

Or did you have something different in mind?

>>     def do_cmd(self, cmd, **args):
>>         self.ui.debug("sending %s command\n" % cmd)
>> +        if self._varargs:
>> +            cmd = '%s#%d' % (cmd, len(args))
> 
> Why not just check for 'varargs' in self.capabilities here, instead of
> the extra variable?

Optimization ;-). But I don't care either way. It would have to be if
self.capabilities and 'vargs' in self.capabilities... it hurts by
optimization brain a bit.

/Sune


More information about the Mercurial-devel mailing list