Show More
@@ -83,6 +83,7 b' from . import (' | |||||
83 | vfs as vfsmod, |
|
83 | vfs as vfsmod, | |
84 | wireprotoframing, |
|
84 | wireprotoframing, | |
85 | wireprotoserver, |
|
85 | wireprotoserver, | |
|
86 | wireprotov2peer, | |||
86 | ) |
|
87 | ) | |
87 | from .utils import ( |
|
88 | from .utils import ( | |
88 | dateutil, |
|
89 | dateutil, | |
@@ -3012,6 +3013,15 b' def debugwireproto(ui, repo, path=None, ' | |||||
3012 | with peer.commandexecutor() as e: |
|
3013 | with peer.commandexecutor() as e: | |
3013 | res = e.callcommand(command, args).result() |
|
3014 | res = e.callcommand(command, args).result() | |
3014 |
|
3015 | |||
|
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: | |||
3015 | ui.status(_('response: %s\n') % stringutil.pprint(res)) |
|
3025 | ui.status(_('response: %s\n') % stringutil.pprint(res)) | |
3016 |
|
3026 | |||
3017 | elif action == 'batchbegin': |
|
3027 | elif action == 'batchbegin': |
@@ -17,6 +17,26 b' from . import (' | |||||
17 | wireprotoframing, |
|
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 | class clienthandler(object): |
|
40 | class clienthandler(object): | |
21 | """Object to handle higher-level client activities. |
|
41 | """Object to handle higher-level client activities. | |
22 |
|
42 | |||
@@ -48,10 +68,7 b' class clienthandler(object):' | |||||
48 | rid = request.requestid |
|
68 | rid = request.requestid | |
49 | self._requests[rid] = request |
|
69 | self._requests[rid] = request | |
50 | self._futures[rid] = f |
|
70 | self._futures[rid] = f | |
51 |
self._responses[rid] = |
|
71 | self._responses[rid] = commandresponse(rid, command) | |
52 | 'cbor': False, |
|
|||
53 | 'b': util.bytesio(), |
|
|||
54 | } |
|
|||
55 |
|
72 | |||
56 | return iter(()) |
|
73 | return iter(()) | |
57 |
|
74 | |||
@@ -104,28 +121,13 b' class clienthandler(object):' | |||||
104 | response = self._responses[frame.requestid] |
|
121 | response = self._responses[frame.requestid] | |
105 |
|
122 | |||
106 | if action == 'responsedata': |
|
123 | if action == 'responsedata': | |
107 |
response |
|
124 | response.b.write(meta['data']) | |
108 |
|
125 | |||
109 | if meta['cbor']: |
|
126 | if meta['cbor']: | |
110 |
response |
|
127 | response.cbor = True | |
111 |
|
128 | |||
112 | if meta['eos']: |
|
129 | if meta['eos']: | |
113 | if meta['cbor']: |
|
130 | self._futures[frame.requestid].set_result(response) | |
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) |
|
|||
129 |
|
131 | |||
130 | del self._requests[frame.requestid] |
|
132 | del self._requests[frame.requestid] | |
131 | del self._futures[frame.requestid] |
|
133 | del self._futures[frame.requestid] |
General Comments 0
You need to be logged in to leave comments.
Login now