comparison mercurial/sshserver.py @ 35705:8cdb671dbd0b

wireproto: drop support for reader interface from streamres (API) 2add671bf55b and later commits overhauled support for compression and output handling in the wire protocol. Fast forward 14 months and all wire protocol commands except the legacy "changegroup" and "changegroupsubset" commands feed a generator to streamres. I no longer think it is worth maintaining support for the old "reader" API (which allows you to specify an object having a read() method to obtain data). This commit refactors the legacy wire protocol commands to feed a generator to the streamres. We also drop support for the "reader" argument and the code that was using it. As part of the change, chunks over the SSH protocol have increased in size for these commands. But these commands are really ancient, so I doubt anyone will notice. .. api:: wireproto.streamres.__init__ no longer accepts a "reader" argument. Use the "gen" argument instead. Differential Revision: https://phab.mercurial-scm.org/D1861
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 15 Jan 2018 15:20:02 -0800
parents 5326e4ef1dab
children a39a9df7ecca
comparison
equal deleted inserted replaced
35704:41ef02ba329b 35705:8cdb671dbd0b
74 self.fout.write(v) 74 self.fout.write(v)
75 self.fout.flush() 75 self.fout.flush()
76 76
77 def sendstream(self, source): 77 def sendstream(self, source):
78 write = self.fout.write 78 write = self.fout.write
79 79 for chunk in source.gen:
80 if source.reader:
81 gen = iter(lambda: source.reader.read(4096), '')
82 else:
83 gen = source.gen
84
85 for chunk in gen:
86 write(chunk) 80 write(chunk)
87 self.fout.flush() 81 self.fout.flush()
88 82
89 def sendpushresponse(self, rsp): 83 def sendpushresponse(self, rsp):
90 self.sendresponse('') 84 self.sendresponse('')