changeset 40328:2c55716f8a1c

wireprotov2: add response type that serializes to indefinite length bytestring This will be needed in a future patch. Differential Revision: https://phab.mercurial-scm.org/D5133
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 16 Oct 2018 21:35:33 +0200
parents 55836a34f41b
children ed55a0077490
files mercurial/wireprotoframing.py mercurial/wireprototypes.py
diffstat 2 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/wireprotoframing.py	Wed Sep 26 14:38:43 2018 -0700
+++ b/mercurial/wireprotoframing.py	Tue Oct 16 21:35:33 2018 +0200
@@ -1146,6 +1146,14 @@
                         for frame in emitter.send(o.data):
                             yield frame
 
+                    elif isinstance(
+                        o, wireprototypes.indefinitebytestringresponse):
+                        for chunk in cborutil.streamencodebytestringfromiter(
+                            o.chunks):
+
+                            for frame in emitter.send(chunk):
+                                yield frame
+
                     # A regular object is CBOR encoded.
                     else:
                         for chunk in cborutil.streamencode(o):
--- a/mercurial/wireprototypes.py	Wed Sep 26 14:38:43 2018 -0700
+++ b/mercurial/wireprototypes.py	Tue Oct 16 21:35:33 2018 +0200
@@ -389,3 +389,12 @@
     fullhashseed = attr.ib(default=None)
     serverdercerts = attr.ib(default=None)
     servercadercerts = attr.ib(default=None)
+
+@attr.s
+class indefinitebytestringresponse(object):
+    """Represents an object to be encoded to an indefinite length bytestring.
+
+    Instances are initialized from an iterable of chunks, with each chunk being
+    a bytes instance.
+    """
+    chunks = attr.ib()