Mercurial > public > mercurial-scm > hg
comparison mercurial/util.py @ 30625:bcf4a975f93d
py3: replace os.altsep with pycompat.altsep
All the occurences of os.altsep are replaced with pycompat.altsep which
returns bytes.
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Sun, 18 Dec 2016 01:17:12 +0530 |
parents | 1112ff99d965 |
children | 344e68882cd3 |
comparison
equal
deleted
inserted
replaced
30624:a82a6eee2613 | 30625:bcf4a975f93d |
---|---|
1302 ''' | 1302 ''' |
1303 def _makefspathcacheentry(dir): | 1303 def _makefspathcacheentry(dir): |
1304 return dict((normcase(n), n) for n in os.listdir(dir)) | 1304 return dict((normcase(n), n) for n in os.listdir(dir)) |
1305 | 1305 |
1306 seps = pycompat.ossep | 1306 seps = pycompat.ossep |
1307 if os.altsep: | 1307 if pycompat.osaltsep: |
1308 seps = seps + os.altsep | 1308 seps = seps + pycompat.osaltsep |
1309 # Protect backslashes. This gets silly very quickly. | 1309 # Protect backslashes. This gets silly very quickly. |
1310 seps.replace('\\','\\\\') | 1310 seps.replace('\\','\\\\') |
1311 pattern = remod.compile(r'([^%s]+)|([%s]+)' % (seps, seps)) | 1311 pattern = remod.compile(r'([^%s]+)|([%s]+)' % (seps, seps)) |
1312 dir = os.path.normpath(root) | 1312 dir = os.path.normpath(root) |
1313 result = [] | 1313 result = [] |
1369 pass | 1369 pass |
1370 | 1370 |
1371 def endswithsep(path): | 1371 def endswithsep(path): |
1372 '''Check path ends with os.sep or os.altsep.''' | 1372 '''Check path ends with os.sep or os.altsep.''' |
1373 return (path.endswith(pycompat.ossep) | 1373 return (path.endswith(pycompat.ossep) |
1374 or os.altsep and path.endswith(os.altsep)) | 1374 or pycompat.osaltsep and path.endswith(pycompat.osaltsep)) |
1375 | 1375 |
1376 def splitpath(path): | 1376 def splitpath(path): |
1377 '''Split path by os.sep. | 1377 '''Split path by os.sep. |
1378 Note that this function does not use os.altsep because this is | 1378 Note that this function does not use os.altsep because this is |
1379 an alternative of simple "xxx.split(os.sep)". | 1379 an alternative of simple "xxx.split(os.sep)". |