[PATCH 2 of 3] py3: appease urllib.request.pathname2url() with a str in Windows
Yuya Nishihara
yuya at tcha.org
Mon Oct 15 06:03:19 UTC 2018
On Sun, 14 Oct 2018 12:41:54 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison at yahoo.com>
> # Date 1539492655 14400
> # Sun Oct 14 00:50:55 2018 -0400
> # Node ID 8b25e88b588d5be2b6a511d4f76e3c0230122e10
> # Parent edf769c43bbb10048dceed4cc2ddd46197943ff3
> py3: appease urllib.request.pathname2url() with a str in Windows
>
> This fixes test-extdata.t on Windows. Presumably url2pathname() needs a similar
> fix, but that's only used in svn conversions, and I don't have svn installed.
>
> diff --git a/mercurial/url.py b/mercurial/url.py
> --- a/mercurial/url.py
> +++ b/mercurial/url.py
> @@ -598,7 +598,8 @@ def open(ui, url_, data=None):
> url_, authinfo = u.authinfo()
> else:
> path = util.normpath(os.path.abspath(url_))
> - url_ = 'file://' + pycompat.bytesurl(urlreq.pathname2url(path))
> + p2url = urlreq.pathname2url
> + url_ = 'file://' + pycompat.bytesurl(p2url(encoding.tonativestr(path)))
Maybe vendor nturl2path.py to make it bytes safe and call our
urllibcompat.quote()?
I think it's better to not do lossy encoding conversion here, but I have
no idea to get around the unicode bytes dance in nturl2path ->
urllib.parse.quote() -> quote_from_bytes().
More information about the Mercurial-devel
mailing list