Mercurial > public > mercurial-scm > hg
diff mercurial/debugcommands.py @ 34025:626a28f30dbd
debugcommands: stabilize output of debugbundle by having a custom repr
We handle all dict-like things the same, and don't worry about it
actually being a repr.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Tue, 22 Aug 2017 23:11:35 -0400 |
parents | 9c4e2aa0a239 |
children | 07f09995e857 |
line wrap: on
line diff
--- a/mercurial/debugcommands.py Tue Aug 22 20:25:08 2017 -0400 +++ b/mercurial/debugcommands.py Tue Aug 22 23:11:35 2017 -0400 @@ -7,6 +7,7 @@ from __future__ import absolute_import +import collections import difflib import errno import operator @@ -323,16 +324,22 @@ ui.write(indent_string) ui.write('%s %s\n' % (hex(head), phases.phasenames[phase])) +def _quasirepr(thing): + if isinstance(thing, (dict, util.sortdict, collections.OrderedDict)): + return '{%s}' % ( + b', '.join(b'%s: %s' % (k, thing[k]) for k in sorted(thing))) + return pycompat.bytestr(repr(thing)) + def _debugbundle2(ui, gen, all=None, **opts): """lists the contents of a bundle2""" if not isinstance(gen, bundle2.unbundle20): raise error.Abort(_('not a bundle2 file')) - ui.write(('Stream params: %s\n' % repr(gen.params))) + ui.write(('Stream params: %s\n' % _quasirepr(gen.params))) parttypes = opts.get(r'part_type', []) for part in gen.iterparts(): if parttypes and part.type not in parttypes: continue - ui.write('%s -- %r\n' % (part.type, repr(part.params))) + ui.write('%s -- %s\n' % (part.type, _quasirepr(part.params))) if part.type == 'changegroup': version = part.params.get('version', '01') cg = changegroup.getunbundler(version, part, 'UN')