changeset 30615:bb77654dc7ae

py3: replace os.sep with pycompat.ossep (part 3 of 4)
author Pulkit Goyal <7895pulkit@gmail.com>
date Sat, 17 Dec 2016 20:14:24 +0530
parents cfe66dcf45c0
children 6f9fcd29e290
files mercurial/cmdutil.py mercurial/hgweb/common.py mercurial/subrepo.py mercurial/templater.py mercurial/windows.py
diffstat 5 files changed, 15 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Sat Dec 17 20:02:50 2016 +0530
+++ b/mercurial/cmdutil.py	Sat Dec 17 20:14:24 2016 +0530
@@ -731,7 +731,7 @@
             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 @@
                 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,
--- a/mercurial/hgweb/common.py	Sat Dec 17 20:02:50 2016 +0530
+++ b/mercurial/hgweb/common.py	Sat Dec 17 20:14:24 2016 +0530
@@ -12,7 +12,10 @@
 import mimetypes
 import os
 
-from .. import util
+from .. import (
+    pycompat,
+    util,
+)
 
 httpserver = util.httpserver
 
@@ -139,7 +142,8 @@
     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):
--- a/mercurial/subrepo.py	Sat Dec 17 20:02:50 2016 +0530
+++ b/mercurial/subrepo.py	Sat Dec 17 20:14:24 2016 +0530
@@ -31,6 +31,7 @@
     node,
     pathutil,
     phases,
+    pycompat,
     scmutil,
     util,
 )
@@ -1172,7 +1173,7 @@
                 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)
 
--- a/mercurial/templater.py	Sat Dec 17 20:02:50 2016 +0530
+++ b/mercurial/templater.py	Sat Dec 17 20:14:24 2016 +0530
@@ -17,6 +17,7 @@
     error,
     minirst,
     parser,
+    pycompat,
     registrar,
     revset as revsetmod,
     templatefilters,
@@ -1243,7 +1244,7 @@
         # 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]
--- a/mercurial/windows.py	Sat Dec 17 20:02:50 2016 +0530
+++ b/mercurial/windows.py	Sat Dec 17 20:14:24 2016 +0530
@@ -215,7 +215,7 @@
         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 @@
                 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):