[PATCH] Fix issue 1782 don’t do url2pathname conversion for urls
Laurens Holst
laurens.nospam at grauw.nl
Fri Aug 7 15:18:05 CDT 2009
Dirkjan Ochtman schreef:
> Can you test it like this?
>
>
>> diff -r 2de7d96593db -r 3ca6009819d0 hgext/convert/subversion.py
>> --- a/hgext/convert/subversion.py Mon Jul 27 02:27:24 2009 +0200
>> +++ b/hgext/convert/subversion.py Fri Aug 07 01:15:16 2009 +0200
>> @@ -153,11 +153,13 @@
>> def issvnurl(url):
>> try:
>> proto, path = url.split('://', 1)
>> - path = urllib.url2pathname(path)
>> except ValueError:
>> proto = 'file'
>> path = os.path.abspath(url)
>> - path = path.replace(os.sep, '/')
>> + if proto == 'file':
>> + path = urllib.url2pathname(path)
>> + path = path.replace(os.sep, '/')
>> check = protomap.get(proto, lambda p, p2: False)
>> while '/' in path:
>> if check(path, proto):
>>
>
> It seems the url2pathname() call probably won't raise a ValueError (or
> at least not the one the except clause is fixing up).
>
Hmm, are you sure? os.path.abspath already returns an OS-style path, and
this might break for relative paths to a local filesystem SVN install
(which I don’t have setup on my Windows machine to test).
E.g.:
>>> os.path.abspath('..\\x\\y.z')
'C:\\Program Files (x86)\\x\\y.z'
vs.
>>> urllib.url2pathname(os.path.abspath('..\\x\\y.z'))
'C:\\\\Program Files (x86)\\x\\y.z'
Note the extra backslash after C:\. Although os.path.exists() which is
called shortly afterwards seems to grok it, I’d rather not pass path
parsing edge cases around :). So although it is probably good form to
avoid unrelated statements in a try block if possible, I think here it
is better to keep url2pathname() in the try.
By the way, I also ran the tests on Linux with this patch, no problems.
Well, one (test-inotify-debuginotify), but that one is also there
without my patch. Don’t really have a Windows testing environment setup
properly for testing on Windows.
~Laurens
--
~~ Ushiko-san! Kimi wa doushite, Ushiko-san nan da!! ~~
Laurens Holst, student, Utrecht University, the Netherlands
Website: www.grauw.nl. Backbase employee; www.backbase.com
More information about the Mercurial-devel
mailing list