Rev 3200: (andrew) Don't URL-escape relpaths transmitted by the smart protocol in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Jan 24 05:03:29 GMT 2008


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

------------------------------------------------------------
revno: 3200
revision-id:pqm at pqm.ubuntu.com-20080124050323-gsgsp2em7v1ugtnz
parent: pqm at pqm.ubuntu.com-20080123180146-9pkott489spjwv8q
parent: andrew.bennetts at canonical.com-20080124032143-srxbec60xf9dt3xy
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2008-01-24 05:03:23 +0000
message:
  (andrew) Don't URL-escape relpaths transmitted by the smart protocol
  	client, fixing an interoperability issue with bzr 1.1 and earlier.
modified:
  bzrlib/smart/client.py         client.py-20061116014825-2k6ada6xgulslami-1
  bzrlib/tests/test_remote.py    test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
    ------------------------------------------------------------
    revno: 3192.2.2
    revision-id:andrew.bennetts at canonical.com-20080124032143-srxbec60xf9dt3xy
    parent: andrew.bennetts at canonical.com-20080122002742-jq55lz7umd0bcvx1
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: smart-path-encoding
    timestamp: Thu 2008-01-24 14:21:43 +1100
    message:
      Just use urllib.unquote, as suggested by John's review.
    modified:
      bzrlib/smart/client.py         client.py-20061116014825-2k6ada6xgulslami-1
    ------------------------------------------------------------
    revno: 3192.2.1
    revision-id:andrew.bennetts at canonical.com-20080122002742-jq55lz7umd0bcvx1
    parent: pqm at pqm.ubuntu.com-20080118011625-465mgy0mhdz1jiky
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: smart-path-encoding
    timestamp: Tue 2008-01-22 11:27:42 +1100
    message:
      Don't transmit URL-escaped relpaths in the smart protocol, which is back to how things worked in bzr 1.1 and earlier.
    modified:
      bzrlib/smart/client.py         client.py-20061116014825-2k6ada6xgulslami-1
      bzrlib/tests/test_remote.py    test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
=== modified file 'bzrlib/smart/client.py'
--- a/bzrlib/smart/client.py	2008-01-17 07:47:52 +0000
+++ b/bzrlib/smart/client.py	2008-01-24 03:21:43 +0000
@@ -14,6 +14,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+import urllib
 from urlparse import urlparse
 
 from bzrlib.smart import protocol
@@ -91,4 +92,5 @@
         else:
             medium_base = urlutils.join(self._shared_connection.base, '/')
             
-        return urlutils.relative_url(medium_base, transport.base).encode('utf8')
+        rel_url = urlutils.relative_url(medium_base, transport.base)
+        return urllib.unquote(rel_url)

=== modified file 'bzrlib/tests/test_remote.py'
--- a/bzrlib/tests/test_remote.py	2008-01-17 07:47:52 +0000
+++ b/bzrlib/tests/test_remote.py	2008-01-22 00:27:42 +0000
@@ -26,7 +26,6 @@
 from cStringIO import StringIO
 
 from bzrlib import (
-    bzrdir,
     errors,
     graph,
     pack,
@@ -166,6 +165,19 @@
         self.base = base
 
 
+class TestVfsHas(tests.TestCase):
+
+    def test_unicode_path(self):
+        client = FakeClient([(('yes',), )], '/')
+        transport = RemoteTransport('bzr://localhost/', _client=client)
+        filename = u'/hell\u00d8'.encode('utf8')
+        result = transport.has(filename)
+        self.assertEqual(
+            [('call', 'has', (filename,))],
+            client._calls)
+        self.assertTrue(result)
+
+
 class TestBzrDirOpenBranch(tests.TestCase):
 
     def test_branch_present(self):
@@ -194,6 +206,19 @@
             [('call', 'BzrDir.open_branch', ('quack/',))],
             client._calls)
 
+    def test_url_quoting_of_path(self):
+        # Relpaths on the wire should not be URL-escaped.  So "~" should be
+        # transmitted as "~", not "%7E".
+        transport = RemoteTransport('bzr://localhost/~hello/')
+        client = FakeClient([(('ok', ''), ), (('ok', '', 'no', 'no'), )],
+                            transport.base)
+        bzrdir = RemoteBzrDir(transport, _client=client)
+        result = bzrdir.open_branch()
+        self.assertEqual(
+            [('call', 'BzrDir.open_branch', ('~hello/',)),
+             ('call', 'BzrDir.find_repository', ('~hello/',))],
+            client._calls)
+
     def check_open_repository(self, rich_root, subtrees):
         transport = MemoryTransport()
         transport.mkdir('quack')




More information about the bazaar-commits mailing list