Patchwork D1861: wireproto: drop support for reader interface from streamres (API)

login
register
mail settings
Submitter phabricator
Date Jan. 18, 2018, 1:41 p.m.
Message ID <10c6937c9ef40db0c1c54b8549b72317@localhost.localdomain>
Download mbox | patch
Permalink /patch/26892/
State Not Applicable
Headers show

Comments

phabricator - Jan. 18, 2018, 1:41 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG8cdb671dbd0b: wireproto: drop support for reader interface from streamres (API) (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1861?vs=4836&id=4894

REVISION DETAIL
  https://phab.mercurial-scm.org/D1861

AFFECTED FILES
  mercurial/hgweb/protocol.py
  mercurial/sshserver.py
  mercurial/wireproto.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -520,17 +520,16 @@ 
 
     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
     application/mercurial-0.1 media type). This flag should NOT be used on
     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,16 +801,18 @@ 
     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):
     bases = decodelist(bases)
     heads = decodelist(heads)
     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):
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/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.