Bug 1279564 - Return a 2-tuple from get_state_dir(); r=glandium
This matches the implementation from mach_bootstrap.py.
MozReview-Commit-ID: 8kZCKuIsAMQ
--- a/python/mozboot/mozboot/bootstrap.py
+++ b/python/mozboot/mozboot/bootstrap.py
@@ -218,17 +218,17 @@ class Bootstrapper(object):
hg_installed, hg_modern = self.instance.ensure_mercurial_modern()
self.instance.ensure_python_modern()
# The state directory code is largely duplicated from mach_bootstrap.py.
# We can't easily import mach_bootstrap.py because the bootstrapper may
# run in self-contained mode and only the files in this directory will
# be available. We /could/ refactor parts of mach_bootstrap.py to be
# part of this directory to avoid the code duplication.
- state_dir = get_state_dir()
+ state_dir, _ = get_state_dir()
if not os.path.exists(state_dir):
if not self.instance.no_interactive:
choice = self.instance.prompt_int(
prompt=STATE_DIR_INFO.format(statedir=state_dir),
low=1,
high=2)
--- a/python/mozboot/mozboot/util.py
+++ b/python/mozboot/mozboot/util.py
@@ -1,12 +1,20 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import os
def get_state_dir():
- """Obtain path to a directory to hold state."""
+ """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.
+ """
state_user_dir = os.path.expanduser('~/.mozbuild')
state_env_dir = os.environ.get('MOZBUILD_STATE_PATH')
- return state_env_dir or state_user_dir
+
+ if state_env_dir:
+ return state_env_dir, True
+ else:
+ return state_user_dir, False