D5133: wireprotov2: add response type that serializes to indefinite length bytestring

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Wed Oct 17 09:46:06 EDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG2c55716f8a1c: wireprotov2: add response type that serializes to indefinite length bytestring (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5133?vs=12195&id=12202

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

AFFECTED FILES
  mercurial/wireprotoframing.py
  mercurial/wireprototypes.py

CHANGE DETAILS

diff --git a/mercurial/wireprototypes.py b/mercurial/wireprototypes.py
--- a/mercurial/wireprototypes.py
+++ b/mercurial/wireprototypes.py
@@ -389,3 +389,12 @@
     fullhashseed = attr.ib(default=None)
     serverdercerts = attr.ib(default=None)
     servercadercerts = attr.ib(default=None)
+
+ at 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()
diff --git a/mercurial/wireprotoframing.py b/mercurial/wireprotoframing.py
--- a/mercurial/wireprotoframing.py
+++ b/mercurial/wireprotoframing.py
@@ -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):



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


More information about the Mercurial-devel mailing list