changeset 30642:e995f00a9e9a

py3: replace sys.platform with pycompat.sysplatform (part 2 of 2)
author Pulkit Goyal <7895pulkit@gmail.com>
date Mon, 19 Dec 2016 02:26:41 +0530
parents 16b5df5792a8
children dfb19aed409e
files hgext/win32mbcs.py mercurial/posix.py mercurial/pure/osutil.py mercurial/util.py
diffstat 4 files changed, 11 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/win32mbcs.py	Mon Dec 19 02:15:24 2016 +0530
+++ b/hgext/win32mbcs.py	Mon Dec 19 02:26:41 2016 +0530
@@ -169,7 +169,7 @@
 def extsetup(ui):
     # TODO: decide use of config section for this extension
     if ((not os.path.supports_unicode_filenames) and
-        (sys.platform != 'cygwin')):
+        (pycompat.sysplatform != 'cygwin')):
         ui.warn(_("[win32mbcs] cannot activate on this platform.\n"))
         return
     # determine encoding for filename
--- a/mercurial/posix.py	Mon Dec 19 02:15:24 2016 +0530
+++ b/mercurial/posix.py	Mon Dec 19 02:26:41 2016 +0530
@@ -80,7 +80,7 @@
 def parsepatchoutput(output_line):
     """parses the output produced by patch and returns the filename"""
     pf = output_line[14:]
-    if os.sys.platform == 'OpenVMS':
+    if pycompat.sysplatform == 'OpenVMS':
         if pf[0] == '`':
             pf = pf[1:-1] # Remove the quotes
     else:
@@ -404,7 +404,7 @@
 
 _needsshellquote = None
 def shellquote(s):
-    if os.sys.platform == 'OpenVMS':
+    if pycompat.sysplatform == 'OpenVMS':
         return '"%s"' % s
     global _needsshellquote
     if _needsshellquote is None:
@@ -423,7 +423,7 @@
 
 def testpid(pid):
     '''return False if pid dead, True if running or not sure'''
-    if os.sys.platform == 'OpenVMS':
+    if pycompat.sysplatform == 'OpenVMS':
         return True
     try:
         os.kill(pid, 0)
--- a/mercurial/pure/osutil.py	Mon Dec 19 02:15:24 2016 +0530
+++ b/mercurial/pure/osutil.py	Mon Dec 19 02:26:41 2016 +0530
@@ -12,7 +12,6 @@
 import os
 import socket
 import stat as statmod
-import sys
 
 from . import (
     policy,
@@ -70,14 +69,14 @@
     return result
 
 ffi = None
-if modulepolicy not in policynocffi and sys.platform == 'darwin':
+if modulepolicy not in policynocffi and pycompat.sysplatform == 'darwin':
     try:
         from _osutil_cffi import ffi, lib
     except ImportError:
         if modulepolicy == 'cffi': # strict cffi import
             raise
 
-if sys.platform == 'darwin' and ffi is not None:
+if pycompat.sysplatform == 'darwin' and ffi is not None:
     listdir_batch_size = 4096
     # tweakable number, only affects performance, which chunks
     # of bytes do we get back from getattrlistbulk
@@ -165,7 +164,7 @@
     _SCM_RIGHTS = 0x01
     _socklen_t = ctypes.c_uint
 
-    if sys.platform == 'linux2':
+    if pycompat.sysplatform.startswith('linux'):
         # socket.h says "the type should be socklen_t but the definition of
         # the kernel is incompatible with this."
         _cmsg_len_t = ctypes.c_size_t
--- a/mercurial/util.py	Mon Dec 19 02:15:24 2016 +0530
+++ b/mercurial/util.py	Mon Dec 19 02:26:41 2016 +0530
@@ -795,7 +795,7 @@
         cmd = cmd.replace('INFILE', inname)
         cmd = cmd.replace('OUTFILE', outname)
         code = os.system(cmd)
-        if sys.platform == 'OpenVMS' and code & 1:
+        if pycompat.sysplatform == 'OpenVMS' and code & 1:
             code = 0
         if code:
             raise Abort(_("command '%s' failed: %s") %
@@ -998,7 +998,7 @@
         return str(val)
     origcmd = cmd
     cmd = quotecommand(cmd)
-    if sys.platform == 'plan9' and (sys.version_info[0] == 2
+    if pycompat.sysplatform == 'plan9' and (sys.version_info[0] == 2
                                     and sys.version_info[1] < 7):
         # subprocess kludge to work around issues in half-baked Python
         # ports, notably bichued/python:
@@ -1020,7 +1020,7 @@
                 out.write(line)
             proc.wait()
             rc = proc.returncode
-        if sys.platform == 'OpenVMS' and rc & 1:
+        if pycompat.sysplatform == 'OpenVMS' and rc & 1:
             rc = 0
     if rc and onerr:
         errmsg = '%s %s' % (os.path.basename(origcmd.split(None, 1)[0]),
@@ -1383,7 +1383,7 @@
 
 def gui():
     '''Are we running in a GUI?'''
-    if sys.platform == 'darwin':
+    if pycompat.sysplatform == 'darwin':
         if 'SSH_CONNECTION' in encoding.environ:
             # handle SSH access to a box where the user is logged in
             return False