Mercurial > hg
diff 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 |
line wrap: on
line diff
--- a/mercurial/debugcommands.py Sat Apr 14 11:50:19 2018 -0700 +++ b/mercurial/debugcommands.py Sat Apr 14 11:46:08 2018 -0700 @@ -83,6 +83,7 @@ vfs as vfsmod, wireprotoframing, wireprotoserver, + wireprotov2peer, ) from .utils import ( dateutil, @@ -3012,7 +3013,16 @@ with peer.commandexecutor() as e: res = e.callcommand(command, args).result() - ui.status(_('response: %s\n') % stringutil.pprint(res)) + if isinstance(res, wireprotov2peer.commandresponse): + if res.cbor: + val = list(res.cborobjects()) + else: + val = [res.b.getvalue()] + + ui.status(_('response: %s\n') % stringutil.pprint(val)) + + else: + ui.status(_('response: %s\n') % stringutil.pprint(res)) elif action == 'batchbegin': if batchedcommands is not None: