Show More
@@ -83,6 +83,7 b' from . import (' | |||
|
83 | 83 | vfs as vfsmod, |
|
84 | 84 | wireprotoframing, |
|
85 | 85 | wireprotoserver, |
|
86 | wireprotov2peer, | |
|
86 | 87 | ) |
|
87 | 88 | from .utils import ( |
|
88 | 89 | dateutil, |
@@ -3012,7 +3013,16 b' def debugwireproto(ui, repo, path=None, ' | |||
|
3012 | 3013 | with peer.commandexecutor() as e: |
|
3013 | 3014 | res = e.callcommand(command, args).result() |
|
3014 | 3015 | |
|
3015 | ui.status(_('response: %s\n') % stringutil.pprint(res)) | |
|
3016 | if isinstance(res, wireprotov2peer.commandresponse): | |
|
3017 | if res.cbor: | |
|
3018 | val = list(res.cborobjects()) | |
|
3019 | else: | |
|
3020 | val = [res.b.getvalue()] | |
|
3021 | ||
|
3022 | ui.status(_('response: %s\n') % stringutil.pprint(val)) | |
|
3023 | ||
|
3024 | else: | |
|
3025 | ui.status(_('response: %s\n') % stringutil.pprint(res)) | |
|
3016 | 3026 | |
|
3017 | 3027 | elif action == 'batchbegin': |
|
3018 | 3028 | if batchedcommands is not None: |
@@ -17,6 +17,26 b' from . import (' | |||
|
17 | 17 | wireprotoframing, |
|
18 | 18 | ) |
|
19 | 19 | |
|
20 | class commandresponse(object): | |
|
21 | """Represents the response to a command request.""" | |
|
22 | ||
|
23 | def __init__(self, requestid, command): | |
|
24 | self.requestid = requestid | |
|
25 | self.command = command | |
|
26 | ||
|
27 | self.cbor = False | |
|
28 | self.b = util.bytesio() | |
|
29 | ||
|
30 | def cborobjects(self): | |
|
31 | """Obtain decoded CBOR objects from this response.""" | |
|
32 | size = self.b.tell() | |
|
33 | self.b.seek(0) | |
|
34 | ||
|
35 | decoder = cbor.CBORDecoder(self.b) | |
|
36 | ||
|
37 | while self.b.tell() < size: | |
|
38 | yield decoder.decode() | |
|
39 | ||
|
20 | 40 | class clienthandler(object): |
|
21 | 41 | """Object to handle higher-level client activities. |
|
22 | 42 | |
@@ -48,10 +68,7 b' class clienthandler(object):' | |||
|
48 | 68 | rid = request.requestid |
|
49 | 69 | self._requests[rid] = request |
|
50 | 70 | self._futures[rid] = f |
|
51 |
self._responses[rid] = |
|
|
52 | 'cbor': False, | |
|
53 | 'b': util.bytesio(), | |
|
54 | } | |
|
71 | self._responses[rid] = commandresponse(rid, command) | |
|
55 | 72 | |
|
56 | 73 | return iter(()) |
|
57 | 74 | |
@@ -104,28 +121,13 b' class clienthandler(object):' | |||
|
104 | 121 | response = self._responses[frame.requestid] |
|
105 | 122 | |
|
106 | 123 | if action == 'responsedata': |
|
107 |
response |
|
|
124 | response.b.write(meta['data']) | |
|
108 | 125 | |
|
109 | 126 | if meta['cbor']: |
|
110 |
response |
|
|
127 | response.cbor = True | |
|
111 | 128 | |
|
112 | 129 | if meta['eos']: |
|
113 | if meta['cbor']: | |
|
114 | # If CBOR, decode every object. | |
|
115 | b = response['b'] | |
|
116 | ||
|
117 | size = b.tell() | |
|
118 | b.seek(0) | |
|
119 | ||
|
120 | decoder = cbor.CBORDecoder(b) | |
|
121 | ||
|
122 | result = [] | |
|
123 | while b.tell() < size: | |
|
124 | result.append(decoder.decode()) | |
|
125 | else: | |
|
126 | result = [response['b'].getvalue()] | |
|
127 | ||
|
128 | self._futures[frame.requestid].set_result(result) | |
|
130 | self._futures[frame.requestid].set_result(response) | |
|
129 | 131 | |
|
130 | 132 | del self._requests[frame.requestid] |
|
131 | 133 | del self._futures[frame.requestid] |
General Comments 0
You need to be logged in to leave comments.
Login now