Rev 3329: Fix _SmartClient.remote_path_for_transport's handling of plain http: in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Apr 3 04:55:21 BST 2008


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

------------------------------------------------------------
revno: 3329
revision-id:pqm at pqm.ubuntu.com-20080403035509-qsxozetmg702c4p0
parent: pqm at pqm.ubuntu.com-20080403022255-5l0yelvi9m74mq24
parent: andrew.bennetts at canonical.com-20080401115907-8a8txfptssz811mw
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2008-04-03 04:55:09 +0100
message:
  Fix _SmartClient.remote_path_for_transport's handling of plain http:
  	URLs. (Andrew Bennetts)
modified:
  bzrlib/smart/client.py         client.py-20061116014825-2k6ada6xgulslami-1
  bzrlib/tests/test_remote.py    test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
    ------------------------------------------------------------
    revno: 3313.2.3.1.3
    revision-id:andrew.bennetts at canonical.com-20080401115907-8a8txfptssz811mw
    parent: andrew.bennetts at canonical.com-20080401082219-1hi5xflgeu6527lo
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: Fix remote_path_for_transport for http://
    timestamp: Tue 2008-04-01 22:59:07 +1100
    message:
      Add tests for _SmartClient.remote_path_for_transport.
    modified:
      bzrlib/tests/test_remote.py    test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
    ------------------------------------------------------------
    revno: 3313.2.3.1.2
    revision-id:andrew.bennetts at canonical.com-20080401082219-1hi5xflgeu6527lo
    parent: andrew.bennetts at canonical.com-20080328090701-p210ycxz2inhj5zg
    parent: pqm at pqm.ubuntu.com-20080401035104-fnjlf47gtles4byl
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: Fix remote_path_for_transport for http://
    timestamp: Tue 2008-04-01 19:22:19 +1100
    message:
      Merge from bzr.dev.
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzr                            bzr.py-20050313053754-5485f144c7006fa6
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/doc/api/__init__.py     __init__.py-20051224020744-7b87d590843855bc
      bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
      bzrlib/help_topics/__init__.py help_topics.py-20060920210027-rnim90q9e0bwxvy4-1
      bzrlib/smart/branch.py         branch.py-20061124031907-mzh3pla28r83r97f-1
      bzrlib/smart/bzrdir.py         bzrdir.py-20061122024551-ol0l0o0oofsu9b3t-1
      bzrlib/smart/medium.py         medium.py-20061103051856-rgu2huy59fkz902q-1
      bzrlib/smart/protocol.py       protocol.py-20061108035435-ot0lstk2590yqhzr-1
      bzrlib/smart/repository.py     repository.py-20061128022038-vr5wy5bubyb8xttk-1
      bzrlib/smart/request.py        request.py-20061108095550-gunadhxmzkdjfeek-1
      bzrlib/smart/server.py         server.py-20061110062051-chzu10y32vx8gvur-1
      bzrlib/smart/vfs.py            vfs.py-20061108095550-gunadhxmzkdjfeek-2
      bzrlib/tests/interrepository_implementations/__init__.py __init__.py-20060220054744-baf49a1f88f17b1a
      bzrlib/tests/interrepository_implementations/test_interrepository.py test_interrepository.py-20060220061411-1ec13fa99e5e3eee
      bzrlib/tests/test_errors.py    test_errors.py-20060210110251-41aba2deddf936a8
      bzrlib/tests/test_lazy_import.py test_lazy_import.py-20060910203832-f77c54gf3n232za0-2
      bzrlib/tests/test_selftest.py  test_selftest.py-20051202044319-c110a115d8c0456a
      bzrlib/tests/test_smart.py     test_smart.py-20061122024551-ol0l0o0oofsu9b3t-2
      bzrlib/tests/test_smart_transport.py test_ssh_transport.py-20060608202016-c25gvf1ob7ypbus6-2
      bzrlib/tests/test_transport_implementations.py test_transport_implementations.py-20051227111451-f97c5c7d5c49fce7
      bzrlib/tests/test_wsgi.py      test_wsgi.py-20061005091552-rz8pva0olkxv0sd8-1
      bzrlib/transport/chroot.py     chroot.py-20061011104729-0us9mgm97z378vnt-1
      bzrlib/transport/ftp.py        ftp.py-20051116161804-58dc9506548c2a53
      bzrlib/transport/http/wsgi.py  wsgi.py-20061005091552-rz8pva0olkxv0sd8-2
      bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
      doc/developers/repository.txt  repository.txt-20070709152006-xkhlek456eclha4u-1
      doc/en/user-guide/http_smart_server.txt fastcgi.txt-20061005091552-rz8pva0olkxv0sd8-3
    ------------------------------------------------------------
    revno: 3313.2.3.1.1
    revision-id:andrew.bennetts at canonical.com-20080328090701-p210ycxz2inhj5zg
    parent: andrew.bennetts at canonical.com-20080328085843-pdstuawpwy1hst6r
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: Fix remote_path_for_transport for http://
    timestamp: Fri 2008-03-28 20:07:01 +1100
    message:
      Treat http:// and https:// URLs correctly in _SmartClient.remote_path_for_transport.
    modified:
      bzrlib/smart/client.py         client.py-20061116014825-2k6ada6xgulslami-1
=== modified file 'bzrlib/smart/client.py'
--- a/bzrlib/smart/client.py	2008-03-28 08:05:51 +0000
+++ b/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'
--- a/bzrlib/tests/test_remote.py	2008-03-28 08:05:51 +0000
+++ b/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):




More information about the bazaar-commits mailing list