[MERGE][#207558] Fix _SmartClient.remote_path_for_transport's handling of plain http: URLs.

Andrew Bennetts andrew at canonical.com
Tue Apr 1 13:08:46 BST 2008


This simple change fixes the core of bug #207558, which was introduced in
bzr.dev r3309.  It makes the client send the right paths when the transport
scheme is http and https (and not just when the transport scheme is bzr+http or
bzr+https).

Still to be done:
  * Fix bazaar.launchpad.net's smart server, which is currently suffering from
    bug #124089 (the fix for this landed in bzr.dev earlier today)
  * Offer some way for clients to explictly not use the smart server when using
    HTTP.  This may be useful for debugging, and also as a workaround if an HTTP
    server has a misconfigured bzr smart server.

-Andrew.

-------------- next part --------------
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: andrew.bennetts at canonical.com-20080401115907-\
#   8a8txfptssz811mw
# target_branch: http://bazaar-vcs.org/bzr/bzr.dev
# testament_sha1: 750f25621b1971b0c2c6bcbddcd14e00f9cea873
# timestamp: 2008-04-01 22:59:22 +1100
# source_branch: http://people.ubuntu.com/~andrew/bzr/bug-207558
# base_revision_id: pqm at pqm.ubuntu.com-20080401035104-fnjlf47gtles4byl
# 
# Begin patch
=== modified file 'bzrlib/smart/client.py'
--- bzrlib/smart/client.py	2008-03-28 08:05:51 +0000
+++ bzrlib/smart/client.py	2008-03-28 09:07:01 +0000
@@ -87,7 +87,8 @@
         the medium from the matching transport.
         """
         base = self._base
-        if base.startswith('bzr+http://') or base.startswith('bzr+https://'):
+        if (base.startswith('bzr+http://') or base.startswith('bzr+https://')
+            or base.startswith('http://') or base.startswith('https://')):
             medium_base = self._base
         else:
             medium_base = urlutils.join(self._base, '/')

=== modified file 'bzrlib/tests/test_remote.py'
--- bzrlib/tests/test_remote.py	2008-03-28 08:05:51 +0000
+++ bzrlib/tests/test_remote.py	2008-04-01 11:59:07 +0000
@@ -46,6 +46,7 @@
 from bzrlib.smart import server, medium
 from bzrlib.smart.client import _SmartClient
 from bzrlib.symbol_versioning import one_four
+from bzrlib.transport import get_transport
 from bzrlib.transport.memory import MemoryTransport
 from bzrlib.transport.remote import RemoteTransport
 
@@ -183,6 +184,39 @@
         self.assertTrue(result)
 
 
+class Test_SmartClient_remote_path_from_transport(tests.TestCase):
+    """Tests for the behaviour of _SmartClient.remote_path_from_transport."""
+
+    def assertRemotePath(self, expected, client_base, transport_base):
+        """Assert that the result of _SmartClient.remote_path_from_transport
+        is the expected value for a given client_base and transport_base.
+        """
+        dummy_medium = 'dummy medium'
+        client = _SmartClient(dummy_medium, client_base)
+        transport = get_transport(transport_base)
+        result = client.remote_path_from_transport(transport)
+        self.assertEqual(expected, result)
+        
+    def test_remote_path_from_transport(self):
+        """_SmartClient.remote_path_from_transport calculates a URL for the
+        given transport relative to the root of the client base URL.
+        """
+        self.assertRemotePath('xyz/', 'bzr://host/path', 'bzr://host/xyz')
+        self.assertRemotePath(
+            'path/xyz/', 'bzr://host/path', 'bzr://host/path/xyz')
+
+    def test_remote_path_from_transport_http(self):
+        """Remote paths for HTTP transports are calculated differently to other
+        transports.  They are just relative to the client base, not the root
+        directory of the host.
+        """
+        for scheme in ['http:', 'https:', 'bzr+http:', 'bzr+https:']:
+            self.assertRemotePath(
+                '../xyz/', scheme + '//host/path', scheme + '//host/xyz')
+            self.assertRemotePath(
+                'xyz/', scheme + '//host/path', scheme + '//host/path/xyz')
+
+
 class TestBzrDirOpenBranch(tests.TestCase):
 
     def test_branch_present(self):

# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWaGnsMwABlXfgGRUUe///3//
//q////wYAufbvvtLbvHcxuwAO6j4zXddXZt7t2nQNF2JrnIMohRhkjZNRvSTTaaTQYyjZQyDAgx
ME0yNBJRBpGEp+mqe1H6kyR6J5T1DZR6ZIep6agaPRMg2gTDJGqbRpT1MmmAIGamjTCNAA0GQGIA
ASIhEm0QmTAI0yNPSaA0DQNGgADTQAikgg0GlPTTSbEyYjIhPE1No0xRppkyYaIPU0EkiaDQTTFN
o0ChkntGVPQCeoHpMgyA0NPUaSwZWCBgE5VUNc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