##// 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 import sys
21 import sys
22 import cPickle as pickle
22 import cPickle as pickle
23 import tempfile
23 import tempfile
24 import urllib
24
25
25 from mercurial import strutil, util
26 from mercurial import strutil, util
26 from mercurial.i18n import _
27 from mercurial.i18n import _
@@ -54,7 +55,7 b' def geturl(path):'
54 path = os.path.normpath(os.path.abspath(path))
55 path = os.path.normpath(os.path.abspath(path))
55 if os.name == 'nt':
56 if os.name == 'nt':
56 path = '/' + util.normpath(path)
57 path = '/' + util.normpath(path)
57 return 'file://%s' % path
58 return 'file://%s' % urllib.quote(path)
58 return path
59 return path
59
60
60 def optrev(number):
61 def optrev(number):
@@ -172,10 +173,10 b' class svn_source(converter_source):'
172 self.transport = transport.SvnRaTransport(url=self.url)
173 self.transport = transport.SvnRaTransport(url=self.url)
173 self.ra = self.transport.ra
174 self.ra = self.transport.ra
174 self.ctx = self.transport.client
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 # Module is either empty or a repository path starting with
177 # Module is either empty or a repository path starting with
177 # a slash and not ending with a slash.
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 self.prevmodule = None
180 self.prevmodule = None
180 self.rootmodule = self.module
181 self.rootmodule = self.module
181 self.commits = {}
182 self.commits = {}
@@ -230,7 +231,7 b' class svn_source(converter_source):'
230
231
231 def exists(self, path, optrev):
232 def exists(self, path, optrev):
232 try:
233 try:
233 svn.client.ls(self.url.rstrip('/') + '/' + path,
234 svn.client.ls(self.url.rstrip('/') + '/' + urllib.quote(path),
234 optrev, False, self.ctx)
235 optrev, False, self.ctx)
235 return True
236 return True
236 except SubversionException, err:
237 except SubversionException, err:
@@ -279,8 +280,8 b' class svn_source(converter_source):'
279 # Check if branches bring a few more heads to the list
280 # Check if branches bring a few more heads to the list
280 if branches:
281 if branches:
281 rpath = self.url.strip('/')
282 rpath = self.url.strip('/')
282 branchnames = svn.client.ls(rpath + '/' + branches, rev, False,
283 branchnames = svn.client.ls(rpath + '/' + urllib.quote(branches),
283 self.ctx)
284 rev, False, self.ctx)
284 for branch in branchnames.keys():
285 for branch in branchnames.keys():
285 module = '%s/%s/%s' % (oldmodule, branches, branch)
286 module = '%s/%s/%s' % (oldmodule, branches, branch)
286 if not isdir(module, self.last_changed):
287 if not isdir(module, self.last_changed):
@@ -324,8 +325,8 b' class svn_source(converter_source):'
324 else:
325 else:
325 # Perform a full checkout on roots
326 # Perform a full checkout on roots
326 uuid, module, revnum = self.revsplit(rev)
327 uuid, module, revnum = self.revsplit(rev)
327 entries = svn.client.ls(self.base + module, optrev(revnum),
328 entries = svn.client.ls(self.baseurl + urllib.quote(module),
328 True, self.ctx)
329 optrev(revnum), True, self.ctx)
329 files = [n for n,e in entries.iteritems()
330 files = [n for n,e in entries.iteritems()
330 if e.kind == svn.core.svn_node_file]
331 if e.kind == svn.core.svn_node_file]
331 copies = {}
332 copies = {}
@@ -524,12 +525,12 b' class svn_source(converter_source):'
524 """Reparent the svn transport and return the previous parent."""
525 """Reparent the svn transport and return the previous parent."""
525 if self.prevmodule == module:
526 if self.prevmodule == module:
526 return module
527 return module
527 svn_url = (self.base + module).encode(self.encoding)
528 svnurl = self.baseurl + urllib.quote(module)
528 prevmodule = self.prevmodule
529 prevmodule = self.prevmodule
529 if prevmodule is None:
530 if prevmodule is None:
530 prevmodule = ''
531 prevmodule = ''
531 self.ui.debug("reparent to %s\n" % svn_url)
532 self.ui.debug("reparent to %s\n" % svnurl)
532 svn.ra.reparent(self.ra, svn_url)
533 svn.ra.reparent(self.ra, svnurl)
533 self.prevmodule = module
534 self.prevmodule = module
534 return prevmodule
535 return prevmodule
535
536
@@ -872,8 +873,9 b' class svn_source(converter_source):'
872 def _find_children(self, path, revnum):
873 def _find_children(self, path, revnum):
873 path = path.strip('/')
874 path = path.strip('/')
874 pool = Pool()
875 pool = Pool()
875 rpath = '/'.join([self.base, path]).strip('/')
876 rpath = '/'.join([self.baseurl, urllib.quote(path)]).strip('/')
876 return ['%s/%s' % (path, x) for x in svn.client.ls(rpath, optrev(revnum), True, self.ctx, pool).keys()]
877 return ['%s/%s' % (path, x) for x in
878 svn.client.ls(rpath, optrev(revnum), True, self.ctx, pool).keys()]
877
879
878 def getrelpath(self, path, module=None):
880 def getrelpath(self, path, module=None):
879 if module is None:
881 if module is None:
@@ -909,7 +911,7 b' class svn_source(converter_source):'
909 if not p.startswith('/'):
911 if not p.startswith('/'):
910 p = self.module + '/' + p
912 p = self.module + '/' + p
911 relpaths.append(p.strip('/'))
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 strict_node_history]
915 strict_node_history]
914 arg = encodeargs(args)
916 arg = encodeargs(args)
915 hgexe = util.hgexecutable()
917 hgexe = util.hgexecutable()
@@ -30,23 +30,23 b' mkdir trunk'
30 mkdir tags
30 mkdir tags
31 cd ..
31 cd ..
32
32
33 svnurl=file://$svnpath/svn-repo/projB
33 svnurl=file://$svnpath/svn-repo/proj%20B
34 svn import -m "init projB" projB $svnurl | fix_path
34 svn import -m "init projB" projB $svnurl | fix_path
35
35
36
36
37 echo % update svn repository
37 echo % update svn repository
38 svn co $svnurl/trunk B | fix_path
38 svn co $svnurl/trunk B | fix_path
39 cd B
39 cd B
40 echo hello > letter.txt
40 echo hello > 'letter .txt'
41 svn add letter.txt
41 svn add 'letter .txt'
42 svn ci -m hello
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 svn ci -m world
45 svn ci -m world
46
46
47 svn copy -m "tag v0.1" $svnurl/trunk $svnurl/tags/v0.1
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 svn ci -m "nice day"
50 svn ci -m "nice day"
51 cd ..
51 cd ..
52
52
@@ -55,7 +55,7 b' hg convert $svnurl B-hg'
55
55
56 echo % update svn repository again
56 echo % update svn repository again
57 cd B
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 echo "nice to meet you" > letter2.txt
59 echo "nice to meet you" > letter2.txt
60 svn add letter2.txt
60 svn add letter2.txt
61 svn ci -m "second letter"
61 svn ci -m "second letter"
@@ -7,16 +7,16 b' Adding projB/tags'
7 Committed revision 1.
7 Committed revision 1.
8 % update svn repository
8 % update svn repository
9 Checked out revision 1.
9 Checked out revision 1.
10 A letter.txt
10 A letter .txt
11 Adding letter.txt
11 Adding letter .txt
12 Transmitting file data .
12 Transmitting file data .
13 Committed revision 2.
13 Committed revision 2.
14 Sending letter.txt
14 Sending letter .txt
15 Transmitting file data .
15 Transmitting file data .
16 Committed revision 3.
16 Committed revision 3.
17
17
18 Committed revision 4.
18 Committed revision 4.
19 Sending letter.txt
19 Sending letter .txt
20 Transmitting file data .
20 Transmitting file data .
21 Committed revision 5.
21 Committed revision 5.
22 % convert to hg once
22 % convert to hg once
@@ -31,7 +31,7 b' 0 nice day'
31 updating tags
31 updating tags
32 % update svn repository again
32 % update svn repository again
33 A letter2.txt
33 A letter2.txt
34 Sending letter.txt
34 Sending letter .txt
35 Adding letter2.txt
35 Adding letter2.txt
36 Transmitting file data ..
36 Transmitting file data ..
37 Committed revision 6.
37 Committed revision 6.
@@ -51,15 +51,15 b' o 7 update tags files: .hgtags'
51 |
51 |
52 o 6 work in progress files: letter2.txt
52 o 6 work in progress files: letter2.txt
53 |
53 |
54 o 5 second letter files: letter.txt letter2.txt
54 o 5 second letter files: letter .txt letter2.txt
55 |
55 |
56 o 4 update tags files: .hgtags
56 o 4 update tags files: .hgtags
57 |
57 |
58 o 3 nice day files: letter.txt
58 o 3 nice day files: letter .txt
59 |
59 |
60 o 2 world files: letter.txt
60 o 2 world files: letter .txt
61 |
61 |
62 o 1 hello files: letter.txt
62 o 1 hello files: letter .txt
63 |
63 |
64 o 0 init projB files:
64 o 0 init projB files:
65
65
General Comments 0
You need to be logged in to leave comments. Login now