py3: avoid using %r format on bytes stable
authorManuel Jacob <me@manueljacob.de>
Tue, 16 Jun 2020 14:32:10 +0200
branchstable
changeset 44970 7a4630536e53
parent 44969 d545b895234a
child 44971 423e20c78e6d
py3: avoid using %r format on bytes Before the patch, the 'b' prefix appeared in the formatted string. Wrapping the bytes as pycompat.bytestr solves this problem. Eventually, I think that we should move away from using %r (like 975e517451a6 and 4d6019c0e0ef did), but that would change output of non-ASCII bytes on Python 2, so we can’t do it on the stable branch. Also, many places continue to use %r, so it would be a good idea to do the change all at once.
hgext/convert/subversion.py
--- a/hgext/convert/subversion.py	Tue Jun 16 14:03:00 2020 +0200
+++ b/hgext/convert/subversion.py	Tue Jun 16 14:32:10 2020 +0200
@@ -535,7 +535,9 @@
                         % (name, path)
                     )
                 return None
-            self.ui.note(_(b'found %s at %r\n') % (name, path))
+            self.ui.note(
+                _(b'found %s at %r\n') % (name, pycompat.bytestr(path))
+            )
             return path
 
         rev = optrev(self.last_changed)
@@ -1208,7 +1210,10 @@
                 return relative
 
         # The path is outside our tracked tree...
-        self.ui.debug(b'%r is not under %r, ignoring\n' % (path, module))
+        self.ui.debug(
+            b'%r is not under %r, ignoring\n'
+            % (pycompat.bytestr(path), pycompat.bytestr(module))
+        )
         return None
 
     def _checkpath(self, path, revnum, module=None):