changeset 671:e910e3ebd23b

svnmeta: strip all repeated slashes from subdir
author Peter Arrenbrecht <peter.arrenbre...@gmail.com>
date Wed, 28 Jul 2010 14:47:44 +0200
parents 186f13b35d15
children 2cc1342d4476
files hgsubversion/svnmeta.py tests/test_push_command.py
diffstat 2 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/svnmeta.py
+++ b/hgsubversion/svnmeta.py
@@ -55,9 +55,11 @@ class SVNMeta(object):
                                                  'usebranchnames', True)
 
         # FIXME: test that this hasn't changed! defer & compare?
+        if subdir:
+            # strip leading and trailing slashes
+            # collapse all repeated slashes to a single one
+            subdir = '/'.join(p for p in subdir.split('/') if p)
         self.subdir = subdir
-        if self.subdir and self.subdir[0] == '/':
-            self.subdir = self.subdir[1:]
         self.branches = {}
         if os.path.exists(self.branch_info_file):
             f = open(self.branch_info_file)
--- a/tests/test_push_command.py
+++ b/tests/test_push_command.py
@@ -76,7 +76,7 @@ class PushTests(test_util.TestBase):
         tip = self.repo['tip']
         self.assertEqual(new_hash, tip.node())
 
-    def test_push_over_svnserve(self, commit=True):
+    def internal_push_over_svnserve(self, subdir='', commit=True):
         test_util.load_svndump_fixture(self.repo_path, 'simple_branch.svndump')
         open(os.path.join(self.repo_path, 'conf', 'svnserve.conf'),
              'w').write('[general]\nanon-access=write\n[sasl]\n')
@@ -94,7 +94,8 @@ class PushTests(test_util.TestBase):
             time.sleep(2)
             import shutil
             shutil.rmtree(self.wc_path)
-            commands.clone(self.ui(), 'svn://%s:%d/' % (self.host, self.port),
+            commands.clone(self.ui(),
+                           'svn://%s:%d/%s' % (self.host, self.port, subdir),
                            self.wc_path, noupdate=True)
 
             repo = self.repo
@@ -135,6 +136,12 @@ class PushTests(test_util.TestBase):
             # TODO: use svnserve.kill() in Python >2.5
             test_util.kill_process(svnserve)
 
+    def test_push_over_svnserve(self):
+        self.internal_push_over_svnserve()
+
+    def test_push_over_svnserve_with_subdir(self):
+        self.internal_push_over_svnserve(subdir='///branches////the_branch/////')
+
     def test_push_to_default(self, commit=True):
         repo = self.repo
         old_tip = repo['tip'].node()