diff --git a/mercurial/hgweb/protocol.py b/mercurial/hgweb/protocol.py --- a/mercurial/hgweb/protocol.py +++ b/mercurial/hgweb/protocol.py @@ -175,10 +175,7 @@ req.respond(HTTP_OK, HGTYPE, body=rsp) return [] elif isinstance(rsp, wireproto.streamres): - if rsp.reader: - gen = iter(lambda: rsp.reader.read(32768), '') - else: - gen = rsp.gen + gen = rsp.gen # This code for compression should not be streamres specific. It # is here because we only compress streamres at the moment. diff --git a/mercurial/sshserver.py b/mercurial/sshserver.py --- a/mercurial/sshserver.py +++ b/mercurial/sshserver.py @@ -76,13 +76,7 @@ def sendstream(self, source): write = self.fout.write - - if source.reader: - gen = iter(lambda: source.reader.read(4096), '') - else: - gen = source.gen - - for chunk in gen: + for chunk in source.gen: write(chunk) self.fout.flush() diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py --- a/mercurial/wireproto.py +++ b/mercurial/wireproto.py @@ -520,7 +520,7 @@ The call was successful and the result is a stream. - Accepts either a generator or an object with a ``read(size)`` method. + Accepts a generator containing chunks of data to be sent to the client. ``v1compressible`` indicates whether this data can be compressed to "version 1" clients (technically: HTTP peers using @@ -528,9 +528,8 @@ new commands because new clients should support a more modern compression mechanism. """ - def __init__(self, gen=None, reader=None, v1compressible=False): + def __init__(self, gen=None, v1compressible=False): self.gen = gen - self.reader = reader self.v1compressible = v1compressible class pushres(object): @@ -802,7 +801,8 @@ outgoing = discovery.outgoing(repo, missingroots=nodes, missingheads=repo.heads()) cg = changegroupmod.makechangegroup(repo, outgoing, '01', 'serve') - return streamres(reader=cg, v1compressible=True) + gen = iter(lambda: cg.read(32768), '') + return streamres(gen=gen, v1compressible=True) @wireprotocommand('changegroupsubset', 'bases heads') def changegroupsubset(repo, proto, bases, heads): @@ -811,7 +811,8 @@ outgoing = discovery.outgoing(repo, missingroots=bases, missingheads=heads) cg = changegroupmod.makechangegroup(repo, outgoing, '01', 'serve') - return streamres(reader=cg, v1compressible=True) + gen = iter(lambda: cg.read(32768), '') + return streamres(gen=gen, v1compressible=True) @wireprotocommand('debugwireargs', 'one two *') def debugwireargs(repo, proto, one, two, others):