Rev 2469: (Andrew Bennetts) Normalise URLs in RemoteHTTPTransport before doing URL calculations to fix bad results. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Mon Apr 30 05:00:08 BST 2007


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 2469
revision-id: pqm at pqm.ubuntu.com-20070430040006-olr7xpzdbp02y1sd
parent: pqm at pqm.ubuntu.com-20070430025942-y83xydh67a37zebd
parent: andrew.bennetts at canonical.com-20070427021911-pk1ylmrmc1ueo9ad
committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2007-04-30 05:00:06 +0100
message:
  (Andrew Bennetts) Normalise URLs in RemoteHTTPTransport before doing URL calculations to fix bad results.
modified:
  bzrlib/tests/test_smart_transport.py test_ssh_transport.py-20060608202016-c25gvf1ob7ypbus6-2
  bzrlib/transport/remote.py     ssh.py-20060608202016-c25gvf1ob7ypbus6-1
    ------------------------------------------------------------
    revno: 2466.3.1
    merged: andrew.bennetts at canonical.com-20070427021911-pk1ylmrmc1ueo9ad
    parent: pqm at pqm.ubuntu.com-20070426211103-h84prqh7a4ad3ez2
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: normalize-remote-http-urls
    timestamp: Fri 2007-04-27 12:19:11 +1000
    message:
      Normalise URLs in RemoteHTTPTransport before doing URL calculations to fix bad results.
=== modified file 'bzrlib/tests/test_smart_transport.py'
--- a/bzrlib/tests/test_smart_transport.py	2007-04-26 09:07:38 +0000
+++ b/bzrlib/tests/test_smart_transport.py	2007-04-27 02:19:11 +0000
@@ -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'
--- a/bzrlib/transport/remote.py	2007-04-30 02:25:45 +0000
+++ b/bzrlib/transport/remote.py	2007-04-30 04:00:06 +0000
@@ -503,7 +503,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)
@@ -538,7 +538,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:




More information about the bazaar-commits mailing list