Commit 9b5dd7ab authored by Mike Frysinger's avatar Mike Frysinger Committed by LUCI CQ

repo: upgrade to v2.11

Change-Id: Ia6388b624382c3b2db55c3cca5abacae7793e177
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2626049Reviewed-by: 's avatarMichael Mortensen <mmortensen@google.com>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
parent 87b67778
...@@ -32,6 +32,13 @@ import subprocess ...@@ -32,6 +32,13 @@ import subprocess
import sys import sys
# These should never be newer than the main.py version since this needs to be a
# bit more flexible with older systems. See that file for more details on the
# versions we select.
MIN_PYTHON_VERSION_SOFT = (3, 6)
MIN_PYTHON_VERSION_HARD = (3, 5)
# Keep basic logic in sync with repo_trace.py. # Keep basic logic in sync with repo_trace.py.
class Trace(object): class Trace(object):
"""Trace helper logic.""" """Trace helper logic."""
...@@ -70,8 +77,6 @@ def check_python_version(): ...@@ -70,8 +77,6 @@ def check_python_version():
def reexec(prog): def reexec(prog):
exec_command([prog] + sys.argv) exec_command([prog] + sys.argv)
MIN_PYTHON_VERSION = (3, 6)
ver = sys.version_info ver = sys.version_info
major = ver.major major = ver.major
minor = ver.minor minor = ver.minor
...@@ -80,19 +85,26 @@ def check_python_version(): ...@@ -80,19 +85,26 @@ def check_python_version():
if (major, minor) < (2, 7): if (major, minor) < (2, 7):
print('repo: error: Your Python version is too old. ' print('repo: error: Your Python version is too old. '
'Please use Python {}.{} or newer instead.'.format( 'Please use Python {}.{} or newer instead.'.format(
*MIN_PYTHON_VERSION), file=sys.stderr) *MIN_PYTHON_VERSION_SOFT), file=sys.stderr)
sys.exit(1) sys.exit(1)
# Try to re-exec the version specific Python 3 if needed. # Try to re-exec the version specific Python 3 if needed.
if (major, minor) < MIN_PYTHON_VERSION: if (major, minor) < MIN_PYTHON_VERSION_SOFT:
# Python makes releases ~once a year, so try our min version +10 to help # Python makes releases ~once a year, so try our min version +10 to help
# bridge the gap. This is the fallback anyways so perf isn't critical. # bridge the gap. This is the fallback anyways so perf isn't critical.
min_major, min_minor = MIN_PYTHON_VERSION min_major, min_minor = MIN_PYTHON_VERSION_SOFT
for inc in range(0, 10): for inc in range(0, 10):
reexec('python{}.{}'.format(min_major, min_minor + inc)) reexec('python{}.{}'.format(min_major, min_minor + inc))
# Try the generic Python 3 wrapper, but only if it's new enough. We don't # Fallback to older versions if possible.
# want to go from (still supported) Python 2.7 to (unsupported) Python 3.5. for inc in range(MIN_PYTHON_VERSION_SOFT[1] - MIN_PYTHON_VERSION_HARD[1], 0, -1):
# Don't downgrade, and don't reexec ourselves (which would infinite loop).
if (min_major, min_minor - inc) <= (major, minor):
break
reexec('python{}.{}'.format(min_major, min_minor - inc))
# Try the generic Python 3 wrapper, but only if it's new enough. If it
# isn't, we want to just give up below and make the user resolve things.
try: try:
proc = subprocess.Popen( proc = subprocess.Popen(
['python3', '-c', 'import sys; ' ['python3', '-c', 'import sys; '
...@@ -103,18 +115,20 @@ def check_python_version(): ...@@ -103,18 +115,20 @@ def check_python_version():
except (OSError, subprocess.CalledProcessError): except (OSError, subprocess.CalledProcessError):
python3_ver = None python3_ver = None
# The python3 version looks like it's new enough, so give it a try. # If the python3 version looks like it's new enough, give it a try.
if python3_ver and python3_ver >= MIN_PYTHON_VERSION: if (python3_ver and python3_ver >= MIN_PYTHON_VERSION_HARD
and python3_ver != (major, minor)):
reexec('python3') reexec('python3')
# We're still here, so diagnose things for the user. # We're still here, so diagnose things for the user.
if major < 3: if major < 3:
print('repo: warning: Python 2 is no longer supported; ' print('repo: error: Python 2 is no longer supported; '
'Please upgrade to Python {}.{}+.'.format(*MIN_PYTHON_VERSION), 'Please upgrade to Python {}.{}+.'.format(*MIN_PYTHON_VERSION_HARD),
file=sys.stderr) file=sys.stderr)
else: sys.exit(1)
elif (major, minor) < MIN_PYTHON_VERSION_HARD:
print('repo: error: Python 3 version is too old; ' print('repo: error: Python 3 version is too old; '
'Please use Python {}.{} or newer.'.format(*MIN_PYTHON_VERSION), 'Please use Python {}.{} or newer.'.format(*MIN_PYTHON_VERSION_HARD),
file=sys.stderr) file=sys.stderr)
sys.exit(1) sys.exit(1)
...@@ -133,7 +147,7 @@ if not REPO_REV: ...@@ -133,7 +147,7 @@ if not REPO_REV:
REPO_REV = 'stable' REPO_REV = 'stable'
# increment this whenever we make important changes to this script # increment this whenever we make important changes to this script
VERSION = (2, 8) VERSION = (2, 11)
# increment this if the MAINTAINER_KEYS block is modified # increment this if the MAINTAINER_KEYS block is modified
KEYRING_VERSION = (2, 3) KEYRING_VERSION = (2, 3)
...@@ -439,9 +453,11 @@ def get_gitc_manifest_dir(): ...@@ -439,9 +453,11 @@ def get_gitc_manifest_dir():
def gitc_parse_clientdir(gitc_fs_path): def gitc_parse_clientdir(gitc_fs_path):
"""Parse a path in the GITC FS and return its client name. """Parse a path in the GITC FS and return its client name.
@param gitc_fs_path: A subdirectory path within the GITC_FS_ROOT_DIR. Args:
gitc_fs_path: A subdirectory path within the GITC_FS_ROOT_DIR.
@returns: The GITC client name Returns:
The GITC client name.
""" """
if gitc_fs_path == GITC_FS_ROOT_DIR: if gitc_fs_path == GITC_FS_ROOT_DIR:
return None return None
...@@ -966,9 +982,7 @@ def _FindRepo(): ...@@ -966,9 +982,7 @@ def _FindRepo():
repo = None repo = None
olddir = None olddir = None
while curdir != '/' \ while curdir != olddir and not repo:
and curdir != olddir \
and not repo:
repo = os.path.join(curdir, repodir, REPO_MAIN) repo = os.path.join(curdir, repodir, REPO_MAIN)
if not os.path.isfile(repo): if not os.path.isfile(repo):
repo = None repo = None
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment