# HG changeset patch # User Brodie Rao # Date 1301540424 25200 # Node ID 2540f8087e020a3fdc1e6f05f91b8edac972ab5d # Parent d066d8d652c8a8a74c57ee5361ace58a4dc743be 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). diff -r d066d8d652c8 -r 2540f8087e02 mercurial/url.py --- 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('bundle:foo') + >>> url('bundle://../foo') + >>> url('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