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: +paxFh9VkHPWRRaEYZOo/FsfpjTYwaTPWK8idpPaczyB3Oa1kSEHYHhWQsVpqnz18RuUwtCTg1 6VP9o8BNLdRA== 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: V0AVOPSWf16KPkBQNQeTg1kcc0ZiYA0kXVx0HHlGyJuK6mXoAcPeuXaIN+2ZKfrCp1sP6J9M8u cKS+vtiW/nxQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,377,1583222400"; d="scan'208";a="296747710" Received: from aedesimo-desk.amr.corp.intel.com ([10.212.208.216]) by fmsmga002.fm.intel.com with ESMTP; 10 May 2020 17:50:28 -0700 From: "Ashley E Desimone" To: devel@edk2.groups.io Cc: Nate DeSimone , Puja Pandya , Erik Bjorge , Bret Barkelew , Prince Agyeman Subject: [edk2-stagin/EdkRepo] [PATCH 1/4] EdkRepo: Update sync to support multiple manifest repositories Date: Sun, 10 May 2020 17:50:23 -0700 Message-Id: <20200511005026.23532-2-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 sync command to only update the global manifest repository that the workspace is based on and to only check the source manfiest repository for manifest updates. Update the manifest parser to ignore the 'SourceManifestRepository' field when conducting an equality operation. 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 | 36 +++++++++++++++++----------- edkrepo_manifest_parser/edk_manifest.py | 42 +++++++++++++++++++++++++-------- 2 files changed, 54 insertions(+), 24 deletions(-) diff --git a/edkrepo/commands/sync_command.py b/edkrepo/commands/sync_command.py index 82f5247..d1db4f1 100644 --- a/edkrepo/commands/sync_command.py +++ b/edkrepo/commands/sync_command.py @@ -18,7 +18,7 @@ from git import Repo # Our modules from edkrepo.commands.edkrepo_command import EdkrepoCommand -from edkrepo.commands.edkrepo_command import DryRunArgument, SubmoduleSkipArgument +from edkrepo.commands.edkrepo_command import DryRunArgument, SubmoduleSkipArgument, SourceManifestRepoArgument import edkrepo.commands.arguments.sync_args as arguments from edkrepo.common.progress_handler import GitProgressHandler from edkrepo.common.edkrepo_exception import EdkrepoUncommitedChangesException, EdkrepoManifestNotFoundException @@ -32,8 +32,8 @@ from edkrepo.common.humble import MIRROR_BEHIND_PRIMARY_REPO, SYNC_NEEDS_REBASE, 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 -from edkrepo.common.common_repo_functions import reset_sparse_checkout, sparse_checkout, verify_manifest_data +from edkrepo.common.common_repo_functions import clone_repos, sparse_checkout_enabled +from edkrepo.common.common_repo_functions import reset_sparse_checkout, sparse_checkout, verify_single_manifest from edkrepo.common.common_repo_functions import checkout_repos, check_dirty_repos from edkrepo.common.common_repo_functions import update_editor_config from edkrepo.common.common_repo_functions import update_repo_commit_template, get_latest_sha @@ -41,8 +41,12 @@ from edkrepo.common.common_repo_functions import has_primary_repo_remote, fetch_ from edkrepo.common.common_repo_functions import update_hooks, maintain_submodules, combinations_in_manifest from edkrepo.common.common_repo_functions import write_included_config, remove_included_config from edkrepo.common.workspace_maintenance.workspace_maintenance import generate_name_for_obsolete_backup +from edkrepo.common.workspace_maintenance.manifest_repos_maintenance import pull_workspace_manifest_repo +from edkrepo.common.workspace_maintenance.manifest_repos_maintenance import find_source_manifest_repo +from edkrepo.common.workspace_maintenance.manifest_repos_maintenance import list_available_manifest_repos from edkrepo.common.ui_functions import init_color_console from edkrepo.config.config_factory import get_workspace_path, get_workspace_manifest, get_edkrepo_global_data_directory +from edkrepo.config.config_factory import get_workspace_manifest_file from edkrepo_manifest_parser.edk_manifest import CiIndexXml, ManifestXml @@ -71,23 +75,30 @@ class SyncCommand(EdkrepoCommand): 'required' : False, 'help-text' : arguments.OVERRIDE_HELP}) args.append(SubmoduleSkipArgument) + args.append(SourceManifestRepoArgument) return metadata def run_command(self, args, config): update_editor_config(config) + workspace_path = get_workspace_path() initial_manifest = get_workspace_manifest() current_combo = initial_manifest.general_config.current_combo initial_sources = initial_manifest.get_repo_sources(current_combo) initial_hooks = initial_manifest.repo_hooks - pull_latest_manifest_repo(args, config) + source_global_manifest_repo = find_source_manifest_repo(initial_manifest, config['cfg_file'], config['user_cfg_file'], args.source_manifest_repo) + pull_workspace_manifest_repo(initial_manifest, config['cfg_file'], config['user_cfg_file'], args.source_manifest_repo, False) + cfg_manifest_repos, user_cfg_manifest_repos, conflicts = list_available_manifest_repos(config['cfg_file'], config['user_cfg_file']) + if source_global_manifest_repo in cfg_manifest_repos: + global_manifest_directory = config['cfg_file'].manifest_repo_abs_path(source_global_manifest_repo) + verify_single_manifest(config['cfg_file'], source_global_manifest_repo, get_workspace_manifest_file(), args.verbose) + elif source_global_manifest_repo in user_cfg_manifest_repos: + global_manifest_directory = config['user_cfg_file'].manifest_repo_abs_path(source_global_manifest_repo) + verify_single_manifest(config['user_cfg_file'], source_global_manifest_repo, get_workspace_manifest_file(), args.verbose) - # Verify that the latest version of the manifest in the global manifest repository is not broken - global_manifest_directory = config['cfg_file'].manifest_repo_abs_local_path - verify_manifest_data(global_manifest_directory, config, verbose=args.verbose, verify_proj=initial_manifest.project_info.codename) if not args.update_local_manifest: - self.__check_for_new_manifest(args, config, initial_manifest, workspace_path) + self.__check_for_new_manifest(args, config, initial_manifest, workspace_path, global_manifest_directory) check_dirty_repos(initial_manifest, workspace_path) # Determine if sparse checkout needs to be disabled for this operation sparse_settings = initial_manifest.sparse_settings @@ -103,7 +114,7 @@ class SyncCommand(EdkrepoCommand): # Get the latest manifest if requested 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) + self.__update_local_manifest(args, config, initial_manifest, workspace_path, global_manifest_directory) manifest = get_workspace_manifest() if args.update_local_manifest: try: @@ -199,7 +210,7 @@ class SyncCommand(EdkrepoCommand): print(SPARSE_CHECKOUT) sparse_checkout(workspace_path, repo_sources_to_sync, manifest) - def __update_local_manifest(self, args, config, initial_manifest, workspace_path): + def __update_local_manifest(self, args, config, initial_manifest, workspace_path, global_manifest_directory): local_manifest_dir = os.path.join(workspace_path, 'repo') current_combo = initial_manifest.general_config.current_combo initial_sources = initial_manifest.get_repo_sources(current_combo) @@ -210,8 +221,6 @@ class SyncCommand(EdkrepoCommand): origin = repo.remotes.origin origin.fetch() - global_manifest_directory = config['cfg_file'].manifest_repo_abs_local_path - #see if there is an entry in CiIndex.xml that matches the prject name of the current manifest index_path = os.path.join(global_manifest_directory, 'CiIndex.xml') ci_index_xml = CiIndexXml(index_path) @@ -364,8 +373,7 @@ class SyncCommand(EdkrepoCommand): break return repos_to_checkout - def __check_for_new_manifest(self, args, config, initial_manifest, workspace_path): - global_manifest_directory = config['cfg_file'].manifest_repo_abs_local_path + def __check_for_new_manifest(self, args, config, initial_manifest, workspace_path, global_manifest_directory): #see if there is an entry in CiIndex.xml that matches the prject name of the current manifest index_path = os.path.join(global_manifest_directory, 'CiIndex.xml') ci_index_xml = CiIndexXml(index_path) diff --git a/edkrepo_manifest_parser/edk_manifest.py b/edkrepo_manifest_parser/edk_manifest.py index 69583b1..1e2b111 100644 --- a/edkrepo_manifest_parser/edk_manifest.py +++ b/edkrepo_manifest_parser/edk_manifest.py @@ -425,6 +425,7 @@ class ManifestXml(BaseXmlHelper): element = subroot.find('SourceManifestRepository') if element is None: element = ET.SubElement(subroot, 'SourceManifestRepository') + element.tail = '\n' element.attrib['manifest_repo'] = manifest_repo self._tree.write(filename) self.__general_config.source_manifest_repo = manifest_repo @@ -549,7 +550,16 @@ class ManifestXml(BaseXmlHelper): if element1.text != element2.text: return False if element1.tail != element2.tail: - return False + if element1.tail is not None: + tail1 = element1.tail.strip() + else: + tail1 = '' + if element2.tail is not None: + tail2 = element2.tail.strip() + else: + tail2 = '' + if tail1 != tail2: + return False if element1.attrib != element2.attrib: return False if len(element1) != len(element2): @@ -558,25 +568,37 @@ class ManifestXml(BaseXmlHelper): def equals(self, other, ignore_current_combo=False): status = self._compare_elements(self._tree.getroot(), other._tree.getroot()) - if not status and ignore_current_combo: + if not status: tree1 = copy.deepcopy(self._tree.getroot()) tree2 = copy.deepcopy(other._tree.getroot()) subroot = tree1.find('GeneralConfig') if subroot is None: return False - element = subroot.find('CurrentClonedCombo') + if ignore_current_combo: + element = subroot.find('CurrentClonedCombo') + if element is None: + element = ET.SubElement(subroot, 'CurrentClonedCombo') + element.tail = '\n' + element.attrib['combination'] = '' + element = subroot.find('SourceManifestRepository') if element is None: - element = ET.SubElement(subroot, 'CurrentClonedCombo') - element.tail = '\n' - element.attrib['combination'] = '' + element = ET.SubElement(subroot, 'SourceManifestRepository') + element.tail ='\n' + element.attrib['manifest_repo'] = '' subroot = tree2.find('GeneralConfig') if subroot is None: return False - element = subroot.find('CurrentClonedCombo') + if ignore_current_combo: + element = subroot.find('CurrentClonedCombo') + if element is None: + element = ET.SubElement(subroot, 'CurrentClonedCombo') + element.tail = '\n' + element.attrib['combination'] = '' + element = subroot.find('SourceManifestRepository') if element is None: - element = ET.SubElement(subroot, 'CurrentClonedCombo') - element.tail = '\n' - element.attrib['combination'] = '' + element = ET.SubElement(subroot, 'SourceManifestRepository') + element.tail ='\n' + element.attrib['manifest_repo'] = '' status = self._compare_elements(tree1, tree2) return status -- 2.16.2.windows.1