Work around bug in the Subversion libraries which don't accept http(s) URLs with...
authorJelmer Vernooij <jelmer@samba.org>
Sat, 12 Apr 2008 16:08:21 +0000 (18:08 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Sat, 12 Apr 2008 16:08:21 +0000 (18:08 +0200)
NEWS
tests/test_transport.py
transport.py

diff --git a/NEWS b/NEWS
index e2c0ed8c98045d92eb00fbfa908ee2b284405191..694187fcf48934472b64da53b84086bc776108fc 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -38,13 +38,16 @@ bzr-svn 0.4.10  UNRELEASED
 
   BUGS
 
-    * Avoid sometimes incorrect determination of Bazaar revision numbers. (#181773)
+   * Avoid sometimes incorrect determination of Bazaar revision numbers. (#181773)
 
-    * Deal with bzr:svn-revision-info property being removed. (#206728)
+   * Deal with bzr:svn-revision-info property being removed. (#206728)
 
-    * Gracefully handle erroneous svk merge tickets created by old versions of svk.
+   * Gracefully handle erroneous svk merge tickets created by old versions of svk.
 
-    * Use standard infrastructure for caching revision numbers. (#213953)
+   * Use standard infrastructure for caching revision numbers. (#213953)
+
+   * Work around bug in the Subversion libraries which don't accept 
+     http(s) URLs with urlencoded characters. (#190229)
 
 bzr-svn 0.4.9    2008-03-23
 
index 585585fe352e0410b7c5c5350be59e6281ee349e..14ccee4fdd0e8b4c1418fa3c670ea6a3289c3d9c 100644 (file)
@@ -19,7 +19,7 @@
 from tests import TestCaseWithSubversionRepository
 from bzrlib.errors import NotBranchError, NoSuchFile, FileExists, InvalidURL
 from bzrlib import urlutils
-from transport import SvnRaTransport, bzr_to_svn_url
+from transport import SvnRaTransport, bzr_to_svn_url, _url_unescape_uri
 from unittest import TestCase
 
 import os
@@ -187,3 +187,9 @@ class UrlConversionTest(TestCase):
                          bzr_to_svn_url("http://host/location"))
         self.assertEqual("http://host/location", 
                          bzr_to_svn_url("svn+http://host/location"))
+        self.assertEqual("http://host/gtk+/location", 
+                         bzr_to_svn_url("svn+http://host/gtk%2B/location"))
+
+    def test_url_unescape_uri(self):
+        self.assertEquals("http://svn.gnome.org/svn/gtk+/trunk",
+                _url_unescape_uri("http://svn.gnome.org/svn/gtk%2B/trunk"))
index 438c487d7a62095fb8c6938360d1eddeb3f3622e..5806dd61f6225f3f2e94f06087f15054f7b69a20 100644 (file)
@@ -27,6 +27,8 @@ import svn.core
 import svn.client
 
 from errors import convert_svn_error, NoSvnRepositoryPresent
+import urlparse
+import urllib
 
 svn_config = svn.core.svn_config_get_config(None)
 
@@ -87,6 +89,12 @@ def get_svn_ra_transport(bzr_transport):
     return SvnRaTransport(bzr_transport.base)
 
 
+def _url_unescape_uri(url):
+    (scheme, netloc, path, query, fragment) = urlparse.urlsplit(url)
+    path = urllib.unquote(path)
+    return urlparse.urlunsplit((scheme, netloc, path, query, fragment))
+
+
 def bzr_to_svn_url(url):
     """Convert a Bazaar URL to a URL understood by Subversion.
 
@@ -97,8 +105,14 @@ def bzr_to_svn_url(url):
         url.startswith("svn+https://")):
         url = url[len("svn+"):] # Skip svn+
 
+    if url.startswith("http"):
+        # Without this, URLs with + in them break
+        url = _url_unescape_uri(url)
+
     # The SVN libraries don't like trailing slashes...
-    return url.rstrip('/')
+    url = url.rstrip('/')
+
+    return url
 
 
 def needs_busy(unbound):