Patchwork [7,of,9] py3: replace os.name with pycompat.osname (part 2 of 2)

login
register
mail settings
Submitter Pulkit Goyal
Date Dec. 20, 2016, 2:03 p.m.
Message ID <173684dd16962b352416.1482242633@pulkit-goyal.Home>
Download mbox | patch
Permalink /patch/17979/
State Accepted
Headers show

Comments

Pulkit Goyal - Dec. 20, 2016, 2:03 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1482087492 -19800
#      Mon Dec 19 00:28:12 2016 +0530
# Node ID 173684dd16962b352416332ee66bd1880497aa16
# Parent  e39ac3774a1c6703231bb5511ce082c50726b2ca
py3: replace os.name with pycompat.osname (part 2 of 2)

Patch

diff -r e39ac3774a1c -r 173684dd1696 hgext/color.py
--- a/hgext/color.py	Mon Dec 19 00:16:52 2016 +0530
+++ b/hgext/color.py	Mon Dec 19 00:28:12 2016 +0530
@@ -164,8 +164,6 @@ 
 
 from __future__ import absolute_import
 
-import os
-
 from mercurial.i18n import _
 from mercurial import (
     cmdutil,
@@ -173,6 +171,7 @@ 
     dispatch,
     encoding,
     extensions,
+    pycompat,
     subrepo,
     ui as uimod,
     util,
@@ -257,7 +256,7 @@ 
 
     realmode = mode
     if mode == 'auto':
-        if os.name == 'nt':
+        if pycompat.osname == 'nt':
             term = encoding.environ.get('TERM')
             # TERM won't be defined in a vanilla cmd.exe environment.
 
@@ -583,7 +582,7 @@ 
             ui.write(', '.join(ui.label(e, e) for e in effects.split()))
         ui.write('\n')
 
-if os.name != 'nt':
+if pycompat.osname != 'nt':
     w32effects = None
 else:
     import ctypes
diff -r e39ac3774a1c -r 173684dd1696 hgext/convert/subversion.py
--- a/hgext/convert/subversion.py	Mon Dec 19 00:16:52 2016 +0530
+++ b/hgext/convert/subversion.py	Mon Dec 19 00:28:12 2016 +0530
@@ -103,7 +103,7 @@ 
         pass
     if os.path.isdir(path):
         path = os.path.normpath(os.path.abspath(path))
-        if os.name == 'nt':
+        if pycompat.osname == 'nt':
             path = '/' + util.normpath(path)
         # Module URL is later compared with the repository URL returned
         # by svn API, which is UTF-8.
@@ -254,8 +254,8 @@ 
     try:
         proto, path = url.split('://', 1)
         if proto == 'file':
-            if (os.name == 'nt' and path[:1] == '/' and path[1:2].isalpha()
-                and path[2:6].lower() == '%3a/'):
+            if (pycompat.osname == 'nt' and path[:1] == '/'\
+                    and path[1:2].isalpha() and path[2:6].lower() == '%3a/'):
                 path = path[:2] + ':/' + path[6:]
             path = urlreq.url2pathname(path)
     except ValueError:
diff -r e39ac3774a1c -r 173684dd1696 hgext/largefiles/lfutil.py
--- a/hgext/largefiles/lfutil.py	Mon Dec 19 00:16:52 2016 +0530
+++ b/hgext/largefiles/lfutil.py	Mon Dec 19 00:28:12 2016 +0530
@@ -23,6 +23,7 @@ 
     httpconnection,
     match as matchmod,
     node,
+    pycompat,
     scmutil,
     util,
 )
@@ -72,7 +73,7 @@ 
     path = ui.configpath(longname, 'usercache', None)
     if path:
         return path
-    if os.name == 'nt':
+    if pycompat.osname == 'nt':
         appdata = os.getenv('LOCALAPPDATA', os.getenv('APPDATA'))
         if appdata:
             return os.path.join(appdata, longname)
@@ -80,7 +81,7 @@ 
         home = os.getenv('HOME')
         if home:
             return os.path.join(home, 'Library', 'Caches', longname)
-    elif os.name == 'posix':
+    elif pycompat.osname == 'posix':
         path = os.getenv('XDG_CACHE_HOME')
         if path:
             return os.path.join(path, longname)
@@ -88,7 +89,8 @@ 
         if home:
             return os.path.join(home, '.cache', longname)
     else:
-        raise error.Abort(_('unknown operating system: %s\n') % os.name)
+        raise error.Abort(_('unknown operating system: %s\n') %\
+                        pycompat.osname)
     raise error.Abort(_('unknown %s usercache location') % longname)
 
 def inusercache(ui, hash):
diff -r e39ac3774a1c -r 173684dd1696 hgext/schemes.py
--- a/hgext/schemes.py	Mon Dec 19 00:16:52 2016 +0530
+++ b/hgext/schemes.py	Mon Dec 19 00:28:12 2016 +0530
@@ -50,6 +50,7 @@ 
     error,
     extensions,
     hg,
+    pycompat,
     templater,
     util,
 )
@@ -114,7 +115,7 @@ 
     schemes.update(dict(ui.configitems('schemes')))
     t = templater.engine(lambda x: x)
     for scheme, url in schemes.items():
-        if (os.name == 'nt' and len(scheme) == 1 and scheme.isalpha()
+        if (pycompat.osname == 'nt' and len(scheme) == 1 and scheme.isalpha()
             and os.path.exists('%s:\\' % scheme)):
             raise error.Abort(_('custom scheme %s:// conflicts with drive '
                                'letter %s:\\\n') % (scheme, scheme.upper()))
diff -r e39ac3774a1c -r 173684dd1696 hgext/win32mbcs.py
--- a/hgext/win32mbcs.py	Mon Dec 19 00:16:52 2016 +0530
+++ b/hgext/win32mbcs.py	Mon Dec 19 00:28:12 2016 +0530
@@ -179,7 +179,7 @@ 
     if _encoding.lower() in problematic_encodings.split():
         for f in funcs.split():
             wrapname(f, wrapper)
-        if os.name == 'nt':
+        if pycompat.osname == 'nt':
             for f in winfuncs.split():
                 wrapname(f, wrapper)
         wrapname("mercurial.osutil.listdir", wrapperforlistdir)