##// END OF EJS Templates
convert: convert URLs to UTF-8 for Subversion...
Manuel Jacob -
r45562:e54c3caf stable
parent child Browse files
Show More
@@ -65,10 +65,10 b' except ImportError:'
65 65 svn = None
66 66
67 67
68 # In Subversion, paths are Unicode (encoded as UTF-8), which Subversion
69 # converts from / to native strings when interfacing with the OS. When passing
70 # paths to Subversion, we have to recode them such that it roundstrips with
71 # what Subversion is doing.
68 # In Subversion, paths and URLs are Unicode (encoded as UTF-8), which
69 # Subversion converts from / to native strings when interfacing with the OS.
70 # When passing paths and URLs to Subversion, we have to recode them such that
71 # it roundstrips with what Subversion is doing.
72 72
73 73 fsencoding = None
74 74
@@ -141,7 +141,9 b' def quote(s):'
141 141
142 142 def geturl(path):
143 143 try:
144 return svn.client.url_from_path(svn.core.svn_path_canonicalize(path))
144 return svn.client.url_from_path(
145 svn.core.svn_path_canonicalize(fs2svn(path))
146 )
145 147 except svn.core.SubversionException:
146 148 # svn.client.url_from_path() fails with local repositories
147 149 pass
@@ -358,6 +360,19 b' def issvnurl(ui, url):'
358 360 and path[2:6].lower() == b'%3a/'
359 361 ):
360 362 path = path[:2] + b':/' + path[6:]
363 try:
364 path.decode(fsencoding)
365 except UnicodeDecodeError:
366 ui.warn(
367 _(
368 b'Subversion requires that file URLs can be converted '
369 b'to Unicode using the current locale encoding (%s)\n'
370 )
371 % pycompat.sysbytes(fsencoding)
372 )
373 return False
374 # FIXME: The following reasoning and logic is wrong and will be
375 # fixed in a following changeset.
361 376 # pycompat.fsdecode() / pycompat.fsencode() are used so that bytes
362 377 # in the URL roundtrip correctly on Unix. urlreq.url2pathname() on
363 378 # py3 will decode percent-encoded bytes using the utf-8 encoding
@@ -182,6 +182,20 b" tests) don't work."
182 182 cannot find required "p4" tool
183 183 abort: \xff: missing or unsupported repository (glob) (esc)
184 184 [255]
185 $ hg convert file://$TESTTMP/$XFF test
186 initializing destination test repository
187 Subversion requires that file URLs can be converted to Unicode using the current locale encoding (ascii)
188 file:/*/$TESTTMP/\xff does not look like a CVS checkout (glob) (esc)
189 $TESTTMP/file:$TESTTMP/\xff does not look like a Git repository (esc)
190 file:/*/$TESTTMP/\xff does not look like a Subversion repository (glob) (esc)
191 file:/*/$TESTTMP/\xff is not a local Mercurial repository (glob) (esc)
192 file:/*/$TESTTMP/\xff does not look like a darcs repository (glob) (esc)
193 file:/*/$TESTTMP/\xff does not look like a monotone repository (glob) (esc)
194 file:/*/$TESTTMP/\xff does not look like a GNU Arch repository (glob) (esc)
195 file:/*/$TESTTMP/\xff does not look like a Bazaar repository (glob) (esc)
196 file:/*/$TESTTMP/\xff does not look like a P4 repository (glob) (esc)
197 abort: file:/*/$TESTTMP/\xff: missing or unsupported repository (glob) (esc)
198 [255]
185 199
186 200 #if py3
187 201 For now, on Python 3, we abort when encountering non-UTF-8 percent-encoded
General Comments 0
You need to be logged in to leave comments. Login now