From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web09.14536.1605133791958753580 for ; Wed, 11 Nov 2020 14:29:52 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: ashley.e.desimone@intel.com) IronPort-SDR: b/vfI3ysf+BbwbdePt0sUFkshy9zvW+mNV+tgUbt3wqquHWqWGQZXlmeumy2E5C2Rkb6GMmDEJ JL0qwCo7XtHw== X-IronPort-AV: E=McAfee;i="6000,8403,9802"; a="231848724" X-IronPort-AV: E=Sophos;i="5.77,470,1596524400"; d="scan'208";a="231848724" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Nov 2020 14:29:51 -0800 IronPort-SDR: htzygmiX/Vr0trTqr1gpYENPL23Yciw+wce8rZEGHyyHmyxboyYO0Yd559X43CEMj5povETKgI I23ROW4VJliQ== X-IronPort-AV: E=Sophos;i="5.77,470,1596524400"; d="scan'208";a="366396639" Received: from aedesimo-desk.amr.corp.intel.com ([10.212.245.21]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Nov 2020 14:29:51 -0800 From: "Ashley E Desimone" To: devel@edk2.groups.io Cc: Nate DeSimone , Puja Pandya , Bret Barkelew , Prince Agyeman , Erik Bjorge Subject: [edk2-staging/EdkRepo][PATCH] EdkRepo: Remove unused checkout sha functionality Date: Wed, 11 Nov 2020 14:29:39 -0800 Message-Id: <20201111222939.1433-1-ashley.e.desimone@intel.com> X-Mailer: git-send-email 2.27.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The SHA parameter for the checkout command has been removed previously. This commit removes the calculations which supported this functionality and amends the checkout function to raise an EdkRepoInvalidParameters exception if a valid combo name is not passed in. Cc: Ashley E Desimone Cc: Nate DeSimone Cc: Puja Pandya Cc: Bret Barkelew Cc: Prince Agyeman Cc: Erik Bjorge Signed-off-by: Ashley E Desimone --- edkrepo/common/common_repo_functions.py | 78 ++++--------------------- 1 file changed, 12 insertions(+), 66 deletions(-) diff --git a/edkrepo/common/common_repo_functions.py b/edkrepo/common/common_repo_functions.py index 0d54bbf..2277c1e 100644 --- a/edkrepo/common/common_repo_functions.py +++ b/edkrepo/common/common_repo_functions.py @@ -427,76 +427,22 @@ def combination_is_in_manifest(combination, manifest): return combination in combination_names -def get_target_sources(combination_or_sha, manifest, workspace_path, log=None): - if combination_is_in_manifest(combination_or_sha, manifest): - return manifest.get_repo_sources(combination_or_sha) - - current_combo = manifest.general_config.current_combo - # look for a pin file that is named combination_or_sha.xml - pin_filename = os.path.join( - workspace_path, - 'repo', - combination_or_sha+'.xml') - if os.path.exists(pin_filename): - return ManifestXml(pin_filename).get_repo_sources(current_combo) - - print ("Search repositories for '{}'".format(combination_or_sha)) - commit_map = { - x.root : None - for x in manifest.get_repo_sources(current_combo) - } - found = False - if not log: - log = sort_commits(manifest, workspace_path) - for commit in log: - root = os.path.basename(commit.repo.working_dir) - if combination_or_sha == commit.hexsha: - found = True - commit_map[root] = commit.hexsha - continue - if not found: - continue - if not commit_map[root]: - commit_map[root] = commit.hexsha - if not found: - raise EdkrepoInvalidParametersException(CHECKOUT_INVALID_COMBO) - - # Create a new pin file - old_sources = manifest.get_repo_sources(current_combo) - new_sources = [] - for repo_source in old_sources: - new_sources.append( - repo_source._replace(commit=commit_map[repo_source.root])) - manifest.generate_pin_xml( - combination_or_sha, - current_combo, - new_sources, - filename=pin_filename) - - return ManifestXml(pin_filename).get_repo_sources(current_combo) - - -def checkout(combination_or_sha, verbose=False, override=False, log=None): +def checkout(combination, verbose=False, override=False, log=None): workspace_path = get_workspace_path() manifest = get_workspace_manifest() - # Create combo_or_sha so we have original input and do not introduce any + # Create combo so we have original input and do not introduce any # unintended behavior by messing with parameters. - combo_or_sha = combination_or_sha + combo = combination submodule_combo = manifest.general_config.current_combo try: # Try to handle normalize combo name to match the manifest file. - combo_or_sha = case_insensitive_single_match(combo_or_sha, combinations_in_manifest(manifest)) - submodule_combo = combo_or_sha + combo = case_insensitive_single_match(combo, combinations_in_manifest(manifest)) + submodule_combo = combo except: - # No match so leave it alone. It must be a SHA1 or a bad combo name. - pass + raise EdkrepoInvalidParametersException(CHECKOUT_INVALID_COMBO) - repo_sources = get_target_sources( - combo_or_sha, - manifest, - workspace_path, - log=log) + repo_sources = manifest.get_repo_sources(combo) initial_repo_sources = manifest.get_repo_sources(manifest.general_config.current_combo) # Disable sparse checkout @@ -523,7 +469,7 @@ def checkout(combination_or_sha, verbose=False, override=False, log=None): # Deinit all submodules due to the potential for issues when switching # branches. - if combo_or_sha != manifest.general_config.current_combo: + if combo != manifest.general_config.current_combo: try: deinit_full(workspace_path, manifest, verbose) except Exception as e: @@ -531,19 +477,19 @@ def checkout(combination_or_sha, verbose=False, override=False, log=None): if verbose: print(e) - print(CHECKING_OUT_COMBO.format(combo_or_sha)) + print(CHECKING_OUT_COMBO.format(combo)) try: checkout_repos(verbose, override, repo_sources, workspace_path, manifest) current_repos = repo_sources # Update the current checkout combo in the manifest only if this # combination exists in the manifest - if combination_is_in_manifest(combo_or_sha, manifest): - manifest.write_current_combo(combo_or_sha) + if combination_is_in_manifest(combo, manifest): + manifest.write_current_combo(combo) except: if verbose: traceback.print_exc() - print (CHECKOUT_COMBO_UNSUCCESSFULL.format(combo_or_sha)) + print (CHECKOUT_COMBO_UNSUCCESSFULL.format(combo)) # Return to the initial combo, since there was an issue with cheking out the selected combo checkout_repos(verbose, override, initial_repo_sources, workspace_path, manifest) finally: -- 2.26.2.windows.1