# HG changeset patch # User Pulkit Goyal <7895pul...@gmail.com> # Date 1482093924 -19800 # Mon Dec 19 02:15:24 2016 +0530 # Node ID 068e2e6fe20712a2624c5b2050aedeb68ab619c2 # Parent 173684dd16962b352416332ee66bd1880497aa16 py3: replace sys.platform with pycompat.sysplatform (part 1 of 2)
sys.platform returns unicode on python 3 world. Our code base has most of the things bytes because of the transformer. So we have a bytes version of this as pycompat.sysplatform. This series of 2 patches replaces occurences of sys.platform with pycompat.sysplatform. diff -r 173684dd1696 -r 068e2e6fe207 mercurial/commands.py --- a/mercurial/commands.py Mon Dec 19 00:28:12 2016 +0530 +++ b/mercurial/commands.py Mon Dec 19 02:15:24 2016 +0530 @@ -3891,15 +3891,15 @@ keep = opts.get('system') or [] if len(keep) == 0: - if sys.platform.startswith('win'): + if pycompat.sysplatform.startswith('win'): keep.append('windows') - elif sys.platform == 'OpenVMS': + elif pycompat.sysplatform == 'OpenVMS': keep.append('vms') - elif sys.platform == 'plan9': + elif pycompat.sysplatform == 'plan9': keep.append('plan9') else: keep.append('unix') - keep.append(sys.platform.lower()) + keep.append(pycompat.sysplatform.lower()) if ui.verbose: keep.append('verbose') diff -r 173684dd1696 -r 068e2e6fe207 mercurial/posix.py --- a/mercurial/posix.py Mon Dec 19 00:28:12 2016 +0530 +++ b/mercurial/posix.py Mon Dec 19 02:15:24 2016 +0530 @@ -303,7 +303,7 @@ # fallback normcase function for non-ASCII strings normcasefallback = normcase -if sys.platform == 'darwin': +if pycompat.sysplatform == 'darwin': def normcase(path): ''' @@ -354,7 +354,7 @@ # drop HFS+ ignored characters return encoding.hfsignoreclean(enc) -if sys.platform == 'cygwin': +if pycompat.sysplatform == 'cygwin': # workaround for cygwin, in which mount point part of path is # treated as case sensitive, even though underlying NTFS is case # insensitive. @@ -447,7 +447,7 @@ If command is a basename then PATH is searched for command. PATH isn't searched if command is an absolute or relative path. If command isn't found None is returned.''' - if sys.platform == 'OpenVMS': + if pycompat.sysplatform == 'OpenVMS': return command def findexisting(executable): @@ -459,7 +459,7 @@ if pycompat.ossep in command: return findexisting(command) - if sys.platform == 'plan9': + if pycompat.sysplatform == 'plan9': return findexisting(os.path.join('/bin', command)) for path in encoding.environ.get('PATH', '').split(pycompat.ospathsep): diff -r 173684dd1696 -r 068e2e6fe207 mercurial/scmposix.py --- a/mercurial/scmposix.py Mon Dec 19 00:28:12 2016 +0530 +++ b/mercurial/scmposix.py Mon Dec 19 02:15:24 2016 +0530 @@ -25,7 +25,7 @@ def systemrcpath(): path = [] - if sys.platform == 'plan9': + if pycompat.sysplatform == 'plan9': root = 'lib/mercurial' else: root = 'etc/mercurial' @@ -38,7 +38,7 @@ return path def userrcpath(): - if sys.platform == 'plan9': + if pycompat.sysplatform == 'plan9': return [encoding.environ['home'] + '/lib/hgrc'] else: return [os.path.expanduser('~/.hgrc')] diff -r 173684dd1696 -r 068e2e6fe207 mercurial/sslutil.py --- a/mercurial/sslutil.py Mon Dec 19 00:28:12 2016 +0530 +++ b/mercurial/sslutil.py Mon Dec 19 02:15:24 2016 +0530 @@ -668,7 +668,8 @@ for using system certificate store CAs in addition to the provided cacerts file """ - if sys.platform != 'darwin' or util.mainfrozen() or not sys.executable: + if (pycompat.sysplatform != 'darwin' or + util.mainfrozen() or not sys.executable): return False exe = os.path.realpath(sys.executable).lower() return (exe.startswith('/usr/bin/python') or @@ -725,7 +726,7 @@ # The Apple OpenSSL trick isn't available to us. If Python isn't able to # load system certs, we're out of luck. - if sys.platform == 'darwin': + if pycompat.sysplatform == 'darwin': # FUTURE Consider looking for Homebrew or MacPorts installed certs # files. Also consider exporting the keychain certs to a file during # Mercurial install. diff -r 173684dd1696 -r 068e2e6fe207 mercurial/ui.py --- a/mercurial/ui.py Mon Dec 19 00:28:12 2016 +0530 +++ b/mercurial/ui.py Mon Dec 19 02:15:24 2016 +0530 @@ -1085,7 +1085,7 @@ def geteditor(self): '''return editor to use''' - if sys.platform == 'plan9': + if pycompat.sysplatform == 'plan9': # vi is the MIPS instruction simulator on Plan 9. We # instead default to E to plumb commit messages to # avoid confusion. _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel