Mercurial > hg
changeset 13816:2540f8087e02
url: special case bundle URL parsing to preserve backwards compatibility
This allows bundle://../foo to continue to refer to the relative path
../foo (bundle URLs do not take host names).
author | Brodie Rao <brodie@bitheap.org> |
---|---|
date | Wed, 30 Mar 2011 20:00:24 -0700 |
parents | d066d8d652c8 |
children | 7f18bab2c0b0 |
files | mercurial/url.py |
diffstat | 1 files changed, 19 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/url.py Wed Mar 30 20:00:23 2011 -0700 +++ b/mercurial/url.py Wed Mar 30 20:00:24 2011 -0700 @@ -29,6 +29,9 @@ 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 @@ <url scheme: 'file', path: '/home/joe/repo'> >>> url('bundle:foo') <url scheme: 'bundle', path: 'foo'> + >>> url('bundle://../foo') + <url scheme: 'bundle', path: '../foo'> >>> url('c:\\\\foo\\\\bar') <url path: 'c:\\\\foo\\\\bar'> @@ -71,6 +76,16 @@ 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 @@ '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