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 id30338
push usergszorc@mozilla.com
push dateTue, 28 Jun 2016 18:14:01 +0000
treeherderautoland@2812ef2db597 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1279564
milestone50.0a1
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
python/mozboot/mozboot/bootstrap.py
python/mozboot/mozboot/util.py
--- 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