Rev 2248: Add helper function url_join_unescaped_path in http://people.samba.org/bzr/jelmer/bzr-svn/0.5

Jelmer Vernooij jelmer at samba.org
Mon Dec 8 19:13:36 GMT 2008


At http://people.samba.org/bzr/jelmer/bzr-svn/0.5

------------------------------------------------------------
revno: 2248
revision-id: jelmer at samba.org-20081208191332-8ru2dk8gvec14jvz
parent: jelmer at samba.org-20081208180801-cd9aaafda7ss8n93
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.5
timestamp: Mon 2008-12-08 20:13:32 +0100
message:
  Add helper function url_join_unescaped_path
modified:
  commit.py                      commit.py-20060607190346-qvq128wgfubhhgm2-1
  fetch.py                       fetch.py-20060625004942-x2lfaib8ra707a8p-1
  tests/test_transport.py        test_transport.py-20060621232111-xh7xvoblzsrgj79t-1
  transport.py                   transport.py-20060406231150-b3472d06b3a0818d
=== modified file 'commit.py'
--- a/commit.py	2008-12-08 16:39:47 +0000
+++ b/commit.py	2008-12-08 19:13:32 +0000
@@ -57,7 +57,7 @@
 from bzrlib.plugins.svn.logwalker import lazy_dict
 from bzrlib.plugins.svn.repository import SvnRepositoryFormat, SvnRepository
 from bzrlib.plugins.svn.versionedfiles import SvnTexts
-from bzrlib.plugins.svn.transport import _url_escape_uri
+from bzrlib.plugins.svn.transport import url_join_unescaped_path
 
 
 def _revision_id_to_svk_feature(revid):
@@ -227,7 +227,7 @@
                               old_inv.id2path(child_ie.file_id), 
                               new_child_path)
             child_editor = dir_editor.add_file(full_new_child_path, 
-                _url_escape_uri(urlutils.join(base_url, old_inv.id2path(child_ie.file_id))),
+                url_join_unescaped_path(base_url, old_inv.id2path(child_ie.file_id)),
                 base_revnum)
 
         # open if they existed at the same location
@@ -290,7 +290,7 @@
             mutter('copy dir %r -> %r', old_child_path, new_child_path)
             child_editor = dir_editor.add_directory(
                 branch_relative_path(new_child_path),
-                _url_escape_uri(urlutils.join(base_url, old_child_path)), base_revnum)
+                url_join_unescaped_path(base_url, old_child_path), base_revnum)
 
         # open if they existed at the same location and 
         # the directory was touched
@@ -611,7 +611,6 @@
                 else:
                     base_url = None
 
-                # TODO: Accept create_prefix argument
                 branch_editors = self.open_branch_editors(root, bp_parts,
                     existing_bp_parts, base_url, self.base_revnum, 
                     replace_existing)
@@ -796,7 +795,7 @@
             if deletefirst:
                 root.delete_entry(urlutils.basename(branch_path))
             branch_dir = root.add_directory(urlutils.basename(branch_path), 
-                    _url_escape_uri(urlutils.join(repository.base, revmeta.branch_path)), revmeta.revnum)
+                    url_join_unescaped_path(repository.base, revmeta.branch_path), revmeta.revnum)
             for k, (ov, nv) in properties.diff(fileprops, revmeta.get_fileprops()).iteritems():
                 branch_dir.change_prop(k, nv)
             branch_dir.close()
@@ -1036,7 +1035,8 @@
             graph = self.target.get_graph()
             for revision_id in todo:
                 if pb is not None:
-                    pb.update("pushing revisions", todo.index(revision_id), len(todo))
+                    pb.update("pushing revisions", todo.index(revision_id), 
+                        len(todo))
                 rev = self.source.get_revision(revision_id)
 
                 mutter('pushing %r', revision_id)
@@ -1045,7 +1045,7 @@
 
                 (uuid, bp, _), _ = self.target.lookup_revision_id(parent_revid)
                 if target_branch is None:
-                    target_branch = Branch.open(_url_escape_uri(urlutils.join(self.target.base, bp)))
+                    target_branch = Branch.open(url_join_unescaped_path(self.target.base, bp))
                 if target_branch.get_branch_path() != bp:
                     target_branch.set_branch_path(bp)
 
@@ -1053,12 +1053,13 @@
                 if (layout.push_merged_revisions(target_branch.project) and 
                     len(rev.parent_ids) > 1 and
                     target_config.get_push_merged_revisions()):
-                    push_ancestors(self.target, self.source, layout, "", rev.parent_ids, graph,
-                                   create_prefix=True)
+                    push_ancestors(self.target, self.source, layout, "", 
+                        rev.parent_ids, graph, create_prefix=True)
 
-                push_revision_tree(graph, target_branch.repository, target_branch.get_branch_path(), 
-                                   target_config, self.source, parent_revid, revision_id, rev,
-                                   append_revisions_only=target_branch._get_append_revisions_only())
+                push_revision_tree(graph, target_branch.repository, 
+                    target_branch.get_branch_path(), target_config, 
+                    self.source, parent_revid, revision_id, rev, 
+                    append_revisions_only=target_branch._get_append_revisions_only())
         finally:
             self.source.unlock()
  

=== modified file 'fetch.py'
--- a/fetch.py	2008-12-07 23:25:07 +0000
+++ b/fetch.py	2008-12-08 19:13:32 +0000
@@ -39,7 +39,7 @@
 from bzrlib.plugins.svn.mapping import SVN_PROP_BZR_PREFIX
 from bzrlib.plugins.svn.repository import SvnRepository, SvnRepositoryFormat
 from bzrlib.plugins.svn.revmeta import iter_with_mapping
-from bzrlib.plugins.svn.transport import _url_escape_uri
+from bzrlib.plugins.svn.transport import url_join_unescaped_path
 
 FETCH_COMMIT_WRITE_SIZE = 500
 
@@ -852,7 +852,7 @@
 
             if parent_branch != revmeta.branch_path:
                 reporter = conn.do_switch(revmeta.revnum, "", True, 
-                    _url_escape_uri(urlutils.join(conn.get_repos_root(), revmeta.branch_path)), 
+                    url_join_unescaped_path(conn.get_repos_root(), revmeta.branch_path), 
                     editor)
             else:
                 reporter = conn.do_update(revmeta.revnum, "", True, editor)

=== modified file 'tests/test_transport.py'
--- a/tests/test_transport.py	2008-10-02 21:18:28 +0000
+++ b/tests/test_transport.py	2008-12-08 19:13:32 +0000
@@ -22,7 +22,7 @@
 import subvertpy
 from subvertpy import ra
 from bzrlib.plugins.svn.tests import SubversionTestCase
-from bzrlib.plugins.svn.transport import SvnRaTransport, bzr_to_svn_url, _url_unescape_uri
+from bzrlib.plugins.svn.transport import SvnRaTransport, bzr_to_svn_url, _url_unescape_uri, url_join_unescaped_path, _url_escape_uri
 
 from unittest import TestCase
 
@@ -199,3 +199,11 @@
     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"))
+
+    def test_url_escape_uri(self):
+        self.assertEquals("http://svn.gnome.org/svn/gtk%2B/trunk",
+                _url_escape_uri("http://svn.gnome.org/svn/gtk+/trunk"))
+
+    def test_url_join_unescaped_path(self):
+        self.assertEquals("http://svn.gnome.org/svn/gtk%2B/trunk",
+                url_join_unescaped_path("http://svn.gnome.org/svn/", "gtk+/trunk"))

=== modified file 'transport.py'
--- a/transport.py	2008-12-08 16:01:50 +0000
+++ b/transport.py	2008-12-08 19:13:32 +0000
@@ -85,6 +85,10 @@
     return urlparse.urlunsplit((scheme, netloc, path, query, fragment))
 
 
+def url_join_unescaped_path(url, path):
+    return _url_escape_uri(urlutils.join(url, path))
+
+
 svnplus_warning_showed = False
 
 def warn_svnplus(url):




More information about the bazaar-commits mailing list