changeset 45830:c102b704edb5

global: use python3 in shebangs Python 3 is the future. We want Python scripts to be using Python 3 by default. This change updates all `#!/usr/bin/env python` shebangs to use `python3`. Does this mean all scripts use or require Python 3: no. In the test environment, the `PATH` environment variable in tests is updated to guarantee that the Python executable used to run run-tests.py is used. Since test scripts all now use `#!/usr/bin/env python3`, we had to update this code to install a `python3` symlink instead of `python`. It is possible there are some random scripts now executed with the incorrect Python interpreter in some contexts. However, I would argue that this was a pre-existing bug: we should almost always be executing new Python processes using the `sys.executable` from the originating Python script, as `python` or `python3` won't guarantee we'll use the same interpreter. Differential Revision: https://phab.mercurial-scm.org/D9273
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 06 Nov 2020 13:58:59 -0800
parents e7a4c018b563
children f14c33b2e497
files contrib/check-code.py contrib/check-commit contrib/check-config.py contrib/check-py3-compat.py contrib/debugcmdserver.py contrib/dumprevlog contrib/hg-ssh contrib/hgperf contrib/hgweb.fcgi contrib/import-checker.py contrib/perf-utils/perf-revlog-write-plot.py contrib/phab-clean.py contrib/revsetbenchmarks.py contrib/simplemerge contrib/undumprevlog doc/check-seclevel.py doc/docchecker doc/gendoc.py doc/runrst hg hgweb.cgi i18n/check-translation.py i18n/hggettext i18n/posplit tests/artifacts/scripts/generate-churning-bundle.py tests/check-perf-code.py tests/dumbhttp.py tests/dummysmtpd.py tests/dummyssh tests/f tests/filterpyflakes.py tests/filtertraceback.py tests/fsmonitor-run-tests.py tests/get-with-headers.py tests/hghave tests/killdaemons.py tests/ls-l.py tests/md5sum.py tests/printenv.py tests/readlink.py tests/revlog-formatv0.py tests/run-tests.py tests/seq.py tests/svn-safe-append.py tests/test-filelog.py tests/test-remotefilelog-datapack.py tests/test-remotefilelog-histpack.py tests/test-run-tests.t tests/test-status-inprocess.py tests/test-stdio.py tests/tinyproxy.py
diffstat 51 files changed, 52 insertions(+), 52 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/check-code.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/contrib/check-code.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # check-code - a style and portability checker for Mercurial
 #
--- a/contrib/check-commit	Mon Nov 09 09:58:44 2020 -0800
+++ b/contrib/check-commit	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Copyright 2014 Matt Mackall <mpm@selenic.com>
 #
--- a/contrib/check-config.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/contrib/check-config.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # check-config - a config flag documentation checker for Mercurial
 #
--- a/contrib/check-py3-compat.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/contrib/check-py3-compat.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # check-py3-compat - check Python 3 compatibility of Mercurial files
 #
--- a/contrib/debugcmdserver.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/contrib/debugcmdserver.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Dumps output generated by Mercurial's command server in a formatted style to a
 # given file or stderr if '-' is specified. Output is also written in its raw
--- a/contrib/dumprevlog	Mon Nov 09 09:58:44 2020 -0800
+++ b/contrib/dumprevlog	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # Dump revlogs as raw data stream
 # $ find .hg/store/ -name "*.i" | xargs dumprevlog > repo.dump
 
--- a/contrib/hg-ssh	Mon Nov 09 09:58:44 2020 -0800
+++ b/contrib/hg-ssh	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Copyright 2005-2007 by Intevation GmbH <intevation@intevation.de>
 #
--- a/contrib/hgperf	Mon Nov 09 09:58:44 2020 -0800
+++ b/contrib/hgperf	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # hgperf - measure performance of Mercurial commands
 #
--- a/contrib/hgweb.fcgi	Mon Nov 09 09:58:44 2020 -0800
+++ b/contrib/hgweb.fcgi	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # An example FastCGI script for use with flup, edit as necessary
 
--- a/contrib/import-checker.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/contrib/import-checker.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 from __future__ import absolute_import, print_function
 
--- a/contrib/perf-utils/perf-revlog-write-plot.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/contrib/perf-utils/perf-revlog-write-plot.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 #  Copyright 2018 Paul Morelle <Paul.Morelle@octobus.net>
 #
--- a/contrib/phab-clean.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/contrib/phab-clean.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # A small script to automatically reject idle Diffs
 #
--- a/contrib/revsetbenchmarks.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/contrib/revsetbenchmarks.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 # Measure the performance of a list of revsets against multiple revisions
 # defined by parameter. Checkout one by one and run perfrevset with every
--- a/contrib/simplemerge	Mon Nov 09 09:58:44 2020 -0800
+++ b/contrib/simplemerge	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 from __future__ import absolute_import
 
 import getopt
--- a/contrib/undumprevlog	Mon Nov 09 09:58:44 2020 -0800
+++ b/contrib/undumprevlog	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # Undump a dump from dumprevlog
 # $ hg init
 # $ undumprevlog < repo.dump
--- a/doc/check-seclevel.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/doc/check-seclevel.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # checkseclevel - checking section title levels in each online help document
 
--- a/doc/docchecker	Mon Nov 09 09:58:44 2020 -0800
+++ b/doc/docchecker	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # docchecker - look for problematic markup
 #
--- a/doc/gendoc.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/doc/gendoc.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 """usage: %s DOC ...
 
 where DOC is the name of a document
--- a/doc/runrst	Mon Nov 09 09:58:44 2020 -0800
+++ b/doc/runrst	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # runrst - register custom roles and run correct writer
 #
--- a/hg	Mon Nov 09 09:58:44 2020 -0800
+++ b/hg	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # mercurial - scalable distributed SCM
 #
--- a/hgweb.cgi	Mon Nov 09 09:58:44 2020 -0800
+++ b/hgweb.cgi	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # An example hgweb CGI script, edit as necessary
 # See also https://mercurial-scm.org/wiki/PublishingRepositories
--- a/i18n/check-translation.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/i18n/check-translation.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # check-translation.py - check Mercurial specific translation problems
 from __future__ import absolute_import
--- a/i18n/hggettext	Mon Nov 09 09:58:44 2020 -0800
+++ b/i18n/hggettext	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # hggettext - carefully extract docstrings for Mercurial
 #
--- a/i18n/posplit	Mon Nov 09 09:58:44 2020 -0800
+++ b/i18n/posplit	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # posplit - split messages in paragraphs on .po/.pot files
 #
--- a/tests/artifacts/scripts/generate-churning-bundle.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/tests/artifacts/scripts/generate-churning-bundle.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # generate-branchy-bundle - generate a branch for a "large" branchy repository
 #
--- a/tests/check-perf-code.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/tests/check-perf-code.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # check-perf-code - (historical) portability checker for contrib/perf.py
 
--- a/tests/dumbhttp.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/tests/dumbhttp.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 from __future__ import absolute_import
 
--- a/tests/dummysmtpd.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/tests/dummysmtpd.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 """dummy SMTP server for use in tests"""
 
--- a/tests/dummyssh	Mon Nov 09 09:58:44 2020 -0800
+++ b/tests/dummyssh	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 from __future__ import absolute_import
 
--- a/tests/f	Mon Nov 09 09:58:44 2020 -0800
+++ b/tests/f	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 """
 Utility for inspecting files in various ways.
--- a/tests/filterpyflakes.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/tests/filterpyflakes.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 # Filter output by pyflakes to control which warnings we check
 
--- a/tests/filtertraceback.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/tests/filtertraceback.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 # Filters traceback lines from stdin.
 
--- a/tests/fsmonitor-run-tests.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/tests/fsmonitor-run-tests.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 # fsmonitor-run-tests.py - Run Mercurial tests with fsmonitor enabled
 #
--- a/tests/get-with-headers.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/tests/get-with-headers.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 """This does HTTP GET requests given a host:port and path and returns
 a subset of the headers plus the body of the result."""
--- a/tests/hghave	Mon Nov 09 09:58:44 2020 -0800
+++ b/tests/hghave	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 """Test the running system for features availability. Exit with zero
 if all features are there, non-zero otherwise. If a feature name is
 prefixed with "no-", the absence of feature is tested.
--- a/tests/killdaemons.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/tests/killdaemons.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 from __future__ import absolute_import
 import errno
--- a/tests/ls-l.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/tests/ls-l.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 # like ls -l, but do not print date, user, or non-common mode bit, to avoid
 # using globs in tests.
--- a/tests/md5sum.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/tests/md5sum.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Based on python's Tools/scripts/md5sum.py
 #
--- a/tests/printenv.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/tests/printenv.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # simple script to be used in hooks
 #
--- a/tests/readlink.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/tests/readlink.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 from __future__ import absolute_import, print_function
 
--- a/tests/revlog-formatv0.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/tests/revlog-formatv0.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # Copyright 2010 Intevation GmbH
 # Author(s):
 # Thomas Arendsen Hein <thomas@intevation.de>
--- a/tests/run-tests.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/tests/run-tests.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # run-tests.py - Run a set of tests on Mercurial
 #
@@ -3434,7 +3434,7 @@
     def _usecorrectpython(self):
         """Configure the environment to use the appropriate Python in tests."""
         # Tests must use the same interpreter as us or bad things will happen.
-        pyexename = sys.platform == 'win32' and b'python.exe' or b'python'
+        pyexename = sys.platform == 'win32' and b'python.exe' or b'python3'
 
         # os.symlink() is a thing with py3 on Windows, but it requires
         # Administrator rights.
--- a/tests/seq.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/tests/seq.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # A portable replacement for 'seq'
 #
--- a/tests/svn-safe-append.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/tests/svn-safe-append.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 from __future__ import absolute_import
 
--- a/tests/test-filelog.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/tests/test-filelog.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 """
 Tests the behavior of filelog w.r.t. data starting with '\1\n'
 """
--- a/tests/test-remotefilelog-datapack.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/tests/test-remotefilelog-datapack.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 from __future__ import absolute_import, print_function
 
 import hashlib
--- a/tests/test-remotefilelog-histpack.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/tests/test-remotefilelog-histpack.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 from __future__ import absolute_import
 
 import hashlib
--- a/tests/test-run-tests.t	Mon Nov 09 09:58:44 2020 -0800
+++ b/tests/test-run-tests.t	Fri Nov 06 13:58:59 2020 -0800
@@ -1412,7 +1412,7 @@
   > This should print the start of check-code. If this passes but the
   > previous check failed, that means we found a copy of check-code at whatever
   > RUNTESTSDIR ended up containing, even though it doesn't match TESTDIR.
-  >   $ head -n 3 "\$RUNTESTDIR"/../contrib/check-code.py | sed 's@.!.*python@#!USRBINENVPY@'
+  >   $ head -n 3 "\$RUNTESTDIR"/../contrib/check-code.py | sed 's@.!.*python3@#!USRBINENVPY@'
   >   #!USRBINENVPY
   >   #
   >   # check-code - a style and portability checker for Mercurial
--- a/tests/test-status-inprocess.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/tests/test-status-inprocess.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 from __future__ import absolute_import, print_function
 
 import sys
--- a/tests/test-stdio.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/tests/test-stdio.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 """
 Tests the buffering behavior of stdio streams in `mercurial.utils.procutil`.
 """
--- a/tests/tinyproxy.py	Mon Nov 09 09:58:44 2020 -0800
+++ b/tests/tinyproxy.py	Fri Nov 06 13:58:59 2020 -0800
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 from __future__ import absolute_import, print_function