diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -1444,6 +1444,8 @@ class url(object): path = None if not self.host: self.host = None + # path of file:///d is /d + # path of file:///d:/ is d:/, not /d:/ if path and not hasdriveletter(path): path = '/' + path @@ -1586,11 +1588,6 @@ class url(object): path = self._hostport + '/' + self.path elif self.host is not None and self.path: path = '/' + path - # We also need to handle the case of file:///C:/, which - # should return C:/, not /C:/. - elif hasdriveletter(path): - # Strip leading slash from paths with drive names - return path[1:] return path return self._origpath diff --git a/tests/test-url.py b/tests/test-url.py --- a/tests/test-url.py +++ b/tests/test-url.py @@ -204,18 +204,32 @@ def test_url(): >>> str(u) 'file:///foo/bar/baz' + >>> u.localpath() + '/foo/bar/baz' >>> u = url('file:///foo/bar/baz') >>> u >>> str(u) 'file:///foo/bar/baz' + >>> u.localpath() + '/foo/bar/baz' + + >>> u = url('file:///f:oo/bar/baz') + >>> u + + >>> str(u) + 'file:f%3Aoo/bar/baz' + >>> u.localpath() + 'f:oo/bar/baz' >>> u = url('file:foo/bar/baz') >>> u >>> str(u) 'file:foo/bar/baz' + >>> u.localpath() + 'foo/bar/baz' """ doctest.testmod(optionflags=doctest.NORMALIZE_WHITESPACE)