diff mercurial/pycompat.py @ 35944:fc44c2657dc5

py3: drop b'' from repr() of smartset cmdutil._maybebytestr() is moved to pycompat.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 27 Jan 2018 17:46:37 +0900
parents 1a31111e6239
children 04984f2e50ae
line wrap: on
line diff
--- a/mercurial/pycompat.py	Sat Jan 27 17:31:25 2018 +0900
+++ b/mercurial/pycompat.py	Sat Jan 27 17:46:37 2018 +0900
@@ -161,6 +161,12 @@
         """Iterate bytes as if it were a str object of Python 2"""
         return map(bytechr, s)
 
+    def maybebytestr(s):
+        """Promote bytes to bytestr"""
+        if isinstance(s, bytes):
+            return bytestr(s)
+        return s
+
     def sysbytes(s):
         """Convert an internal str (e.g. keyword, __doc__) back to bytes
 
@@ -267,6 +273,7 @@
     bytechr = chr
     bytestr = str
     iterbytestr = iter
+    maybebytestr = identity
     sysbytes = identity
     sysstr = identity
     strurl = identity