url: fix file:// URL handling
authorPatrick Mezard <pmezard@gmail.com>
Tue, 28 Oct 2008 22:24:41 +0100
changeset 7284 ac81ffac0f35
parent 7283 b19c0200c90b
child 7285 5ad99abfab79
url: fix file:// URL handling
mercurial/url.py
--- a/mercurial/url.py	Tue Oct 28 20:48:30 2008 +0100
+++ b/mercurial/url.py	Tue Oct 28 22:24:41 2008 +0100
@@ -250,7 +250,12 @@
     scheme, netloc, urlpath, query, frag = urlparse.urlsplit(path)
     if not urlpath:
         urlpath = '/'
-    urlpath = quotepath(urlpath)
+    if scheme != 'file':
+        # XXX: why are we quoting the path again with some smart
+        # heuristic here? Anyway, it cannot be done with file://
+        # urls since path encoding is os/fs dependent (see
+        # urllib.pathname2url() for details).
+        urlpath = quotepath(urlpath)
     host, port, user, passwd = netlocsplit(netloc)
 
     # urllib cannot handle URLs with embedded user or passwd
@@ -296,7 +301,9 @@
 def open(ui, url, data=None):
     scheme = urlparse.urlsplit(url)[0]
     if not scheme:
-        url, authinfo = 'file://' + util.normpath(os.path.abspath(url)), None
+        path = util.normpath(os.path.abspath(url))
+        url = 'file://' + urllib.pathname2url(path)
+        authinfo = None
     else:
         url, authinfo = getauthinfo(url)
     return opener(ui, authinfo).open(url, data)