Mercurial > public > mercurial-scm > hg
comparison mercurial/debugcommands.py @ 37720:d715a85003c8
wireprotov2: establish a type for representing command response
It will be desirable to have a higher-level type for representing
command responses. This will allow us to do nicer things.
For now, the instance encapsulates existing logic. It is still
a bit primitive. But we're slowly making things better.
Version 1 protocols have a wrapping layer that decodes the raw
string data into a data structure and that data structure is
sent to the future. Version 2 doesn't yet have this layer and
the future is receiving the raw wire response. Hence why
debugcommands needed to be taught about the response type.
Differential Revision: https://phab.mercurial-scm.org/D3380
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 14 Apr 2018 11:46:08 -0700 |
parents | ad1c07008e0b |
children | 89a16704114c |
comparison
equal
deleted
inserted
replaced
37719:a656cba08a04 | 37720:d715a85003c8 |
---|---|
81 url as urlmod, | 81 url as urlmod, |
82 util, | 82 util, |
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, |
89 procutil, | 90 procutil, |
90 stringutil, | 91 stringutil, |
3010 stringutil.escapestr(output)) | 3011 stringutil.escapestr(output)) |
3011 else: | 3012 else: |
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 |
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 elif action == 'batchbegin': | 3027 elif action == 'batchbegin': |
3018 if batchedcommands is not None: | 3028 if batchedcommands is not None: |
3019 raise error.Abort(_('nested batchbegin not allowed')) | 3029 raise error.Abort(_('nested batchbegin not allowed')) |
3020 | 3030 |