[PATCH 1 of 9] py3: add a new strurl() which will convert a bytes url to str

Pulkit Goyal 7895pulkit at gmail.com
Thu Jun 15 21:34:43 UTC 2017


# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1497553372 -19800
#      Fri Jun 16 00:32:52 2017 +0530
# Node ID c860b2b1b6b3cb9464c021167bbd85589e091225
# Parent  877b74712132f1e2848174ee49490d328282e00d
py3: add a new strurl() which will convert a bytes url to str

diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -149,6 +149,10 @@
         def __iter__(self):
             return iterbytestr(bytes.__iter__(self))
 
+    def strurl(url):
+        """Converts a bytes url back to str"""
+        return url.decode(u'ascii')
+
     def iterbytestr(s):
         """Iterate bytes as if it were a str object of Python 2"""
         return map(bytechr, s)
@@ -244,6 +248,7 @@
     iterbytestr = iter
     sysbytes = identity
     sysstr = identity
+    strurl = identity
 
     # this can't be parsed on Python 3
     exec('def raisewithtb(exc, tb):\n'


More information about the Mercurial-devel mailing list