[PATCH 2 of 9] py3: add a new bytesurl() to convert a str url into bytes
Pulkit Goyal
7895pulkit at gmail.com
Thu Jun 15 17:34:44 EDT 2017
# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1497553577 -19800
# Fri Jun 16 00:36:17 2017 +0530
# Node ID 8a4aa371b00bd7a7533459ee6ac8a3a07f0fa98e
# Parent c860b2b1b6b3cb9464c021167bbd85589e091225
py3: add a new bytesurl() to convert a str url into bytes
diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -153,6 +153,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 iterbytestr(s):
"""Iterate bytes as if it were a str object of Python 2"""
return map(bytechr, s)
@@ -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'
More information about the Mercurial-devel
mailing list