[PATCH 9 of 9] py3: replace sys.platform with pycompat.sysplatform (part 2 of 2)

Pulkit Goyal 7895pulkit at gmail.com
Tue Dec 20 09:03:55 EST 2016


# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1482094601 -19800
#      Mon Dec 19 02:26:41 2016 +0530
# Node ID e0752031ef003151141020f68a2a902080db157b
# Parent  068e2e6fe20712a2624c5b2050aedeb68ab619c2
py3: replace sys.platform with pycompat.sysplatform (part 2 of 2)

diff -r 068e2e6fe207 -r e0752031ef00 hgext/win32mbcs.py
--- 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
diff -r 068e2e6fe207 -r e0752031ef00 mercurial/posix.py
--- 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)
diff -r 068e2e6fe207 -r e0752031ef00 mercurial/pure/osutil.py
--- 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
diff -r 068e2e6fe207 -r e0752031ef00 mercurial/util.py
--- 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


More information about the Mercurial-devel mailing list