comparison mercurial/wireprototypes.py @ 37728:564a3eec6e63

wireprotov2: add support for more response types This adds types to represent error and generator responses from server commands. Differential Revision: https://phab.mercurial-scm.org/D3388
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 15 Apr 2018 10:37:29 -0700
parents 77c9ee77687c
children 352932a11905
comparison
equal deleted inserted replaced
37727:5cdde6158426 37728:564a3eec6e63
104 class cborresponse(object): 104 class cborresponse(object):
105 """Encode the response value as CBOR.""" 105 """Encode the response value as CBOR."""
106 def __init__(self, v): 106 def __init__(self, v):
107 self.value = v 107 self.value = v
108 108
109 class v2errorresponse(object):
110 """Represents a command error for version 2 transports."""
111 def __init__(self, message, args=None):
112 self.message = message
113 self.args = args
114
115 class v2streamingresponse(object):
116 """A response whose data is supplied by a generator.
117
118 The generator can either consist of data structures to CBOR
119 encode or a stream of already-encoded bytes.
120 """
121 def __init__(self, gen, compressible=True):
122 self.gen = gen
123 self.compressible = compressible
124
109 # list of nodes encoding / decoding 125 # list of nodes encoding / decoding
110 def decodelist(l, sep=' '): 126 def decodelist(l, sep=' '):
111 if l: 127 if l:
112 return [bin(v) for v in l.split(sep)] 128 return [bin(v) for v in l.split(sep)]
113 return [] 129 return []