repo: upgrade to v2.11
Change-Id: Ia6388b624382c3b2db55c3cca5abacae7793e177
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2626049
Reviewed-by: Michael Mortensen <mmortensen@google.com>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
diff --git a/repo_launcher b/repo_launcher
index 8a3b2aa..0162f0e 100755
--- a/repo_launcher
+++ b/repo_launcher
@@ -32,6 +32,13 @@
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.
class Trace(object):
"""Trace helper logic."""
@@ -70,8 +77,6 @@
def reexec(prog):
exec_command([prog] + sys.argv)
- MIN_PYTHON_VERSION = (3, 6)
-
ver = sys.version_info
major = ver.major
minor = ver.minor
@@ -80,19 +85,26 @@
if (major, minor) < (2, 7):
print('repo: error: Your Python version is too old. '
'Please use Python {}.{} or newer instead.'.format(
- *MIN_PYTHON_VERSION), file=sys.stderr)
+ *MIN_PYTHON_VERSION_SOFT), file=sys.stderr)
sys.exit(1)
# 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
# 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):
reexec('python{}.{}'.format(min_major, min_minor + inc))
- # Try the generic Python 3 wrapper, but only if it's new enough. We don't
- # want to go from (still supported) Python 2.7 to (unsupported) Python 3.5.
+ # Fallback to older versions if possible.
+ 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:
proc = subprocess.Popen(
['python3', '-c', 'import sys; '
@@ -103,18 +115,20 @@
except (OSError, subprocess.CalledProcessError):
python3_ver = None
- # The python3 version looks like it's new enough, so give it a try.
- if python3_ver and python3_ver >= MIN_PYTHON_VERSION:
+ # If the python3 version looks like it's new enough, give it a try.
+ if (python3_ver and python3_ver >= MIN_PYTHON_VERSION_HARD
+ and python3_ver != (major, minor)):
reexec('python3')
# We're still here, so diagnose things for the user.
if major < 3:
- print('repo: warning: Python 2 is no longer supported; '
- 'Please upgrade to Python {}.{}+.'.format(*MIN_PYTHON_VERSION),
+ print('repo: error: Python 2 is no longer supported; '
+ 'Please upgrade to Python {}.{}+.'.format(*MIN_PYTHON_VERSION_HARD),
file=sys.stderr)
- else:
+ sys.exit(1)
+ elif (major, minor) < MIN_PYTHON_VERSION_HARD:
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)
sys.exit(1)
@@ -133,7 +147,7 @@
REPO_REV = 'stable'
# 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
KEYRING_VERSION = (2, 3)
@@ -439,9 +453,11 @@
def gitc_parse_clientdir(gitc_fs_path):
"""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:
return None
@@ -966,9 +982,7 @@
repo = None
olddir = None
- while curdir != '/' \
- and curdir != olddir \
- and not repo:
+ while curdir != olddir and not repo:
repo = os.path.join(curdir, repodir, REPO_MAIN)
if not os.path.isfile(repo):
repo = None