Mercurial > hg
changeset 36265:b44fac3a49fb
py3: factor out byterepr() which returns an asciified value on py3
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 17 Feb 2018 18:09:56 +0900 |
parents | 18e29c65bc5c |
children | 1fa33bd848ee |
files | mercurial/formatter.py mercurial/pycompat.py mercurial/smartset.py |
diffstat | 3 files changed, 7 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/formatter.py Thu Feb 15 17:14:45 2018 +0530 +++ b/mercurial/formatter.py Sat Feb 17 18:09:56 2018 +0900 @@ -291,7 +291,7 @@ self._out = out self._out.write("%s = [\n" % self._topic) def _showitem(self): - self._out.write(' %s,\n' % pycompat.sysbytes(repr(self._item))) + self._out.write(' %s,\n' % pycompat.byterepr(self._item)) def end(self): baseformatter.end(self) self._out.write("]\n")
--- a/mercurial/pycompat.py Thu Feb 15 17:14:45 2018 +0530 +++ b/mercurial/pycompat.py Sat Feb 17 18:09:56 2018 +0900 @@ -85,6 +85,7 @@ sysargv = list(map(os.fsencode, sys.argv)) bytechr = struct.Struct('>B').pack + byterepr = b'%r'.__mod__ class bytestr(bytes): """A bytes which mostly acts as a Python 2 str @@ -277,6 +278,7 @@ import cStringIO bytechr = chr + byterepr = repr bytestr = str iterbytestr = iter maybebytestr = identity
--- a/mercurial/smartset.py Thu Feb 15 17:14:45 2018 +0530 +++ b/mercurial/smartset.py Sat Feb 17 18:09:56 2018 +0900 @@ -35,7 +35,7 @@ elif callable(r): return r() else: - return pycompat.sysbytes(repr(r)) + return pycompat.byterepr(r) def _typename(o): return pycompat.sysbytes(type(o).__name__).lstrip('_') @@ -400,7 +400,7 @@ # We fallback to the sorted version for a stable output. if self._ascending is not None: l = self._asclist - s = pycompat.sysbytes(repr(l)) + s = pycompat.byterepr(l) return '<%s%s %s>' % (_typename(self), d, s) class filteredset(abstractsmartset): @@ -513,7 +513,7 @@ @encoding.strmethod def __repr__(self): - xs = [pycompat.sysbytes(repr(self._subset))] + xs = [pycompat.byterepr(self._subset)] s = _formatsetrepr(self._condrepr) if s: xs.append(s) @@ -1132,7 +1132,7 @@ def prettyformat(revs): lines = [] - rs = pycompat.sysbytes(repr(revs)) + rs = pycompat.byterepr(revs) p = 0 while p < len(rs): q = rs.find('<', p + 1)