Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/utils/stringutil.py @ 39088:2aebe138ef6e
stringutil: teach pprint about sets
This is the old (Python 2) way of printing sets. I actually prefer the
Python 3 version of the repr, but this will result in less test churn
in the short term.
Differential Revision: https://phab.mercurial-scm.org/D4243
author | Augie Fackler <augie@google.com> |
---|---|
date | Fri, 10 Aug 2018 01:41:31 -0400 |
parents | e7aa113b14f7 |
children | 38409be2f521 |
comparison
equal
deleted
inserted
replaced
39087:0a2ce5b43574 | 39088:2aebe138ef6e |
---|---|
57 elif isinstance(o, dict): | 57 elif isinstance(o, dict): |
58 return '{%s}' % (b', '.join( | 58 return '{%s}' % (b', '.join( |
59 '%s: %s' % (pprint(k, bprefix=bprefix), | 59 '%s: %s' % (pprint(k, bprefix=bprefix), |
60 pprint(v, bprefix=bprefix)) | 60 pprint(v, bprefix=bprefix)) |
61 for k, v in sorted(o.items()))) | 61 for k, v in sorted(o.items()))) |
62 elif isinstance(o, set): | |
63 return 'set([%s])' % (b', '.join( | |
64 pprint(k, bprefix=bprefix) for k in sorted(o))) | |
62 elif isinstance(o, tuple): | 65 elif isinstance(o, tuple): |
63 return '(%s)' % (b', '.join(pprint(a, bprefix=bprefix) for a in o)) | 66 return '(%s)' % (b', '.join(pprint(a, bprefix=bprefix) for a in o)) |
64 else: | 67 else: |
65 return pycompat.byterepr(o) | 68 return pycompat.byterepr(o) |
66 | 69 |