From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web10.20763.1586975120217302346 for ; Wed, 15 Apr 2020 11:25:20 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: ashley.e.desimone@intel.com) IronPort-SDR: LcsH/xnNeYtXP0GpUAbNZwPe/dHJ8joUDf415kBRdR4wcY+nswpiFn7TlMXa4ds2ycSoN7v1DL dqYWHTeJR1KQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2020 11:25:19 -0700 IronPort-SDR: gTliVznwwJ5+U8YganbDIEPqiXf++AE2dqr4MtshUAQjG/EEFkvY8JqQVrUzqrI2FcMSbYJk0Q Mp7fgEUc4c0A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,388,1580803200"; d="scan'208";a="242387932" Received: from aedesimo-desk.amr.corp.intel.com ([10.7.159.171]) by orsmga007.jf.intel.com with ESMTP; 15 Apr 2020 11:25:19 -0700 From: "Ashley E Desimone" To: devel@edk2.groups.io Cc: Nate DeSimone , Puja Pandya , Erik Bjorge , Bret Barkelew , Prince Agyeman Subject: [edk2-staging/EdkRepo] [PATCH] EdkRepo: Resolve UnboundLocalError in edkrepo.sync Date: Wed, 15 Apr 2020 11:25:13 -0700 Message-Id: <20200415182513.35448-1-ashley.e.desimone@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 Fix: 'Error: local variable 'repo_sources_to_sync' referenced before assignment' by adding the case where it is populated based on the current combo when not using the -u flag. Signed-off-by: Ashley E Desimone Cc: Nate DeSimone Cc: Puja Pandya Cc: Erik Bjorge Cc: Bret Barkelew Cc: Prince Agyeman --- edkrepo/commands/sync_command.py | 58 +++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/edkrepo/commands/sync_command.py b/edkrepo/commands/sync_command.py index 7e4c89d..cb9dc4b 100644 --- a/edkrepo/commands/sync_command.py +++ b/edkrepo/commands/sync_command.py @@ -29,7 +29,7 @@ from edkrepo.common.humble import SYNC_MANIFEST_DIFF_WARNING, SYNC_MANIFEST_UPDA from edkrepo.common.humble import SPARSE_RESET, SPARSE_CHECKOUT, SYNC_REPO_CHANGE, SYNCING, FETCHING, UPDATING_MANIFEST from edkrepo.common.humble import NO_SYNC_DETACHED_HEAD, SYNC_COMMITS_ON_MASTER, SYNC_ERROR from edkrepo.common.humble import MIRROR_BEHIND_PRIMARY_REPO, SYNC_NEEDS_REBASE, INCLUDED_FILE_NAME -from edkrepo.common.humble import SYNC_BRANCH_CHANGE_ON_LOCAL, SYNC_INCOMPATIBLE_COMBO +from edkrepo.common.humble import SYNC_BRANCH_CHANGE_ON_LOCAL, SYNC_INCOMPATIBLE_COMBO from edkrepo.common.humble import SYNC_REBASE_CALC_FAIL from edkrepo.common.pathfix import get_actual_path from edkrepo.common.common_repo_functions import pull_latest_manifest_repo, clone_repos, sparse_checkout_enabled @@ -104,15 +104,17 @@ class SyncCommand(EdkrepoCommand): if args.update_local_manifest: #NOTE: hyphens in arg name replaced with underscores due to argparse self.__update_local_manifest(args, config, initial_manifest, workspace_path) manifest = get_workspace_manifest() - if args.update_local_manifest: - try: - repo_sources_to_sync = manifest.get_repo_sources(current_combo) - except ValueError: - # The manifest file was updated and the initial combo is no longer present so use the default combo - current_combo = manifest.general_config.default_combo - repo_sources_to_sync = manifest.get_repo_sources(current_combo) + if args.update_local_manifest: + try: + repo_sources_to_sync = manifest.get_repo_sources(current_combo) + except ValueError: + # The manifest file was updated and the initial combo is no longer present so use the default combo + current_combo = manifest.general_config.default_combo + repo_sources_to_sync = manifest.get_repo_sources(current_combo) + else: + repo_sources_to_sync = manifest.get_repo_sources(current_combo) manifest.write_current_combo(current_combo) - + sync_error = False # Calculate the hooks which need to be updated, added or removed for the sync if args.update_local_manifest: @@ -218,26 +220,26 @@ class SyncCommand(EdkrepoCommand): ci_index_xml_rel_path = os.path.normpath(ci_index_xml.get_project_xml(initial_manifest.project_info.codename)) global_manifest_path = os.path.join(global_manifest_directory, ci_index_xml_rel_path) new_manifest_to_check = ManifestXml(global_manifest_path) - - # Does the current combo exist in the new manifest? If not check to see if you can use the repo sources from - # the default combo - initial_combos = combinations_in_manifest(initial_manifest) - new_combos = combinations_in_manifest(new_manifest_to_check) - if (current_combo not in new_combos) or (set(new_combos) != set(initial_combos)): - if initial_manifest.get_repo_sources(current_combo) == new_manifest_to_check.get_repo_sources(new_manifest_to_check.general_config.default_combo): - new_sources_for_current_combo = new_manifest_to_check.get_repo_sources(new_manifest_to_check.general_config.default_combo) - new_sources = new_sources_for_current_combo - else: - # Since asymetric combinations are not supported error out with an IMCOMPATIBLE_COMBO warning - print(SYNC_COMBO_CHANGE.format(current_combo, initial_manifest.project_info.codename)) - raise EdkrepoManifestChangedException(SYNC_INCOMPATIBLE_COMBO) - else: - new_sources_for_current_combo = new_manifest_to_check.get_repo_sources(current_combo) - new_sources = new_manifest_to_check.get_repo_sources(current_combo) - + + # Does the current combo exist in the new manifest? If not check to see if you can use the repo sources from + # the default combo + initial_combos = combinations_in_manifest(initial_manifest) + new_combos = combinations_in_manifest(new_manifest_to_check) + if (current_combo not in new_combos) or (set(new_combos) != set(initial_combos)): + if initial_manifest.get_repo_sources(current_combo) == new_manifest_to_check.get_repo_sources(new_manifest_to_check.general_config.default_combo): + new_sources_for_current_combo = new_manifest_to_check.get_repo_sources(new_manifest_to_check.general_config.default_combo) + new_sources = new_sources_for_current_combo + else: + # Since asymetric combinations are not supported error out with an IMCOMPATIBLE_COMBO warning + print(SYNC_COMBO_CHANGE.format(current_combo, initial_manifest.project_info.codename)) + raise EdkrepoManifestChangedException(SYNC_INCOMPATIBLE_COMBO) + else: + new_sources_for_current_combo = new_manifest_to_check.get_repo_sources(current_combo) + new_sources = new_manifest_to_check.get_repo_sources(current_combo) + remove_included_config(initial_manifest.remotes, initial_manifest.submodule_alternate_remotes, local_manifest_dir) write_included_config(new_manifest_to_check.remotes, new_manifest_to_check.submodule_alternate_remotes, local_manifest_dir) - + self.__check_submodule_config(workspace_path, new_manifest_to_check, new_sources_for_current_combo) new_manifest_remotes = {name:url for name, url in new_manifest_to_check.remotes} #check for changes to remote urls @@ -245,7 +247,7 @@ class SyncCommand(EdkrepoCommand): if remote_name in new_manifest_remotes.keys(): if initial_manifest_remotes[remote_name] != new_manifest_remotes[remote_name]: raise EdkrepoManifestChangedException(SYNC_URL_CHANGE.format(remote_name)) - + # Check that the repo sources lists are the same. If they are not the same and the override flag is not set, throw an exception. if not args.override and set(initial_sources) != set(new_sources): raise EdkrepoManifestChangedException(SYNC_REPO_CHANGE.format(initial_manifest.project_info.codename)) -- 2.16.2.windows.1