Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 35903:1a31111e6239
py3: always drop b'' prefix from repr() of bytestr
Perhaps this is what we wanted for py2-3 compatibility.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 27 Jan 2018 17:31:25 +0900 |
parents | 72de5c504833 |
children | fc44c2657dc5 |
comparison
equal
deleted
inserted
replaced
35902:2da4144e6716 | 35903:1a31111e6239 |
---|---|
1561 _exportsingle( | 1561 _exportsingle( |
1562 repo, ctx, match, switch_parent, rev, seqno, write, opts) | 1562 repo, ctx, match, switch_parent, rev, seqno, write, opts) |
1563 if fo is not None: | 1563 if fo is not None: |
1564 fo.close() | 1564 fo.close() |
1565 | 1565 |
1566 class _regrettablereprbytes(bytes): | |
1567 """Bytes subclass that makes the repr the same on Python 3 as Python 2. | |
1568 | |
1569 This is a huge hack. | |
1570 """ | |
1571 def __repr__(self): | |
1572 return repr(pycompat.sysstr(self)) | |
1573 | |
1574 def _maybebytestr(v): | 1566 def _maybebytestr(v): |
1575 if pycompat.ispy3 and isinstance(v, bytes): | 1567 if isinstance(v, bytes): |
1576 return _regrettablereprbytes(v) | 1568 return pycompat.bytestr(v) |
1577 return v | 1569 return v |
1578 | 1570 |
1579 def showmarker(fm, marker, index=None): | 1571 def showmarker(fm, marker, index=None): |
1580 """utility function to display obsolescence marker in a readable way | 1572 """utility function to display obsolescence marker in a readable way |
1581 | 1573 |