From 6d5c9de81bb6b1becf0ece8eb6098a9248e6389e Mon Sep 17 00:00:00 2001 From: Ricky Stewart Date: Wed, 2 Sep 2020 14:57:22 +0000 Subject: [PATCH] Bug 1662632 - Fix `UnboundLocalError` due to undefined variable `have_clone` in `mach bootstrap` r=froydnj This consolidates the `have_clone` logic in one place unconditionally. After bug 1647792 we're deprecating the use case where `bootstrap` is run without a clone, so that's not a problem. In reality the whole `have_clone` thing isn't necessary any more (`have_clone` is always going to be `True` in practice), but I'll save that for a bigger refactoring. Differential Revision: https://phabricator.services.mozilla.com/D89152 --- python/mozboot/mozboot/bootstrap.py | 32 +++++++++++------------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/python/mozboot/mozboot/bootstrap.py b/python/mozboot/mozboot/bootstrap.py index 10be8ee78d75..43931a3ab507 100644 --- a/python/mozboot/mozboot/bootstrap.py +++ b/python/mozboot/mozboot/bootstrap.py @@ -402,17 +402,19 @@ class Bootstrapper(object): # as possible if this check fails. self.instance.ensure_python_modern() - if self.instance.no_system_changes: - state_dir_available, state_dir = self.try_to_create_state_dir() - # We need to enable the loading of hgrc in case extensions are - # required to open the repo. - r = current_firefox_checkout( - env=self.instance._hg_cleanenv(load_hgrc=True), - hg=self.instance.which('hg')) - (checkout_type, checkout_root) = r - self.instance.validate_environment(checkout_root) - have_clone = bool(checkout_type) + state_dir_available, state_dir = self.try_to_create_state_dir() + if state_dir_available: + self.instance.state_dir = state_dir + # We need to enable the loading of hgrc in case extensions are + # required to open the repo. + (checkout_type, checkout_root) = current_firefox_checkout( + env=self.instance._hg_cleanenv(load_hgrc=True), + hg=self.instance.which('hg')) + self.instance.validate_environment(checkout_root) + have_clone = bool(checkout_type) + + if self.instance.no_system_changes: if state_dir_available: self.check_telemetry_opt_in(state_dir) self.maybe_install_private_packages_or_exit(state_dir, @@ -432,16 +434,6 @@ class Bootstrapper(object): if not self.instance.artifact_mode: self.instance.ensure_rust_modern() - state_dir_available, state_dir = self.try_to_create_state_dir() - - # We need to enable the loading of hgrc in case extensions are - # required to open the repo. - r = current_firefox_checkout(env=self.instance._hg_cleanenv(load_hgrc=True), - hg=self.instance.which('hg')) - (checkout_type, checkout_root) = r - - self.instance.validate_environment(checkout_root) - # If we didn't specify a VCS, and we aren't in an exiting clone, # offer a choice if not self.vcs: