[PATCH 5 of 6] py3: replace os.sep with pycompat.ossep (part 3 of 4)

Pulkit Goyal 7895pulkit at gmail.com
Sat Dec 17 10:41:44 EST 2016


# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1481985864 -19800
#      Sat Dec 17 20:14:24 2016 +0530
# Node ID c816d1b5b807f8076b027f9cb9ffdeafe5fd7e62
# Parent  a82ca84371f5f4b4213aec534ab0ccdfbd04cf9b
py3: replace os.sep with pycompat.ossep (part 3 of 4)

diff -r a82ca84371f5 -r c816d1b5b807 mercurial/cmdutil.py
--- 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,
diff -r a82ca84371f5 -r c816d1b5b807 mercurial/hgweb/common.py
--- 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,7 @@
     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 -r a82ca84371f5 -r c816d1b5b807 mercurial/subrepo.py
--- 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)
 
diff -r a82ca84371f5 -r c816d1b5b807 mercurial/templater.py
--- 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]
diff -r a82ca84371f5 -r c816d1b5b807 mercurial/windows.py
--- 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):


More information about the Mercurial-devel mailing list