From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga17.intel.com (mga17.intel.com []) by mx.groups.io with SMTP id smtpd.web11.4128.1589158229244686585 for ; Sun, 10 May 2020 17:50:30 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: ashley.e.desimone@intel.com) IronPort-SDR: 1eQTPhq0A3XfOsym3eaIoBWuZoJGyQjMCzkGDoCZEL2dqFbpDd4dJHV4MtJxTT3AFoQTBL54rR jY5AQ8Q+sJLw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2020 17:50:29 -0700 IronPort-SDR: aAJJbFL2moh33/yVKyKZWp84snrjW49LJl/wb7kf5CzIhgMbsI+99i/XFrdIpTAS2cVsVAdev5 dbowHr6ahyqw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,377,1583222400"; d="scan'208";a="296747721" Received: from aedesimo-desk.amr.corp.intel.com ([10.212.208.216]) by fmsmga002.fm.intel.com with ESMTP; 10 May 2020 17:50:29 -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 3/4] EdkRepo: Add support for multiple manifest repostories to command completions Date: Sun, 10 May 2020 17:50:25 -0700 Message-Id: <20200511005026.23532-4-ashley.e.desimone@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: <20200511005026.23532-1-ashley.e.desimone@intel.com> References: <20200511005026.23532-1-ashley.e.desimone@intel.com> Update the command completions for the checkout pin command to support multiple manifest repositories. If a source manifest repository cannot be found for the current workspace then no completions will be provided. Signed-off-by: Ashley E Desimone Cc: Nate DeSimone Cc: Puja Pandya Cc: Erik Bjorge Cc: Bret Barkelew Cc: Prince Agyeman --- edkrepo/command_completion_edkrepo.py | 48 +++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/edkrepo/command_completion_edkrepo.py b/edkrepo/command_completion_edkrepo.py index 1220924..8a2c0e6 100644 --- a/edkrepo/command_completion_edkrepo.py +++ b/edkrepo/command_completion_edkrepo.py @@ -15,6 +15,9 @@ import traceback from edkrepo_manifest_parser.edk_manifest import ManifestXml from edkrepo.common.common_repo_functions import combinations_in_manifest +from edkrepo.common.edkrepo_exception import EdkrepoManifestNotFoundException +from edkrepo.common.workspace_maintenance.manifest_repos_maintenance import list_available_manifest_repos +from edkrepo.common.workspace_maintenance.manifest_repos_maintenance import find_source_manifest_repo from edkrepo.config import config_factory from edkrepo.config.config_factory import get_workspace_manifest @@ -28,23 +31,36 @@ def current_combo(parsed_args, config): def checkout_pin(parsed_args, config): pins = [] - manifest_directory = config['cfg_file'].manifest_repo_abs_local_path manifest = get_workspace_manifest() - pin_folder = os.path.normpath(os.path.join(manifest_directory, manifest.general_config.pin_path)) - for dirpath, _, filenames in os.walk(pin_folder): - for file in filenames: - pin_file = os.path.join(dirpath, file) - # Capture error output from manifest parser stdout so it is hidden unless verbose is enabled - stdout = sys.stdout - sys.stdout = io.StringIO() - pin = ManifestXml(pin_file) - parse_output = sys.stdout.getvalue() - sys.stdout = stdout - if parsed_args.verbose and parse_output.strip() != '': - print('Pin {} Parsing Errors: {}\n'.format(file, parse_output.strip())) - if pin.project_info.codename == manifest.project_info.codename: - pins.append(file) - print(' '.join(pins)) + manifest_directory = None + try: + source_manifest_repo = find_source_manifest_repo(manifest, config['cfg_file'], config['user_cfg_file'], ) + if source_manifest_repo: + cfg, user_cfg, conflicts = list_available_manifest_repos(config['cfg_file'], config['user_cfgFile']) + if source_manifest_repo in cfg: + manifest_directory = config['cfg_file'].manifest_repo_abs_path(source_manifest_repo) + elif source_manifest_repo in user_cfg: + manifest_directory = config['user_cfg_file'].manifest_repo_abs_path(source_manifest_repo) + else: + manifest_directory = None + except EdkrepoManifestNotFoundException: + manifest_directory = None + if manifest_directory: + pin_folder = os.path.normpath(os.path.join(manifest_directory, manifest.general_config.pin_path)) + for dirpath, _, filenames in os.walk(pin_folder): + for file in filenames: + pin_file = os.path.join(dirpath, file) + # Capture error output from manifest parser stdout so it is hidden unless verbose is enabled + stdout = sys.stdout + sys.stdout = io.StringIO() + pin = ManifestXml(pin_file) + parse_output = sys.stdout.getvalue() + sys.stdout = stdout + if parsed_args.verbose and parse_output.strip() != '': + print('Pin {} Parsing Errors: {}\n'.format(file, parse_output.strip())) + if pin.project_info.codename == manifest.project_info.codename: + pins.append(file) + print(' '.join(pins)) # To add command completions for a new command, add an entry to this dictionary. command_completions = { -- 2.16.2.windows.1