# HG changeset patch # User Gregory Szorc # Date 1604699939 28800 # Node ID c102b704edb5191ed15ed4b02b625a888b8be816 # Parent e7a4c018b563782b4b10cc8a687405312d67d7cb 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 diff -r e7a4c018b563 -r c102b704edb5 contrib/check-code.py --- 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 # diff -r e7a4c018b563 -r c102b704edb5 contrib/check-commit --- 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 # diff -r e7a4c018b563 -r c102b704edb5 contrib/check-config.py --- 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 # diff -r e7a4c018b563 -r c102b704edb5 contrib/check-py3-compat.py --- 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 # diff -r e7a4c018b563 -r c102b704edb5 contrib/debugcmdserver.py --- 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 diff -r e7a4c018b563 -r c102b704edb5 contrib/dumprevlog --- 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 diff -r e7a4c018b563 -r c102b704edb5 contrib/hg-ssh --- 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 # diff -r e7a4c018b563 -r c102b704edb5 contrib/hgperf --- 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 # diff -r e7a4c018b563 -r c102b704edb5 contrib/hgweb.fcgi --- 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 diff -r e7a4c018b563 -r c102b704edb5 contrib/import-checker.py --- 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 diff -r e7a4c018b563 -r c102b704edb5 contrib/perf-utils/perf-revlog-write-plot.py --- 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 # diff -r e7a4c018b563 -r c102b704edb5 contrib/phab-clean.py --- 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 # diff -r e7a4c018b563 -r c102b704edb5 contrib/revsetbenchmarks.py --- 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 diff -r e7a4c018b563 -r c102b704edb5 contrib/simplemerge --- 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 diff -r e7a4c018b563 -r c102b704edb5 contrib/undumprevlog --- 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 diff -r e7a4c018b563 -r c102b704edb5 doc/check-seclevel.py --- 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 diff -r e7a4c018b563 -r c102b704edb5 doc/docchecker --- 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 # diff -r e7a4c018b563 -r c102b704edb5 doc/gendoc.py --- 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 diff -r e7a4c018b563 -r c102b704edb5 doc/runrst --- 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 # diff -r e7a4c018b563 -r c102b704edb5 hg --- 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 # diff -r e7a4c018b563 -r c102b704edb5 hgweb.cgi --- 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 diff -r e7a4c018b563 -r c102b704edb5 i18n/check-translation.py --- 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 diff -r e7a4c018b563 -r c102b704edb5 i18n/hggettext --- 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 # diff -r e7a4c018b563 -r c102b704edb5 i18n/posplit --- 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 # diff -r e7a4c018b563 -r c102b704edb5 tests/artifacts/scripts/generate-churning-bundle.py --- 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 # diff -r e7a4c018b563 -r c102b704edb5 tests/check-perf-code.py --- 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 diff -r e7a4c018b563 -r c102b704edb5 tests/dumbhttp.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 diff -r e7a4c018b563 -r c102b704edb5 tests/dummysmtpd.py --- 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""" diff -r e7a4c018b563 -r c102b704edb5 tests/dummyssh --- 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 diff -r e7a4c018b563 -r c102b704edb5 tests/f --- 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. diff -r e7a4c018b563 -r c102b704edb5 tests/filterpyflakes.py --- 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 diff -r e7a4c018b563 -r c102b704edb5 tests/filtertraceback.py --- 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. diff -r e7a4c018b563 -r c102b704edb5 tests/fsmonitor-run-tests.py --- 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 # diff -r e7a4c018b563 -r c102b704edb5 tests/get-with-headers.py --- 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.""" diff -r e7a4c018b563 -r c102b704edb5 tests/hghave --- 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. diff -r e7a4c018b563 -r c102b704edb5 tests/killdaemons.py --- 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 diff -r e7a4c018b563 -r c102b704edb5 tests/ls-l.py --- 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. diff -r e7a4c018b563 -r c102b704edb5 tests/md5sum.py --- 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 # diff -r e7a4c018b563 -r c102b704edb5 tests/printenv.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 # diff -r e7a4c018b563 -r c102b704edb5 tests/readlink.py --- 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 diff -r e7a4c018b563 -r c102b704edb5 tests/revlog-formatv0.py --- 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 diff -r e7a4c018b563 -r c102b704edb5 tests/run-tests.py --- 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. diff -r e7a4c018b563 -r c102b704edb5 tests/seq.py --- 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' # diff -r e7a4c018b563 -r c102b704edb5 tests/svn-safe-append.py --- 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 diff -r e7a4c018b563 -r c102b704edb5 tests/test-filelog.py --- 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' """ diff -r e7a4c018b563 -r c102b704edb5 tests/test-remotefilelog-datapack.py --- 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 diff -r e7a4c018b563 -r c102b704edb5 tests/test-remotefilelog-histpack.py --- 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 diff -r e7a4c018b563 -r c102b704edb5 tests/test-run-tests.t --- 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 diff -r e7a4c018b563 -r c102b704edb5 tests/test-status-inprocess.py --- 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 diff -r e7a4c018b563 -r c102b704edb5 tests/test-stdio.py --- 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`. """ diff -r e7a4c018b563 -r c102b704edb5 tests/tinyproxy.py --- 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