comparison mercurial/hgweb/protocol.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 0a2ef612ad50
children a39a9df7ecca
comparison
equal deleted inserted replaced
35704:41ef02ba329b 35705:8cdb671dbd0b
173 rsp = wireproto.dispatch(repo, p, cmd) 173 rsp = wireproto.dispatch(repo, p, cmd)
174 if isinstance(rsp, bytes): 174 if isinstance(rsp, bytes):
175 req.respond(HTTP_OK, HGTYPE, body=rsp) 175 req.respond(HTTP_OK, HGTYPE, body=rsp)
176 return [] 176 return []
177 elif isinstance(rsp, wireproto.streamres): 177 elif isinstance(rsp, wireproto.streamres):
178 if rsp.reader: 178 gen = rsp.gen
179 gen = iter(lambda: rsp.reader.read(32768), '')
180 else:
181 gen = rsp.gen
182 179
183 # This code for compression should not be streamres specific. It 180 # This code for compression should not be streamres specific. It
184 # is here because we only compress streamres at the moment. 181 # is here because we only compress streamres at the moment.
185 mediatype, engine, engineopts = p.responsetype(rsp.v1compressible) 182 mediatype, engine, engineopts = p.responsetype(rsp.v1compressible)
186 183