changeset 30645:7a3e67bfa417

py3: replace os.name with pycompat.osname (part 2 of 2)
author Pulkit Goyal <7895pulkit@gmail.com>
date Mon, 19 Dec 2016 00:28:12 +0530
parents d524c88511a7
children 16b5df5792a8
files hgext/color.py hgext/convert/subversion.py hgext/largefiles/lfutil.py hgext/schemes.py hgext/win32mbcs.py
diffstat 5 files changed, 14 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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:
--- 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):
--- 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()))
--- 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)