Bug 1279564 - Return a 2-tuple from get_state_dir(); r=glandium
authorGregory Szorc <gps@mozilla.com>
Fri, 10 Jun 2016 09:39:29 -0700
changeset 302873 cc353a894d96e10c4d78c8d72353760c5288a0ab
parent 302872 910bb13e5929010e0e34b6a08fd3bcf6f5657b6e
child 302874 2812ef2db5977fa7dbebd2330b12a91ff90952c9
push id30377
push usercbook@mozilla.com
push dateWed, 29 Jun 2016 13:04:19 +0000
treeherdermozilla-central@dc77b6514b80 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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()
         # 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(
--- 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