diff --git a/mercurial/url.py b/mercurial/url.py --- a/mercurial/url.py +++ b/mercurial/url.py @@ -29,6 +29,9 @@ class url(object): See http://www.ietf.org/rfc/rfc2396.txt for more information. + Note that for backward compatibility reasons, bundle URLs do not + take host names. That means 'bundle://../' has a path of '../'. + Examples: >>> url('http://www.ietf.org/rfc/rfc2396.txt') @@ -39,6 +42,8 @@ class url(object): >>> url('bundle:foo') + >>> url('bundle://../foo') + >>> url('c:\\\\foo\\\\bar') @@ -71,6 +76,16 @@ class url(object): self.path = path return + # For compatibility reasons, we can't handle bundle paths as + # normal URLS + if path.startswith('bundle:'): + self.scheme = 'bundle' + path = path[7:] + if path.startswith('//'): + path = path[2:] + self.path = path + return + if not path.startswith('/') and ':' in path: parts = path.split(':', 1) if parts[0]: @@ -159,11 +174,15 @@ class url(object): 'http://localhost:80/' >>> str(url('bundle:foo')) 'bundle:foo' + >>> str(url('bundle://../foo')) + 'bundle:../foo' >>> str(url('path')) 'path' """ if self._localpath: s = self.path + if self.scheme == 'bundle': + s = 'bundle:' + s if self.fragment: s += '#' + self.fragment return s