From 080877e41347b8987977fc8cc3ec90dcd149651a Mon Sep 17 00:00:00 2001 From: Raman Tenneti Date: Tue, 9 Mar 2021 15:19:06 -0800 Subject: superproject: pass groups to ToXml method. Added the following methods to XmlManifest class. + GetDefaultGroupsStr() - return 'default,platform-' + platform.system().lower() + GetGroupsStr() - Same as gitc_utils.py's _manifest_groups func. + Replaced gitc_utils.py's_manifest_groups calls with GetGroupsStr. + Used the above methods to get groups in command.py::GetProjects and part of init.py. TODO: clean up these funcs to take structured group data more instead of passing strings around everywhere that need parsing. Tested the code with the following commands. $ ./run_tests -v Tested the sync code by using repo_dev alias and pointing to this CL and verified prebuilts/fullsdk-linux directory has all the folders. Tested repo init and repo sync with --use-superproject and without --use-superproject argument. $ repo_dev init -u sso://android.git.corp.google.com/platform/manifest -b androidx-main --partial-clone --clone-filter=blob:limit=10M --repo-rev=main --use-superproject $ repo_dev sync -c -j32 Bug: [google internal] b/181804931 Bug: https://crbug.com/gerrit/13707 Change-Id: Ia98585cbfa3a1449710655af55d56241794242b6 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/299422 Reviewed-by: Jonathan Nieder Reviewed-by: Mike Frysinger Tested-by: Raman Tenneti --- gitc_utils.py | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'gitc_utils.py') diff --git a/gitc_utils.py b/gitc_utils.py index a2786c9f..486bbeb0 100644 --- a/gitc_utils.py +++ b/gitc_utils.py @@ -77,22 +77,6 @@ def _set_project_revisions(projects): project.revisionExpr = revisionExpr -def _manifest_groups(manifest): - """Returns the manifest group string that should be synced - - This is the same logic used by Command.GetProjects(), which is used during - repo sync - - Args: - manifest: The XmlManifest object - """ - mp = manifest.manifestProject - groups = mp.config.GetString('manifest.groups') - if not groups: - groups = 'default,platform-' + platform.system().lower() - return groups - - def generate_gitc_manifest(gitc_manifest, manifest, paths=None): """Generate a manifest for shafsd to use for this GITC client. @@ -107,7 +91,7 @@ def generate_gitc_manifest(gitc_manifest, manifest, paths=None): if paths is None: paths = list(manifest.paths.keys()) - groups = [x for x in re.split(r'[,\s]+', _manifest_groups(manifest)) if x] + groups = [x for x in re.split(r'[,\s]+', manifest.GetGroupsStr()) if x] # Convert the paths to projects, and filter them to the matched groups. projects = [manifest.paths[p] for p in paths] @@ -166,7 +150,7 @@ def save_manifest(manifest, client_dir=None): else: manifest_file = os.path.join(client_dir, '.manifest') with open(manifest_file, 'w') as f: - manifest.Save(f, groups=_manifest_groups(manifest)) + manifest.Save(f, groups=manifest.GetGroupsStr()) # TODO(sbasi/jorg): Come up with a solution to remove the sleep below. # Give the GITC filesystem time to register the manifest changes. time.sleep(3) -- cgit v1.2.3-54-g00ecf