# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 2016-12-17 14:44:24 # Node ID bb77654dc7ae3ff9e246086d964154d9b2e0abfe # Parent cfe66dcf45c00c75449dfc6bd48d9fdf465deec7 py3: replace os.sep with pycompat.ossep (part 3 of 4) diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -731,7 +731,7 @@ def copy(ui, repo, pats, opts, rename=Fa else: striplen = len(abspfx) if striplen: - striplen += len(os.sep) + striplen += len(pycompat.ossep) res = lambda p: os.path.join(dest, util.localpath(p)[striplen:]) elif destdirexists: res = lambda p: os.path.join(dest, @@ -765,12 +765,12 @@ def copy(ui, repo, pats, opts, rename=Fa abspfx = util.localpath(abspfx) striplen = len(abspfx) if striplen: - striplen += len(os.sep) + striplen += len(pycompat.ossep) if os.path.isdir(os.path.join(dest, os.path.split(abspfx)[1])): score = evalpath(striplen) striplen1 = len(os.path.split(abspfx)[0]) if striplen1: - striplen1 += len(os.sep) + striplen1 += len(pycompat.ossep) if evalpath(striplen1) > score: striplen = striplen1 res = lambda p: os.path.join(dest, diff --git a/mercurial/hgweb/common.py b/mercurial/hgweb/common.py --- a/mercurial/hgweb/common.py +++ b/mercurial/hgweb/common.py @@ -12,7 +12,10 @@ import errno import mimetypes import os -from .. import util +from .. import ( + pycompat, + util, +) httpserver = util.httpserver @@ -139,7 +142,8 @@ def staticfile(directory, fname, req): parts = fname.split('/') for part in parts: if (part in ('', os.curdir, os.pardir) or - os.sep in part or os.altsep is not None and os.altsep in part): + pycompat.ossep in part or + os.altsep is not None and os.altsep in part): return fpath = os.path.join(*parts) if isinstance(directory, str): diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -31,6 +31,7 @@ from . import ( node, pathutil, phases, + pycompat, scmutil, util, ) @@ -1172,7 +1173,7 @@ class svnsubrepo(abstractsubrepo): changes.append(path) for path in changes: for ext in externals: - if path == ext or path.startswith(ext + os.sep): + if path == ext or path.startswith(ext + pycompat.ossep): return True, True, bool(missing) return bool(changes), False, bool(missing) diff --git a/mercurial/templater.py b/mercurial/templater.py --- a/mercurial/templater.py +++ b/mercurial/templater.py @@ -17,6 +17,7 @@ from . import ( error, minirst, parser, + pycompat, registrar, revset as revsetmod, templatefilters, @@ -1243,7 +1244,7 @@ def stylemap(styles, paths=None): # only plain name is allowed to honor template paths if (not style or style in (os.curdir, os.pardir) - or os.sep in style + or pycompat.ossep in style or os.altsep and os.altsep in style): continue locations = [os.path.join(style, 'map'), 'map-' + style] diff --git a/mercurial/windows.py b/mercurial/windows.py --- a/mercurial/windows.py +++ b/mercurial/windows.py @@ -215,7 +215,7 @@ def setbinary(fd): msvcrt.setmode(fno(), os.O_BINARY) def pconvert(path): - return path.replace(os.sep, '/') + return path.replace(pycompat.ossep, '/') def localpath(path): return path.replace('/', '\\') @@ -316,7 +316,7 @@ def findexe(command): return executable return None - if os.sep in command: + if pycompat.ossep in command: return findexisting(command) for path in os.environ.get('PATH', '').split(pycompat.ospathsep):