mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-12 23:12:21 +00:00
Bug 1630317 - Add a warning if there is an attempt to mach bootstrap from an "old commit" r=nalexander
Differential Revision: https://phabricator.services.mozilla.com/D71076 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
a0e9e925ab
commit
c9156704b1
@ -6,10 +6,11 @@ from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
from collections import OrderedDict
|
||||
|
||||
import os
|
||||
import platform
|
||||
import sys
|
||||
import os
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
# NOTE: This script is intended to be run with a vanilla Python install. We
|
||||
# have to rely on the standard library instead of Python 2+3 helpers like
|
||||
@ -206,6 +207,15 @@ install the review submission tool "moz-phab":
|
||||
'''
|
||||
|
||||
|
||||
OLD_REVISION_WARNING = '''
|
||||
WARNING! You appear to be running `mach bootstrap` from an old revision.
|
||||
bootstrap is meant primarily for getting developer environments up-to-date to
|
||||
build the latest version of tree. Running bootstrap on old revisions may fail
|
||||
and is not guaranteed to bring your machine to any working state in particular.
|
||||
Proceed at your own peril.
|
||||
'''
|
||||
|
||||
|
||||
def update_or_create_build_telemetry_config(path):
|
||||
"""Write a mach config file enabling build telemetry to `path`. If the file does not exist,
|
||||
create it. If it exists, add the new setting to the existing data.
|
||||
@ -678,6 +688,7 @@ def current_firefox_checkout(check_output, env, hg=None):
|
||||
env=env,
|
||||
universal_newlines=True)
|
||||
if node in HG_ROOT_REVISIONS:
|
||||
_warn_if_risky_revision(path)
|
||||
return ('hg', path)
|
||||
# Else the root revision is different. There could be nested
|
||||
# repos. So keep traversing the parents.
|
||||
@ -690,6 +701,7 @@ def current_firefox_checkout(check_output, env, hg=None):
|
||||
elif os.path.exists(git_dir):
|
||||
moz_configure = os.path.join(path, 'moz.configure')
|
||||
if os.path.exists(moz_configure):
|
||||
_warn_if_risky_revision(path)
|
||||
return ('git', path)
|
||||
|
||||
path, child = os.path.split(path)
|
||||
@ -798,3 +810,15 @@ def git_clone_firefox(git, dest, watchman=None):
|
||||
|
||||
print('Firefox source code available at %s' % dest)
|
||||
return True
|
||||
|
||||
|
||||
def _warn_if_risky_revision(path):
|
||||
# Warn the user if they're trying to bootstrap from an obviously old
|
||||
# version of tree as reported by the version control system (a month in
|
||||
# this case). This is an approximate calculation but is probably good
|
||||
# enough for our purposes.
|
||||
NUM_SECONDS_IN_MONTH = 60 * 60 * 24 * 30
|
||||
from mozversioncontrol import get_repository_object
|
||||
repo = get_repository_object(path)
|
||||
if (time.time() - repo.get_commit_time()) >= NUM_SECONDS_IN_MONTH:
|
||||
print(OLD_REVISION_WARNING)
|
||||
|
@ -148,6 +148,11 @@ class Repository(object):
|
||||
def base_ref(self):
|
||||
"""Hash of revision the current topic branch is based on."""
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_commit_time(self):
|
||||
"""Return the Unix time of the HEAD revision.
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def sparse_checkout_present(self):
|
||||
"""Whether the working directory is using a sparse checkout.
|
||||
@ -316,6 +321,10 @@ class HgRepository(Repository):
|
||||
args = [a.encode('utf-8') if not isinstance(a, bytes) else a for a in args]
|
||||
return self._client.rawcommand(args).decode('utf-8')
|
||||
|
||||
def get_commit_time(self):
|
||||
return int(self._run(
|
||||
'parent', '--template', '{word(0, date|hgdate)}').strip())
|
||||
|
||||
def sparse_checkout_present(self):
|
||||
# We assume a sparse checkout is enabled if the .hg/sparse file
|
||||
# has data. Strictly speaking, we should look for a requirement in
|
||||
@ -452,6 +461,9 @@ class GitRepository(Repository):
|
||||
return False
|
||||
return True
|
||||
|
||||
def get_commit_time(self):
|
||||
return int(self._run('log', '-1', '--format=%ct').strip())
|
||||
|
||||
def sparse_checkout_present(self):
|
||||
# Not yet implemented.
|
||||
return False
|
||||
|
Loading…
x
Reference in New Issue
Block a user