diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2356,7 +2356,7 @@ def debugpathcomplete(ui, repo, *specs, def complete(path, acceptable): dirstate = repo.dirstate spec = os.path.normpath(os.path.join(pycompat.getcwd(), path)) - rootdir = repo.root + os.sep + rootdir = repo.root + pycompat.ossep if spec != repo.root and not spec.startswith(rootdir): return [], [] if os.path.isdir(spec): @@ -2364,7 +2364,7 @@ def debugpathcomplete(ui, repo, *specs, spec = spec[len(rootdir):] fixpaths = pycompat.ossep != '/' if fixpaths: - spec = spec.replace(os.sep, '/') + spec = spec.replace(pycompat.ossep, '/') speclen = len(spec) fullpaths = opts['full'] files, dirs = set(), set() @@ -2372,11 +2372,11 @@ def debugpathcomplete(ui, repo, *specs, for f, st in dirstate.iteritems(): if f.startswith(spec) and st[0] in acceptable: if fixpaths: - f = f.replace('/', os.sep) + f = f.replace('/', pycompat.ossep) if fullpaths: addfile(f) continue - s = f.find(os.sep, speclen) + s = f.find(pycompat.ossep, speclen) if s >= 0: adddir(f[:s]) else: diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -916,7 +916,7 @@ def pathto(root, n1, n2): a.pop() b.pop() b.reverse() - return os.sep.join((['..'] * len(a)) + b) or '.' + return pycompat.ossep.join((['..'] * len(a)) + b) or '.' def mainfrozen(): """return True if we are a frozen executable. @@ -1303,7 +1303,7 @@ def fspath(name, root): def _makefspathcacheentry(dir): return dict((normcase(n), n) for n in os.listdir(dir)) - seps = os.sep + seps = pycompat.ossep if os.altsep: seps = seps + os.altsep # Protect backslashes. This gets silly very quickly. @@ -1370,7 +1370,8 @@ def checknlink(testfile): def endswithsep(path): '''Check path ends with os.sep or os.altsep.''' - return path.endswith(os.sep) or os.altsep and path.endswith(os.altsep) + return (path.endswith(pycompat.ossep) + or os.altsep and path.endswith(os.altsep)) def splitpath(path): '''Split path by os.sep. @@ -1378,7 +1379,7 @@ def splitpath(path): an alternative of simple "xxx.split(os.sep)". It is recommended to use os.path.normpath() before using this function if need.''' - return path.split(os.sep) + return path.split(pycompat.ossep) def gui(): '''Are we running in a GUI?'''