comparison mercurial/wireprotoserver.py @ 36372:b8d0761a85c7

wireproto: document the wonky push protocol for SSH It took me several minutes to figure out how the "unbundle" protocol worked. It turns out that the SSH protocol handler sends an empty reply that is interpreted as "OK to send" and only then does the client send the bundle payload. On top of that, the response is different depending on whether the operation was successful or not. I nearly pulled out my hair deciphering this. Differential Revision: https://phab.mercurial-scm.org/D2385
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 21 Feb 2018 16:47:39 -0800
parents 0c231df1ffdc
children e7411fb7ba7f
comparison
equal deleted inserted replaced
36371:0c231df1ffdc 36372:b8d0761a85c7
345 val = self._fin.read(int(l)) 345 val = self._fin.read(int(l))
346 data[arg] = val 346 data[arg] = val
347 return [data[k] for k in keys] 347 return [data[k] for k in keys]
348 348
349 def forwardpayload(self, fpout): 349 def forwardpayload(self, fpout):
350 # We initially send an empty response. This tells the client it is
351 # OK to start sending data. If a client sees any other response, it
352 # interprets it as an error.
353 _sshv1respondbytes(self._fout, b'')
354
350 # The file is in the form: 355 # The file is in the form:
351 # 356 #
352 # <chunk size>\n<chunk> 357 # <chunk size>\n<chunk>
353 # ... 358 # ...
354 # 0\n 359 # 0\n
355 _sshv1respondbytes(self._fout, b'')
356 count = int(self._fin.readline()) 360 count = int(self._fin.readline())
357 while count: 361 while count:
358 fpout.write(self._fin.read(count)) 362 fpout.write(self._fin.read(count))
359 count = int(self._fin.readline()) 363 count = int(self._fin.readline())
360 364