##// 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 svn = None
65 svn = None
66
66
67
67
68 # In Subversion, paths are Unicode (encoded as UTF-8), which Subversion
68 # In Subversion, paths and URLs are Unicode (encoded as UTF-8), which
69 # converts from / to native strings when interfacing with the OS. When passing
69 # Subversion converts from / to native strings when interfacing with the OS.
70 # paths to Subversion, we have to recode them such that it roundstrips with
70 # When passing paths and URLs to Subversion, we have to recode them such that
71 # what Subversion is doing.
71 # it roundstrips with what Subversion is doing.
72
72
73 fsencoding = None
73 fsencoding = None
74
74
@@ -141,7 +141,9 b' def quote(s):'
141
141
142 def geturl(path):
142 def geturl(path):
143 try:
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 except svn.core.SubversionException:
147 except svn.core.SubversionException:
146 # svn.client.url_from_path() fails with local repositories
148 # svn.client.url_from_path() fails with local repositories
147 pass
149 pass
@@ -358,6 +360,19 b' def issvnurl(ui, url):'
358 and path[2:6].lower() == b'%3a/'
360 and path[2:6].lower() == b'%3a/'
359 ):
361 ):
360 path = path[:2] + b':/' + path[6:]
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 # pycompat.fsdecode() / pycompat.fsencode() are used so that bytes
376 # pycompat.fsdecode() / pycompat.fsencode() are used so that bytes
362 # in the URL roundtrip correctly on Unix. urlreq.url2pathname() on
377 # in the URL roundtrip correctly on Unix. urlreq.url2pathname() on
363 # py3 will decode percent-encoded bytes using the utf-8 encoding
378 # py3 will decode percent-encoded bytes using the utf-8 encoding
@@ -182,6 +182,20 b" tests) don't work."
182 cannot find required "p4" tool
182 cannot find required "p4" tool
183 abort: \xff: missing or unsupported repository (glob) (esc)
183 abort: \xff: missing or unsupported repository (glob) (esc)
184 [255]
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 #if py3
200 #if py3
187 For now, on Python 3, we abort when encountering non-UTF-8 percent-encoded
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