##// END OF EJS Templates
py3: pass native string to urlreq.url2pathname()...
Manuel Jacob -
r45495:75b59d22 stable
parent child Browse files
Show More
@@ -321,7 +321,26 b' def issvnurl(ui, url):'
321 321 and path[2:6].lower() == b'%3a/'
322 322 ):
323 323 path = path[:2] + b':/' + path[6:]
324 path = urlreq.url2pathname(path)
324 # pycompat.fsdecode() / pycompat.fsencode() are used so that bytes
325 # in the URL roundtrip correctly on Unix. urlreq.url2pathname() on
326 # py3 will decode percent-encoded bytes using the utf-8 encoding
327 # and the "replace" error handler. This means that it will not
328 # preserve non-UTF-8 bytes (https://bugs.python.org/issue40983).
329 # url.open() uses the reverse function (urlreq.pathname2url()) and
330 # has a similar problem
331 # (https://bz.mercurial-scm.org/show_bug.cgi?id=6357). It makes
332 # sense to solve both problems together and handle all file URLs
333 # consistently. For now, we warn.
334 unicodepath = urlreq.url2pathname(pycompat.fsdecode(path))
335 if pycompat.ispy3 and u'\N{REPLACEMENT CHARACTER}' in unicodepath:
336 ui.warn(
337 _(
338 b'on Python 3, we currently do not support non-UTF-8 '
339 b'percent-encoded bytes in file URLs for Subversion '
340 b'repositories\n'
341 )
342 )
343 path = pycompat.fsencode(unicodepath)
325 344 except ValueError:
326 345 proto = b'file'
327 346 path = os.path.abspath(url)
@@ -152,3 +152,23 b' Check tags are in UTF-8'
152 152 f7e66f98380ed1e53a797c5c7a7a2616a7ab377d branch\xc3\xa9 (esc)
153 153
154 154 $ cd ..
155
156 #if py3
157 For now, on Python 3, we abort when encountering non-UTF-8 percent-encoded
158 bytes in a filename.
159
160 $ hg convert file:///%ff test
161 initializing destination test repository
162 on Python 3, we currently do not support non-UTF-8 percent-encoded bytes in file URLs for Subversion repositories
163 file:///%ff does not look like a CVS checkout
164 $TESTTMP/file:/%ff does not look like a Git repository
165 file:///%ff does not look like a Subversion repository
166 file:///%ff is not a local Mercurial repository
167 file:///%ff does not look like a darcs repository
168 file:///%ff does not look like a monotone repository
169 file:///%ff does not look like a GNU Arch repository
170 file:///%ff does not look like a Bazaar repository
171 file:///%ff does not look like a P4 repository
172 abort: file:///%ff: missing or unsupported repository
173 [255]
174 #endif
General Comments 0
You need to be logged in to leave comments. Login now