[PATCH 2 of 2 stable] url: handle file://localhost/c:/foo "correctly"
Mads Kiilerich
mads at kiilerich.com
Tue Nov 15 23:18:47 UTC 2011
# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1321398656 -3600
# Branch stable
# Node ID 396e83d635a6493b689376450ce000cc2418bcfe
# Parent e99facd2cd2a2045e692adc4fcff900c69d00626
url: handle file://localhost/c:/foo "correctly"
The path was parsed correctly, but localpath prepended an extra '/' (as in
'/c:/foo') because it assumed it was an absolute unix path.
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1708,7 +1708,8 @@
# letters to paths with drive letters.
if hasdriveletter(self._hostport):
path = self._hostport + '/' + self.path
- elif self.host is not None and self.path:
+ elif (self.host is not None and self.path
+ and not hasdriveletter(path)):
path = '/' + path
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
@@ -223,6 +223,14 @@
>>> u.localpath()
'f:oo/bar/baz'
+ >>> u = url('file://localhost/f:oo/bar/baz')
+ >>> u
+ <url scheme: 'file', host: 'localhost', path: 'f:oo/bar/baz'>
+ >>> str(u)
+ 'file://localhost/f%3Aoo/bar/baz'
+ >>> u.localpath()
+ 'f:oo/bar/baz'
+
>>> u = url('file:foo/bar/baz')
>>> u
<url scheme: 'file', path: 'foo/bar/baz'>
More information about the Mercurial-devel
mailing list