changeset 7284:ac81ffac0f35

url: fix file:// URL handling
author Patrick Mezard <pmezard@gmail.com>
date Tue, 28 Oct 2008 22:24:41 +0100
parents b19c0200c90b
children 5ad99abfab79
files mercurial/url.py
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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)