diff --git a/hgext/color.py b/hgext/color.py --- a/hgext/color.py +++ b/hgext/color.py @@ -164,8 +164,6 @@ If ``pagermode`` is not defined, the ``m from __future__ import absolute_import -import os - from mercurial.i18n import _ from mercurial import ( cmdutil, @@ -173,6 +171,7 @@ from mercurial import ( dispatch, encoding, extensions, + pycompat, subrepo, ui as uimod, util, @@ -257,7 +256,7 @@ def _modesetup(ui, coloropt): 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 @@ def _debugdisplaystyle(ui): 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 --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py --- a/hgext/convert/subversion.py +++ b/hgext/convert/subversion.py @@ -103,7 +103,7 @@ def geturl(path): 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 @@ def issvnurl(ui, url): 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 --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py --- a/hgext/largefiles/lfutil.py +++ b/hgext/largefiles/lfutil.py @@ -23,6 +23,7 @@ from mercurial import ( httpconnection, match as matchmod, node, + pycompat, scmutil, util, ) @@ -72,7 +73,7 @@ def _usercachedir(ui): 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 @@ def _usercachedir(ui): 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 @@ def _usercachedir(ui): 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 --git a/hgext/schemes.py b/hgext/schemes.py --- a/hgext/schemes.py +++ b/hgext/schemes.py @@ -50,6 +50,7 @@ from mercurial import ( error, extensions, hg, + pycompat, templater, util, ) @@ -114,7 +115,7 @@ def extsetup(ui): 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 --git a/hgext/win32mbcs.py b/hgext/win32mbcs.py --- a/hgext/win32mbcs.py +++ b/hgext/win32mbcs.py @@ -179,7 +179,7 @@ def extsetup(ui): 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)