comparison hgext/convert/subversion.py @ 34645:75979c8d4572

codemod: use pycompat.iswindows This is done by: sed -i "s/pycompat\.osname == 'nt'/pycompat.iswindows/" **/*.py sed -i "s/pycompat\.osname != 'nt'/not pycompat.iswindows/" **/*.py sed -i 's/pycompat.osname == "nt"/pycompat.iswindows/' **/*.py Differential Revision: https://phab.mercurial-scm.org/D1034
author Jun Wu <quark@fb.com>
date Thu, 12 Oct 2017 23:30:46 -0700
parents 0cfa7d9b889c
children effae88bccdb
comparison
equal deleted inserted replaced
34644:c0a6c19690ff 34645:75979c8d4572
101 except svn.core.SubversionException: 101 except svn.core.SubversionException:
102 # svn.client.url_from_path() fails with local repositories 102 # svn.client.url_from_path() fails with local repositories
103 pass 103 pass
104 if os.path.isdir(path): 104 if os.path.isdir(path):
105 path = os.path.normpath(os.path.abspath(path)) 105 path = os.path.normpath(os.path.abspath(path))
106 if pycompat.osname == 'nt': 106 if pycompat.iswindows:
107 path = '/' + util.normpath(path) 107 path = '/' + util.normpath(path)
108 # Module URL is later compared with the repository URL returned 108 # Module URL is later compared with the repository URL returned
109 # by svn API, which is UTF-8. 109 # by svn API, which is UTF-8.
110 path = encoding.tolocal(path) 110 path = encoding.tolocal(path)
111 path = 'file://%s' % quote(path) 111 path = 'file://%s' % quote(path)
252 } 252 }
253 def issvnurl(ui, url): 253 def issvnurl(ui, url):
254 try: 254 try:
255 proto, path = url.split('://', 1) 255 proto, path = url.split('://', 1)
256 if proto == 'file': 256 if proto == 'file':
257 if (pycompat.osname == 'nt' and path[:1] == '/' 257 if (pycompat.iswindows and path[:1] == '/'
258 and path[1:2].isalpha() and path[2:6].lower() == '%3a/'): 258 and path[1:2].isalpha() and path[2:6].lower() == '%3a/'):
259 path = path[:2] + ':/' + path[6:] 259 path = path[:2] + ':/' + path[6:]
260 path = urlreq.url2pathname(path) 260 path = urlreq.url2pathname(path)
261 except ValueError: 261 except ValueError:
262 proto = 'file' 262 proto = 'file'