comparison mercurial/url.py @ 7284:ac81ffac0f35

url: fix file:// URL handling
author Patrick Mezard <pmezard@gmail.com>
date Tue, 28 Oct 2008 22:24:41 +0100
parents 2db33c1a5654
children 5ad99abfab79
comparison
equal deleted inserted replaced
7283:b19c0200c90b 7284:ac81ffac0f35
248 248
249 def getauthinfo(path): 249 def getauthinfo(path):
250 scheme, netloc, urlpath, query, frag = urlparse.urlsplit(path) 250 scheme, netloc, urlpath, query, frag = urlparse.urlsplit(path)
251 if not urlpath: 251 if not urlpath:
252 urlpath = '/' 252 urlpath = '/'
253 urlpath = quotepath(urlpath) 253 if scheme != 'file':
254 # XXX: why are we quoting the path again with some smart
255 # heuristic here? Anyway, it cannot be done with file://
256 # urls since path encoding is os/fs dependent (see
257 # urllib.pathname2url() for details).
258 urlpath = quotepath(urlpath)
254 host, port, user, passwd = netlocsplit(netloc) 259 host, port, user, passwd = netlocsplit(netloc)
255 260
256 # urllib cannot handle URLs with embedded user or passwd 261 # urllib cannot handle URLs with embedded user or passwd
257 url = urlparse.urlunsplit((scheme, netlocunsplit(host, port), 262 url = urlparse.urlunsplit((scheme, netlocunsplit(host, port),
258 urlpath, query, frag)) 263 urlpath, query, frag))
294 return opener 299 return opener
295 300
296 def open(ui, url, data=None): 301 def open(ui, url, data=None):
297 scheme = urlparse.urlsplit(url)[0] 302 scheme = urlparse.urlsplit(url)[0]
298 if not scheme: 303 if not scheme:
299 url, authinfo = 'file://' + util.normpath(os.path.abspath(url)), None 304 path = util.normpath(os.path.abspath(url))
305 url = 'file://' + urllib.pathname2url(path)
306 authinfo = None
300 else: 307 else:
301 url, authinfo = getauthinfo(url) 308 url, authinfo = getauthinfo(url)
302 return opener(ui, authinfo).open(url, data) 309 return opener(ui, authinfo).open(url, data)