##// END OF EJS Templates
convert: properly encode subversion URLs (issue 1224)
Patrick Mezard -
r7074:b1a4f67b default
parent child Browse files
Show More
@@ -21,6 +21,7 b' import re'
21 21 import sys
22 22 import cPickle as pickle
23 23 import tempfile
24 import urllib
24 25
25 26 from mercurial import strutil, util
26 27 from mercurial.i18n import _
@@ -54,7 +55,7 b' def geturl(path):'
54 55 path = os.path.normpath(os.path.abspath(path))
55 56 if os.name == 'nt':
56 57 path = '/' + util.normpath(path)
57 return 'file://%s' % path
58 return 'file://%s' % urllib.quote(path)
58 59 return path
59 60
60 61 def optrev(number):
@@ -172,10 +173,10 b' class svn_source(converter_source):'
172 173 self.transport = transport.SvnRaTransport(url=self.url)
173 174 self.ra = self.transport.ra
174 175 self.ctx = self.transport.client
175 self.base = svn.ra.get_repos_root(self.ra)
176 self.baseurl = svn.ra.get_repos_root(self.ra)
176 177 # Module is either empty or a repository path starting with
177 178 # a slash and not ending with a slash.
178 self.module = self.url[len(self.base):]
179 self.module = urllib.unquote(self.url[len(self.baseurl):])
179 180 self.prevmodule = None
180 181 self.rootmodule = self.module
181 182 self.commits = {}
@@ -230,7 +231,7 b' class svn_source(converter_source):'
230 231
231 232 def exists(self, path, optrev):
232 233 try:
233 svn.client.ls(self.url.rstrip('/') + '/' + path,
234 svn.client.ls(self.url.rstrip('/') + '/' + urllib.quote(path),
234 235 optrev, False, self.ctx)
235 236 return True
236 237 except SubversionException, err:
@@ -279,8 +280,8 b' class svn_source(converter_source):'
279 280 # Check if branches bring a few more heads to the list
280 281 if branches:
281 282 rpath = self.url.strip('/')
282 branchnames = svn.client.ls(rpath + '/' + branches, rev, False,
283 self.ctx)
283 branchnames = svn.client.ls(rpath + '/' + urllib.quote(branches),
284 rev, False, self.ctx)
284 285 for branch in branchnames.keys():
285 286 module = '%s/%s/%s' % (oldmodule, branches, branch)
286 287 if not isdir(module, self.last_changed):
@@ -324,8 +325,8 b' class svn_source(converter_source):'
324 325 else:
325 326 # Perform a full checkout on roots
326 327 uuid, module, revnum = self.revsplit(rev)
327 entries = svn.client.ls(self.base + module, optrev(revnum),
328 True, self.ctx)
328 entries = svn.client.ls(self.baseurl + urllib.quote(module),
329 optrev(revnum), True, self.ctx)
329 330 files = [n for n,e in entries.iteritems()
330 331 if e.kind == svn.core.svn_node_file]
331 332 copies = {}
@@ -524,12 +525,12 b' class svn_source(converter_source):'
524 525 """Reparent the svn transport and return the previous parent."""
525 526 if self.prevmodule == module:
526 527 return module
527 svn_url = (self.base + module).encode(self.encoding)
528 svnurl = self.baseurl + urllib.quote(module)
528 529 prevmodule = self.prevmodule
529 530 if prevmodule is None:
530 531 prevmodule = ''
531 self.ui.debug("reparent to %s\n" % svn_url)
532 svn.ra.reparent(self.ra, svn_url)
532 self.ui.debug("reparent to %s\n" % svnurl)
533 svn.ra.reparent(self.ra, svnurl)
533 534 self.prevmodule = module
534 535 return prevmodule
535 536
@@ -872,8 +873,9 b' class svn_source(converter_source):'
872 873 def _find_children(self, path, revnum):
873 874 path = path.strip('/')
874 875 pool = Pool()
875 rpath = '/'.join([self.base, path]).strip('/')
876 return ['%s/%s' % (path, x) for x in svn.client.ls(rpath, optrev(revnum), True, self.ctx, pool).keys()]
876 rpath = '/'.join([self.baseurl, urllib.quote(path)]).strip('/')
877 return ['%s/%s' % (path, x) for x in
878 svn.client.ls(rpath, optrev(revnum), True, self.ctx, pool).keys()]
877 879
878 880 def getrelpath(self, path, module=None):
879 881 if module is None:
@@ -909,7 +911,7 b' class svn_source(converter_source):'
909 911 if not p.startswith('/'):
910 912 p = self.module + '/' + p
911 913 relpaths.append(p.strip('/'))
912 args = [self.base, relpaths, start, end, limit, discover_changed_paths,
914 args = [self.baseurl, relpaths, start, end, limit, discover_changed_paths,
913 915 strict_node_history]
914 916 arg = encodeargs(args)
915 917 hgexe = util.hgexecutable()
@@ -30,23 +30,23 b' mkdir trunk'
30 30 mkdir tags
31 31 cd ..
32 32
33 svnurl=file://$svnpath/svn-repo/projB
33 svnurl=file://$svnpath/svn-repo/proj%20B
34 34 svn import -m "init projB" projB $svnurl | fix_path
35 35
36 36
37 37 echo % update svn repository
38 38 svn co $svnurl/trunk B | fix_path
39 39 cd B
40 echo hello > letter.txt
41 svn add letter.txt
40 echo hello > 'letter .txt'
41 svn add 'letter .txt'
42 42 svn ci -m hello
43 43
44 "$TESTDIR/svn-safe-append.py" world letter.txt
44 "$TESTDIR/svn-safe-append.py" world 'letter .txt'
45 45 svn ci -m world
46 46
47 47 svn copy -m "tag v0.1" $svnurl/trunk $svnurl/tags/v0.1
48 48
49 "$TESTDIR/svn-safe-append.py" 'nice day today!' letter.txt
49 "$TESTDIR/svn-safe-append.py" 'nice day today!' 'letter .txt'
50 50 svn ci -m "nice day"
51 51 cd ..
52 52
@@ -55,7 +55,7 b' hg convert $svnurl B-hg'
55 55
56 56 echo % update svn repository again
57 57 cd B
58 "$TESTDIR/svn-safe-append.py" "see second letter" letter.txt
58 "$TESTDIR/svn-safe-append.py" "see second letter" 'letter .txt'
59 59 echo "nice to meet you" > letter2.txt
60 60 svn add letter2.txt
61 61 svn ci -m "second letter"
General Comments 0
You need to be logged in to leave comments. Login now