[MERGE][0.16?] Normalise URLs in RemoteHTTPTransport
Andrew Bennetts
andrew at canonical.com
Fri Apr 27 06:57:00 BST 2007
Andrew Bennetts wrote:
[...]
> Both of these are broken, and prevents bzr 0.16rc1 from being able to open
> branches on bzr+http://bazaar.launchpad.net/ (although earlier bzr versions
> can't either, because RemoteHTTPTransport didn't have the logic to POST to a
> consistent .bzr/smart location).
>
> This bundle fixes that.
Ahem. Attached.
-Andrew.
-------------- next part --------------
# Bazaar revision bundle v0.9
#
# message:
# Normalise URLs in RemoteHTTPTransport before doing URL calculations to fix bad results.
# committer: Andrew Bennetts <andrew.bennetts at canonical.com>
# date: Fri 2007-04-27 12:19:11.470000029 +1000
=== modified file bzrlib/tests/test_smart_transport.py
--- bzrlib/tests/test_smart_transport.py
+++ bzrlib/tests/test_smart_transport.py
@@ -2087,6 +2087,19 @@
new_transport = base_transport.clone('abc/../..')
self.assertEqual('foo', new_transport._remote_path('foo'))
+ def test_remote_path_unnormal_base(self):
+ # If the transport's base isn't normalised, the _remote_path should
+ # still be calculated correctly.
+ base_transport = remote.RemoteHTTPTransport('bzr+http://host/%7Ea/b')
+ self.assertEqual('c', base_transport._remote_path('c'))
+
+ def test_clone_unnormal_base(self):
+ # If the transport's base isn't normalised, cloned transports should
+ # still work correctly.
+ base_transport = remote.RemoteHTTPTransport('bzr+http://host/%7Ea/b')
+ new_transport = base_transport.clone('c')
+ self.assertEqual('bzr+http://host/%7Ea/b/c/', new_transport.base)
+
# TODO: Client feature that does get_bundle and then installs that into a
# branch; this can be used in place of the regular pull/fetch operation when
=== modified file bzrlib/transport/remote.py
--- bzrlib/transport/remote.py
+++ bzrlib/transport/remote.py
@@ -488,7 +488,7 @@
"""After connecting HTTP Transport only deals in relative URLs."""
# Adjust the relpath based on which URL this smart transport is
# connected to.
- base = self._http_transport.base
+ base = urlutils.normalize_url(self._http_transport.base)
url = urlutils.join(self.base[len('bzr+'):], relpath)
url = urlutils.normalize_url(url)
return urlutils.relative_url(base, url)
@@ -523,7 +523,9 @@
# We either use the exact same http_transport (for child locations), or
# a clone of the underlying http_transport (for parent locations). This
# means we share the connection.
- normalized_rel_url = urlutils.relative_url(self.base, abs_url)
+ norm_base = urlutils.normalize_url(self.base)
+ norm_abs_url = urlutils.normalize_url(abs_url)
+ normalized_rel_url = urlutils.relative_url(norm_base, norm_abs_url)
if normalized_rel_url == ".." or normalized_rel_url.startswith("../"):
http_transport = self._http_transport.clone(normalized_rel_url)
else:
=== modified directory // last-changed:andrew.bennetts at canonical.com-200704270
... 21911-pk1ylmrmc1ueo9ad
# revision id: andrew.bennetts at canonical.com-20070427021911-pk1ylmrmc1ueo9ad
# sha1: 0e211f0b8767b5d90dc42e11c113685566bcbaa0
# inventory sha1: 485e2c54016f787d1d07db19dd6ff3c5445d42d0
# parent ids:
# pqm at pqm.ubuntu.com-20070426211103-h84prqh7a4ad3ez2
# base id: pqm at pqm.ubuntu.com-20070426211103-h84prqh7a4ad3ez2
# properties:
# branch-nick: normalize-remote-http-urls
More information about the bazaar
mailing list