This is an archive of the discontinued Mercurial Phabricator instance.

stringutil: add function to pretty print an object
ClosedPublic

Authored by indygreg on Mar 30 2018, 5:16 PM.

Details

Summary

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.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

indygreg created this revision.Mar 30 2018, 5:16 PM
durin42 added inline comments.
mercurial/utils/stringutil.py
40

Why this instead of pprint.pformat?

indygreg added inline comments.Apr 3 2018, 12:53 PM
mercurial/utils/stringutil.py
40

Because of differences with b'' in Python 3 :/

durin42 added inline comments.Apr 3 2018, 12:56 PM
mercurial/utils/stringutil.py
40

😭

durin42 accepted this revision.Apr 3 2018, 12:56 PM
This revision is now accepted and ready to land.Apr 3 2018, 12:56 PM
This revision was automatically updated to reflect the committed changes.