зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1483228 - [mozboot] Simplify get_state_dir()'s return value r=nalexander
mozboot.util.get_state_dir() returns a tuple of (<path>, <bool). The bool denotes whether or not the state dir came from an environment variable. But this value is only used in a single place, and is very easy to test for anyway. It's not worth the added complexity it imposes on all other consumers of this function. Let's just make this function return the path. Differential Revision: https://phabricator.services.mozilla.com/D15723 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
fcd9370792
Коммит
8bc7850637
|
@ -264,7 +264,7 @@ def bootstrap(topsrcdir, mozilla_dir=None):
|
|||
mach_context=context, substs=substs,
|
||||
paths=paths)
|
||||
if data:
|
||||
telemetry_dir = os.path.join(get_state_dir()[0], 'telemetry')
|
||||
telemetry_dir = os.path.join(get_state_dir(), 'telemetry')
|
||||
try:
|
||||
os.mkdir(telemetry_dir)
|
||||
except OSError as e:
|
||||
|
@ -284,7 +284,7 @@ def bootstrap(topsrcdir, mozilla_dir=None):
|
|||
if should_skip_telemetry_submission(handler):
|
||||
return True
|
||||
|
||||
state_dir, _ = get_state_dir()
|
||||
state_dir = get_state_dir()
|
||||
|
||||
machpath = os.path.join(instance.topsrcdir, 'mach')
|
||||
with open(os.devnull, 'wb') as devnull:
|
||||
|
@ -299,8 +299,8 @@ def bootstrap(topsrcdir, mozilla_dir=None):
|
|||
if key is None:
|
||||
return
|
||||
if key == 'state_dir':
|
||||
state_dir, is_environ = get_state_dir()
|
||||
if is_environ:
|
||||
state_dir = get_state_dir()
|
||||
if state_dir == os.environ.get('MOZBUILD_STATE_PATH'):
|
||||
if not os.path.exists(state_dir):
|
||||
print('Creating global state directory from environment variable: %s'
|
||||
% state_dir)
|
||||
|
@ -340,7 +340,7 @@ def bootstrap(topsrcdir, mozilla_dir=None):
|
|||
|
||||
if not driver.settings_paths:
|
||||
# default global machrc location
|
||||
driver.settings_paths.append(get_state_dir()[0])
|
||||
driver.settings_paths.append(get_state_dir())
|
||||
# always load local repository configuration
|
||||
driver.settings_paths.append(mozilla_dir)
|
||||
|
||||
|
|
|
@ -341,7 +341,7 @@ class Bootstrapper(object):
|
|||
# be available. We /could/ refactor parts of mach_bootstrap.py to be
|
||||
# part of this directory to avoid the code duplication.
|
||||
def try_to_create_state_dir(self):
|
||||
state_dir, _ = get_state_dir()
|
||||
state_dir = get_state_dir()
|
||||
|
||||
if not os.path.exists(state_dir):
|
||||
should_create_state_dir = True
|
||||
|
|
|
@ -10,13 +10,7 @@ import os
|
|||
def get_state_dir():
|
||||
"""Obtain path to a directory to hold state.
|
||||
|
||||
Returns a tuple of the path and a bool indicating whether the
|
||||
value came from an environment variable.
|
||||
Returns:
|
||||
A path to the state dir (str)
|
||||
"""
|
||||
state_user_dir = os.path.expanduser('~/.mozbuild')
|
||||
state_env_dir = os.environ.get('MOZBUILD_STATE_PATH')
|
||||
|
||||
if state_env_dir:
|
||||
return state_env_dir, True
|
||||
else:
|
||||
return state_user_dir, False
|
||||
return os.environ.get('MOZBUILD_STATE_PATH', os.path.expanduser('~/.mozbuild'))
|
||||
|
|
|
@ -25,7 +25,7 @@ def find_node_paths():
|
|||
"""
|
||||
# Also add in the location to which `mach bootstrap` or
|
||||
# `mach artifact toolchain` installs clang.
|
||||
mozbuild_state_dir, _ = get_state_dir()
|
||||
mozbuild_state_dir = get_state_dir()
|
||||
|
||||
if platform.system() == "Windows":
|
||||
mozbuild_node_path = os.path.join(mozbuild_state_dir, 'node')
|
||||
|
|
|
@ -71,7 +71,7 @@ class RaptorRunner(MozbuildObject):
|
|||
print("Updating external benchmarks from {}".format(BENCHMARK_REPOSITORY))
|
||||
|
||||
# Set up the external repo
|
||||
external_repo_path = os.path.join(get_state_dir()[0], 'performance-tests')
|
||||
external_repo_path = os.path.join(get_state_dir(), 'performance-tests')
|
||||
|
||||
try:
|
||||
subprocess.check_output(['git', '--version'])
|
||||
|
|
|
@ -49,7 +49,7 @@ def create_parser():
|
|||
"--rewrite-config", action="store_true", default=False,
|
||||
help="Force the local configuration to be regenerated")
|
||||
p.add_argument(
|
||||
"--cache-root", action="store", default=os.path.join(get_state_dir()[0], "cache", "wpt"),
|
||||
"--cache-root", action="store", default=os.path.join(get_state_dir(), "cache", "wpt"),
|
||||
help="Path to use for the metadata cache")
|
||||
commandline.add_logging_group(p)
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import subprocess
|
|||
from mozboot.util import get_state_dir
|
||||
|
||||
|
||||
CONFIG_PATH = os.path.join(get_state_dir()[0], "autotry.ini")
|
||||
CONFIG_PATH = os.path.join(get_state_dir(), "autotry.ini")
|
||||
|
||||
|
||||
def list_presets(section=None):
|
||||
|
|
|
@ -45,8 +45,8 @@ here = os.path.abspath(os.path.dirname(__file__))
|
|||
build = MozbuildObject.from_environment(cwd=here)
|
||||
vcs = get_repository_object(build.topsrcdir)
|
||||
topsrcdir_hash = hashlib.sha256(os.path.abspath(build.topsrcdir)).hexdigest()
|
||||
history_path = os.path.join(get_state_dir()[0], 'history', topsrcdir_hash, 'try_task_configs.json')
|
||||
old_history_path = os.path.join(get_state_dir()[0], 'history', 'try_task_configs.json')
|
||||
history_path = os.path.join(get_state_dir(), 'history', topsrcdir_hash, 'try_task_configs.json')
|
||||
old_history_path = os.path.join(get_state_dir(), 'history', 'try_task_configs.json')
|
||||
|
||||
|
||||
def write_task_config(try_task_config):
|
||||
|
|
|
@ -30,7 +30,7 @@ build = MozbuildObject.from_environment(cwd=here)
|
|||
vcs = get_repository_object(build.topsrcdir)
|
||||
|
||||
root_hash = hashlib.sha256(os.path.abspath(build.topsrcdir)).hexdigest()
|
||||
cache_dir = os.path.join(get_state_dir()[0], 'cache', root_hash, 'chunk_mapping')
|
||||
cache_dir = os.path.join(get_state_dir(), 'cache', root_hash, 'chunk_mapping')
|
||||
if not os.path.isdir(cache_dir):
|
||||
os.makedirs(cache_dir)
|
||||
CHUNK_MAPPING_FILE = os.path.join(cache_dir, 'chunk_mapping.sqlite')
|
||||
|
|
|
@ -136,7 +136,7 @@ def fzf_bootstrap(update=False):
|
|||
if fzf_bin and not update:
|
||||
return fzf_bin
|
||||
|
||||
fzf_path = os.path.join(get_state_dir()[0], 'fzf')
|
||||
fzf_path = os.path.join(get_state_dir(), 'fzf')
|
||||
if update and not os.path.isdir(fzf_path):
|
||||
print("fzf installed somewhere other than {}, please update manually".format(fzf_path))
|
||||
sys.exit(1)
|
||||
|
|
|
@ -58,12 +58,12 @@ def generate_tasks(params, full, root):
|
|||
params = params or "project=mozilla-central"
|
||||
|
||||
# Try to delete the old taskgraph cache directory.
|
||||
old_cache_dir = os.path.join(get_state_dir()[0], 'cache', 'taskgraph')
|
||||
old_cache_dir = os.path.join(get_state_dir(), 'cache', 'taskgraph')
|
||||
if os.path.isdir(old_cache_dir):
|
||||
shutil.rmtree(old_cache_dir)
|
||||
|
||||
root_hash = hashlib.sha256(os.path.abspath(root)).hexdigest()
|
||||
cache_dir = os.path.join(get_state_dir()[0], 'cache', root_hash, 'taskgraph')
|
||||
cache_dir = os.path.join(get_state_dir(), 'cache', root_hash, 'taskgraph')
|
||||
|
||||
# Cleanup old cache files
|
||||
for path in glob.glob(os.path.join(cache_dir, '*_set')):
|
||||
|
|
Загрузка…
Ссылка в новой задаче