changeset 32860:f22f39d56bb5

py3: add a new bytesurl() to convert a str url into bytes
author Pulkit Goyal <7895pulkit@gmail.com>
date Fri, 16 Jun 2017 00:36:17 +0530
parents a05f3675c46a
children 20d70df64e93
files mercurial/pycompat.py
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/pycompat.py	Fri Jun 16 00:32:52 2017 +0530
+++ b/mercurial/pycompat.py	Fri Jun 16 00:36:17 2017 +0530
@@ -177,6 +177,10 @@
         """Converts a bytes url back to str"""
         return url.decode(u'ascii')
 
+    def bytesurl(url):
+        """Converts a str url to bytes by encoding in ascii"""
+        return url.encode(u'ascii')
+
     def raisewithtb(exc, tb):
         """Raise exception with the given traceback"""
         raise exc.with_traceback(tb)
@@ -249,6 +253,7 @@
     sysbytes = identity
     sysstr = identity
     strurl = identity
+    bytesurl = identity
 
     # this can't be parsed on Python 3
     exec('def raisewithtb(exc, tb):\n'