##// END OF EJS Templates
util: fix url.__str__() for windows file URLs...
Patrick Mezard -
r15609:8f4bad72 stable
parent child Browse files
Show More
@@ -72,9 +72,10 b' class ShortRepository(object):'
72 72 return hg._peerlookup(url).instance(ui, url, create)
73 73
74 74 def hasdriveletter(orig, path):
75 for scheme in schemes:
76 if path.startswith(scheme + ':'):
77 return False
75 if path:
76 for scheme in schemes:
77 if path.startswith(scheme + ':'):
78 return False
78 79 return orig(path)
79 80
80 81 schemes = {
@@ -1629,6 +1629,8 b' class url(object):'
1629 1629 'path'
1630 1630 >>> str(url('file:///tmp/foo/bar'))
1631 1631 'file:///tmp/foo/bar'
1632 >>> str(url('file:///c:/tmp/foo/bar'))
1633 'file:///c%3A/tmp/foo/bar'
1632 1634 >>> print url(r'bundle:foo\bar')
1633 1635 bundle:foo\bar
1634 1636 """
@@ -1643,8 +1645,11 b' class url(object):'
1643 1645 s = self.scheme + ':'
1644 1646 if self.user or self.passwd or self.host:
1645 1647 s += '//'
1646 elif self.scheme and (not self.path or self.path.startswith('/')):
1648 elif self.scheme and (not self.path or self.path.startswith('/')
1649 or hasdriveletter(self.path)):
1647 1650 s += '//'
1651 if hasdriveletter(self.path):
1652 s += '/'
1648 1653 if self.user:
1649 1654 s += urllib.quote(self.user, safe=self._safechars)
1650 1655 if self.passwd:
@@ -1716,7 +1721,7 b' def hasscheme(path):'
1716 1721 return bool(url(path).scheme)
1717 1722
1718 1723 def hasdriveletter(path):
1719 return path[1:2] == ':' and path[0:1].isalpha()
1724 return path and path[1:2] == ':' and path[0:1].isalpha()
1720 1725
1721 1726 def urllocalpath(path):
1722 1727 return url(path, parsequery=False, parsefragment=False).localpath()
@@ -219,7 +219,7 b' def test_url():'
219 219 >>> u
220 220 <url scheme: 'file', path: 'f:oo/bar/baz'>
221 221 >>> str(u)
222 'file:f%3Aoo/bar/baz'
222 'file:///f%3Aoo/bar/baz'
223 223 >>> u.localpath()
224 224 'f:oo/bar/baz'
225 225
General Comments 0
You need to be logged in to leave comments. Login now