changeset 34645:75979c8d4572

codemod: use pycompat.iswindows This is done by: sed -i "s/pycompat\.osname == 'nt'/pycompat.iswindows/" **/*.py sed -i "s/pycompat\.osname != 'nt'/not pycompat.iswindows/" **/*.py sed -i 's/pycompat.osname == "nt"/pycompat.iswindows/' **/*.py Differential Revision: https://phab.mercurial-scm.org/D1034
author Jun Wu <quark@fb.com>
date Thu, 12 Oct 2017 23:30:46 -0700
parents c0a6c19690ff
children 238abf65a8ad
files hgext/convert/subversion.py hgext/largefiles/lfutil.py hgext/logtoprocess.py hgext/schemes.py hgext/win32mbcs.py mercurial/color.py mercurial/debugcommands.py mercurial/hgweb/server.py mercurial/i18n.py mercurial/pure/osutil.py mercurial/rcutil.py mercurial/scmutil.py mercurial/sslutil.py mercurial/subrepo.py mercurial/ui.py mercurial/util.py mercurial/vfs.py mercurial/worker.py
diffstat 18 files changed, 25 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/subversion.py	Thu Oct 12 19:20:04 2017 -0700
+++ b/hgext/convert/subversion.py	Thu Oct 12 23:30:46 2017 -0700
@@ -103,7 +103,7 @@
         pass
     if os.path.isdir(path):
         path = os.path.normpath(os.path.abspath(path))
-        if pycompat.osname == 'nt':
+        if pycompat.iswindows:
             path = '/' + util.normpath(path)
         # Module URL is later compared with the repository URL returned
         # by svn API, which is UTF-8.
@@ -254,7 +254,7 @@
     try:
         proto, path = url.split('://', 1)
         if proto == 'file':
-            if (pycompat.osname == 'nt' and path[:1] == '/'
+            if (pycompat.iswindows and path[:1] == '/'
                   and path[1:2].isalpha() and path[2:6].lower() == '%3a/'):
                 path = path[:2] + ':/' + path[6:]
             path = urlreq.url2pathname(path)
--- a/hgext/largefiles/lfutil.py	Thu Oct 12 19:20:04 2017 -0700
+++ b/hgext/largefiles/lfutil.py	Thu Oct 12 23:30:46 2017 -0700
@@ -74,7 +74,7 @@
     path = ui.configpath(longname, 'usercache', None)
     if path:
         return path
-    if pycompat.osname == 'nt':
+    if pycompat.iswindows:
         appdata = encoding.environ.get('LOCALAPPDATA',\
                         encoding.environ.get('APPDATA'))
         if appdata:
--- a/hgext/logtoprocess.py	Thu Oct 12 19:20:04 2017 -0700
+++ b/hgext/logtoprocess.py	Thu Oct 12 23:30:46 2017 -0700
@@ -51,7 +51,7 @@
 testedwith = 'ships-with-hg-core'
 
 def uisetup(ui):
-    if pycompat.osname == 'nt':
+    if pycompat.iswindows:
         # no fork on Windows, but we can create a detached process
         # https://msdn.microsoft.com/en-us/library/windows/desktop/ms684863.aspx
         # No stdlib constant exists for this value
--- a/hgext/schemes.py	Thu Oct 12 19:20:04 2017 -0700
+++ b/hgext/schemes.py	Thu Oct 12 23:30:46 2017 -0700
@@ -116,7 +116,7 @@
     schemes.update(dict(ui.configitems('schemes')))
     t = templater.engine(lambda x: x)
     for scheme, url in schemes.items():
-        if (pycompat.osname == 'nt' and len(scheme) == 1 and scheme.isalpha()
+        if (pycompat.iswindows 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	Thu Oct 12 19:20:04 2017 -0700
+++ b/hgext/win32mbcs.py	Thu Oct 12 23:30:46 2017 -0700
@@ -190,7 +190,7 @@
     if _encoding.lower() in problematic_encodings.split():
         for f in funcs.split():
             wrapname(f, wrapper)
-        if pycompat.osname == 'nt':
+        if pycompat.iswindows:
             for f in winfuncs.split():
                 wrapname(f, wrapper)
         wrapname("mercurial.util.listdir", wrapperforlistdir)
--- a/mercurial/color.py	Thu Oct 12 19:20:04 2017 -0700
+++ b/mercurial/color.py	Thu Oct 12 23:30:46 2017 -0700
@@ -210,7 +210,7 @@
         mode = ui.config('color', 'pagermode', mode)
 
     realmode = mode
-    if pycompat.osname == 'nt':
+    if pycompat.iswindows:
         from . import win32
 
         term = encoding.environ.get('TERM')
@@ -379,7 +379,7 @@
     return msg
 
 w32effects = None
-if pycompat.osname == 'nt':
+if pycompat.iswindows:
     import ctypes
 
     _kernel32 = ctypes.windll.kernel32
--- a/mercurial/debugcommands.py	Thu Oct 12 19:20:04 2017 -0700
+++ b/mercurial/debugcommands.py	Thu Oct 12 23:30:46 2017 -0700
@@ -2072,7 +2072,7 @@
     If the update succeeds, retry the original operation.  Otherwise, the cause
     of the SSL error is likely another issue.
     '''
-    if pycompat.osname != 'nt':
+    if not pycompat.iswindows:
         raise error.Abort(_('certificate chain building is only possible on '
                             'Windows'))
 
--- a/mercurial/hgweb/server.py	Thu Oct 12 19:20:04 2017 -0700
+++ b/mercurial/hgweb/server.py	Thu Oct 12 23:30:46 2017 -0700
@@ -266,7 +266,7 @@
 class MercurialHTTPServer(_mixin, httpservermod.httpserver, object):
 
     # SO_REUSEADDR has broken semantics on windows
-    if pycompat.osname == 'nt':
+    if pycompat.iswindows:
         allow_reuse_address = 0
 
     def __init__(self, ui, app, addr, handler, **kwargs):
--- a/mercurial/i18n.py	Thu Oct 12 19:20:04 2017 -0700
+++ b/mercurial/i18n.py	Thu Oct 12 23:30:46 2017 -0700
@@ -29,7 +29,7 @@
     unicode = str
 
 _languages = None
-if (pycompat.osname == 'nt'
+if (pycompat.iswindows
     and 'LANGUAGE' not in encoding.environ
     and 'LC_ALL' not in encoding.environ
     and 'LC_MESSAGES' not in encoding.environ
--- a/mercurial/pure/osutil.py	Thu Oct 12 19:20:04 2017 -0700
+++ b/mercurial/pure/osutil.py	Thu Oct 12 23:30:46 2017 -0700
@@ -64,7 +64,7 @@
             result.append((fn, _mode_to_kind(st.st_mode)))
     return result
 
-if pycompat.osname != 'nt':
+if not pycompat.iswindows:
     posixfile = open
 
     _SCM_RIGHTS = 0x01
--- a/mercurial/rcutil.py	Thu Oct 12 19:20:04 2017 -0700
+++ b/mercurial/rcutil.py	Thu Oct 12 23:30:46 2017 -0700
@@ -15,7 +15,7 @@
     util,
 )
 
-if pycompat.osname == 'nt':
+if pycompat.iswindows:
     from . import scmwindows as scmplatform
 else:
     from . import scmposix as scmplatform
--- a/mercurial/scmutil.py	Thu Oct 12 19:20:04 2017 -0700
+++ b/mercurial/scmutil.py	Thu Oct 12 23:30:46 2017 -0700
@@ -41,7 +41,7 @@
     vfs,
 )
 
-if pycompat.osname == 'nt':
+if pycompat.iswindows:
     from . import scmwindows as scmplatform
 else:
     from . import scmposix as scmplatform
@@ -291,7 +291,7 @@
     val = ui.config('ui', 'portablefilenames')
     lval = val.lower()
     bval = util.parsebool(val)
-    abort = pycompat.osname == 'nt' or lval == 'abort'
+    abort = pycompat.iswindows or lval == 'abort'
     warn = bval or lval == 'warn'
     if bval is None and not (warn or abort or lval == 'ignore'):
         raise error.ConfigError(
--- a/mercurial/sslutil.py	Thu Oct 12 19:20:04 2017 -0700
+++ b/mercurial/sslutil.py	Thu Oct 12 23:30:46 2017 -0700
@@ -477,7 +477,7 @@
                         'for more info)\n'))
 
             elif (e.reason == 'CERTIFICATE_VERIFY_FAILED' and
-                pycompat.osname == 'nt'):
+                pycompat.iswindows):
 
                 ui.warn(_('(the full certificate chain may not be available '
                           'locally; see "hg help debugssl")\n'))
@@ -717,7 +717,7 @@
     # because we'll get a certificate verification error later and the lack
     # of loaded CA certificates will be the reason why.
     # Assertion: this code is only called if certificates are being verified.
-    if pycompat.osname == 'nt':
+    if pycompat.iswindows:
         if not _canloaddefaultcerts:
             ui.warn(_('(unable to load Windows CA certificates; see '
                       'https://mercurial-scm.org/wiki/SecureConnections for '
@@ -749,7 +749,7 @@
     # / is writable on Windows. Out of an abundance of caution make sure
     # we're not on Windows because paths from _systemcacerts could be installed
     # by non-admin users.
-    assert pycompat.osname != 'nt'
+    assert not pycompat.iswindows
 
     # Try to find CA certificates in well-known locations. We print a warning
     # when using a found file because we don't want too much silent magic
--- a/mercurial/subrepo.py	Thu Oct 12 19:20:04 2017 -0700
+++ b/mercurial/subrepo.py	Thu Oct 12 23:30:46 2017 -0700
@@ -1347,7 +1347,7 @@
             if e.errno != errno.ENOENT:
                 raise error.Abort(genericerror % (
                     self._path, encoding.strtolocal(e.strerror)))
-            elif pycompat.osname == 'nt':
+            elif pycompat.iswindows:
                 try:
                     self._gitexecutable = 'git.cmd'
                     out, err = self._gitnodir(['--version'])
--- a/mercurial/ui.py	Thu Oct 12 19:20:04 2017 -0700
+++ b/mercurial/ui.py	Thu Oct 12 23:30:46 2017 -0700
@@ -1041,7 +1041,7 @@
         # gracefully and tell the user about their broken pager.
         shell = any(c in command for c in "|&;<>()$`\\\"' \t\n*?[#~=%")
 
-        if pycompat.osname == 'nt' and not shell:
+        if pycompat.iswindows and not shell:
             # Window's built-in `more` cannot be invoked with shell=False, but
             # its `more.com` can.  Hide this implementation detail from the
             # user so we can also get sane bad PAGER behavior.  MSYS has
--- a/mercurial/util.py	Thu Oct 12 19:20:04 2017 -0700
+++ b/mercurial/util.py	Thu Oct 12 23:30:46 2017 -0700
@@ -92,7 +92,7 @@
 if isatty(stdout):
     stdout = os.fdopen(stdout.fileno(), pycompat.sysstr('wb'), 1)
 
-if pycompat.osname == 'nt':
+if pycompat.iswindows:
     from . import windows as platform
     stdout = platform.winstdout(stdout)
 else:
@@ -1348,7 +1348,7 @@
             return _("filename ends with '%s', which is not allowed "
                      "on Windows") % t
 
-if pycompat.osname == 'nt':
+if pycompat.iswindows:
     checkosfilename = checkwinfilename
     timer = time.clock
 else:
@@ -1572,7 +1572,7 @@
             # pure build; use a safe default
             return True
     else:
-        return pycompat.osname == "nt" or encoding.environ.get("DISPLAY")
+        return pycompat.iswindows or encoding.environ.get("DISPLAY")
 
 def mktempcopy(name, emptyok=False, createmode=None):
     """Create a temporary file with the same contents from name
--- a/mercurial/vfs.py	Thu Oct 12 19:20:04 2017 -0700
+++ b/mercurial/vfs.py	Thu Oct 12 23:30:46 2017 -0700
@@ -543,7 +543,7 @@
 
         # Only Windows/NTFS has slow file closing. So only enable by default
         # on that platform. But allow to be enabled elsewhere for testing.
-        defaultenabled = pycompat.osname == 'nt'
+        defaultenabled = pycompat.iswindows
         enabled = ui.configbool('worker', 'backgroundclose', defaultenabled)
 
         if not enabled:
--- a/mercurial/worker.py	Thu Oct 12 19:20:04 2017 -0700
+++ b/mercurial/worker.py	Thu Oct 12 23:30:46 2017 -0700
@@ -203,7 +203,7 @@
     elif os.WIFSIGNALED(code):
         return -os.WTERMSIG(code)
 
-if pycompat.osname != 'nt':
+if not pycompat.iswindows:
     _platformworker = _posixworker
     _exitstatus = _posixexitstatus