##// END OF EJS Templates
py3: factor out byterepr() which returns an asciified value on py3
Yuya Nishihara -
r36279:b44fac3a default
parent child Browse files
Show More
@@ -291,7 +291,7 b' class debugformatter(baseformatter):'
291 self._out = out
291 self._out = out
292 self._out.write("%s = [\n" % self._topic)
292 self._out.write("%s = [\n" % self._topic)
293 def _showitem(self):
293 def _showitem(self):
294 self._out.write(' %s,\n' % pycompat.sysbytes(repr(self._item)))
294 self._out.write(' %s,\n' % pycompat.byterepr(self._item))
295 def end(self):
295 def end(self):
296 baseformatter.end(self)
296 baseformatter.end(self)
297 self._out.write("]\n")
297 self._out.write("]\n")
@@ -85,6 +85,7 b' if ispy3:'
85 sysargv = list(map(os.fsencode, sys.argv))
85 sysargv = list(map(os.fsencode, sys.argv))
86
86
87 bytechr = struct.Struct('>B').pack
87 bytechr = struct.Struct('>B').pack
88 byterepr = b'%r'.__mod__
88
89
89 class bytestr(bytes):
90 class bytestr(bytes):
90 """A bytes which mostly acts as a Python 2 str
91 """A bytes which mostly acts as a Python 2 str
@@ -277,6 +278,7 b' else:'
277 import cStringIO
278 import cStringIO
278
279
279 bytechr = chr
280 bytechr = chr
281 byterepr = repr
280 bytestr = str
282 bytestr = str
281 iterbytestr = iter
283 iterbytestr = iter
282 maybebytestr = identity
284 maybebytestr = identity
@@ -35,7 +35,7 b' def _formatsetrepr(r):'
35 elif callable(r):
35 elif callable(r):
36 return r()
36 return r()
37 else:
37 else:
38 return pycompat.sysbytes(repr(r))
38 return pycompat.byterepr(r)
39
39
40 def _typename(o):
40 def _typename(o):
41 return pycompat.sysbytes(type(o).__name__).lstrip('_')
41 return pycompat.sysbytes(type(o).__name__).lstrip('_')
@@ -400,7 +400,7 b' class baseset(abstractsmartset):'
400 # We fallback to the sorted version for a stable output.
400 # We fallback to the sorted version for a stable output.
401 if self._ascending is not None:
401 if self._ascending is not None:
402 l = self._asclist
402 l = self._asclist
403 s = pycompat.sysbytes(repr(l))
403 s = pycompat.byterepr(l)
404 return '<%s%s %s>' % (_typename(self), d, s)
404 return '<%s%s %s>' % (_typename(self), d, s)
405
405
406 class filteredset(abstractsmartset):
406 class filteredset(abstractsmartset):
@@ -513,7 +513,7 b' class filteredset(abstractsmartset):'
513
513
514 @encoding.strmethod
514 @encoding.strmethod
515 def __repr__(self):
515 def __repr__(self):
516 xs = [pycompat.sysbytes(repr(self._subset))]
516 xs = [pycompat.byterepr(self._subset)]
517 s = _formatsetrepr(self._condrepr)
517 s = _formatsetrepr(self._condrepr)
518 if s:
518 if s:
519 xs.append(s)
519 xs.append(s)
@@ -1132,7 +1132,7 b' class fullreposet(_spanset):'
1132
1132
1133 def prettyformat(revs):
1133 def prettyformat(revs):
1134 lines = []
1134 lines = []
1135 rs = pycompat.sysbytes(repr(revs))
1135 rs = pycompat.byterepr(revs)
1136 p = 0
1136 p = 0
1137 while p < len(rs):
1137 while p < len(rs):
1138 q = rs.find('<', p + 1)
1138 q = rs.find('<', p + 1)
General Comments 0
You need to be logged in to leave comments. Login now