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 382020 cc353a894d96e10c4d78c8d72353760c5288a0ab
parent 382019 910bb13e5929010e0e34b6a08fd3bcf6f5657b6e
child 382021 2812ef2db5977fa7dbebd2330b12a91ff90952c9
push id21593
push userbmo:gps@mozilla.com
push dateTue, 28 Jun 2016 17:22:28 +0000
reviewersglandium
bugs1279564
milestone50.0a1
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