Mercurial > public > mercurial-scm > hg
comparison mercurial/debugcommands.py @ 37300:2f859ad7ed8c
stringutil: add function to pretty print an object
This is inspired by the pprint() module/function (which we can't
use because the output is different on Python 2 and 3 - namely the
use of b'' literals).
We hook it up to `hg debugwireproto` for printing the response to
a wire protocol command.
This foreshadows future peer work, which will support decoding
CBOR responses into rich data structures.
Differential Revision: https://phab.mercurial-scm.org/D2987
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 28 Mar 2018 14:52:57 -0700 |
parents | cc5a040fe150 |
children | a67fd1fe5109 |
comparison
equal
deleted
inserted
replaced
37299:e9aadee698cf | 37300:2f859ad7ed8c |
---|---|
2967 ui.status(_('result: %s\n') % stringutil.escapedata(res)) | 2967 ui.status(_('result: %s\n') % stringutil.escapedata(res)) |
2968 ui.status(_('remote output: %s\n') % | 2968 ui.status(_('remote output: %s\n') % |
2969 stringutil.escapedata(output)) | 2969 stringutil.escapedata(output)) |
2970 else: | 2970 else: |
2971 res = peer._call(command, **pycompat.strkwargs(args)) | 2971 res = peer._call(command, **pycompat.strkwargs(args)) |
2972 ui.status(_('response: %s\n') % stringutil.escapedata(res)) | 2972 ui.status(_('response: %s\n') % stringutil.pprint(res)) |
2973 | 2973 |
2974 elif action == 'batchbegin': | 2974 elif action == 'batchbegin': |
2975 if batchedcommands is not None: | 2975 if batchedcommands is not None: |
2976 raise error.Abort(_('nested batchbegin not allowed')) | 2976 raise error.Abort(_('nested batchbegin not allowed')) |
2977 | 2977 |