diff options
author | LaMont Jones <lamontjones@google.com> | 2022-04-07 18:14:46 +0000 |
---|---|---|
committer | LaMont Jones <lamontjones@google.com> | 2022-04-12 15:46:23 +0000 |
commit | d56e2eb4216827284220fcc35af42e60b4faaea6 (patch) | |
tree | 886d25de764ce3abe6978b639d1a715e2e7b6277 /manifest_xml.py | |
parent | d52ca421d52c75837d1614ec54549569f354b7ec (diff) | |
download | git-repo-d56e2eb4216827284220fcc35af42e60b4faaea6.tar.gz |
manifest_xml: use Superproject to hold XML contentv2.23
Always create Superproject when there is a <superproject> tag, and have
it hold the XML content, similar to how other manifest elements are
handled.
This also adds SetQuiet and SetPrintMessages to Superproject
consistent with manifest.SetUseLocalManifests.
Change-Id: I522bf3da542006575799f0640c67f7052704f266
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/334641
Reviewed-by: Mike Frysinger <vapier@google.com>
Reviewed-by: Raman Tenneti <rtenneti@google.com>
Tested-by: LaMont Jones <lamontjones@google.com>
Diffstat (limited to 'manifest_xml.py')
-rw-r--r-- | manifest_xml.py | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/manifest_xml.py b/manifest_xml.py index 8718dc54..7d19d63e 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
@@ -24,6 +24,7 @@ import urllib.parse | |||
24 | import gitc_utils | 24 | import gitc_utils |
25 | from git_config import GitConfig, IsId | 25 | from git_config import GitConfig, IsId |
26 | from git_refs import R_HEADS, HEAD | 26 | from git_refs import R_HEADS, HEAD |
27 | from git_superproject import Superproject | ||
27 | import platform_utils | 28 | import platform_utils |
28 | from project import (Annotation, RemoteSpec, Project, RepoProject, | 29 | from project import (Annotation, RemoteSpec, Project, RepoProject, |
29 | ManifestProject) | 30 | ManifestProject) |
@@ -670,17 +671,17 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
670 | if self._superproject: | 671 | if self._superproject: |
671 | root.appendChild(doc.createTextNode('')) | 672 | root.appendChild(doc.createTextNode('')) |
672 | e = doc.createElement('superproject') | 673 | e = doc.createElement('superproject') |
673 | e.setAttribute('name', self._superproject['name']) | 674 | e.setAttribute('name', self._superproject.name) |
674 | remoteName = None | 675 | remoteName = None |
675 | if d.remote: | 676 | if d.remote: |
676 | remoteName = d.remote.name | 677 | remoteName = d.remote.name |
677 | remote = self._superproject.get('remote') | 678 | remote = self._superproject.remote |
678 | if not d.remote or remote.orig_name != remoteName: | 679 | if not d.remote or remote.orig_name != remoteName: |
679 | remoteName = remote.orig_name | 680 | remoteName = remote.orig_name |
680 | e.setAttribute('remote', remoteName) | 681 | e.setAttribute('remote', remoteName) |
681 | revision = remote.revision or d.revisionExpr | 682 | revision = remote.revision or d.revisionExpr |
682 | if not revision or revision != self._superproject['revision']: | 683 | if not revision or revision != self._superproject.revision: |
683 | e.setAttribute('revision', self._superproject['revision']) | 684 | e.setAttribute('revision', self._superproject.revision) |
684 | root.appendChild(e) | 685 | root.appendChild(e) |
685 | 686 | ||
686 | if self._contactinfo.bugurl != Wrapper().BUG_URL: | 687 | if self._contactinfo.bugurl != Wrapper().BUG_URL: |
@@ -984,7 +985,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
984 | self._default = None | 985 | self._default = None |
985 | self._submanifests = {} | 986 | self._submanifests = {} |
986 | self._repo_hooks_project = None | 987 | self._repo_hooks_project = None |
987 | self._superproject = {} | 988 | self._superproject = None |
988 | self._contactinfo = ContactInfo(Wrapper().BUG_URL) | 989 | self._contactinfo = ContactInfo(Wrapper().BUG_URL) |
989 | self._notice = None | 990 | self._notice = None |
990 | self.branch = None | 991 | self.branch = None |
@@ -1052,20 +1053,19 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
1052 | 1053 | ||
1053 | # Now that we have loaded this manifest, load any submanifest manifests | 1054 | # Now that we have loaded this manifest, load any submanifest manifests |
1054 | # as well. We need to do this after self._loaded is set to avoid looping. | 1055 | # as well. We need to do this after self._loaded is set to avoid looping. |
1055 | if self._outer_client: | 1056 | for name in self._submanifests: |
1056 | for name in self._submanifests: | 1057 | tree = self._submanifests[name] |
1057 | tree = self._submanifests[name] | 1058 | spec = tree.ToSubmanifestSpec(self) |
1058 | spec = tree.ToSubmanifestSpec(self) | 1059 | present = os.path.exists(os.path.join(self.subdir, MANIFEST_FILE_NAME)) |
1059 | present = os.path.exists(os.path.join(self.subdir, MANIFEST_FILE_NAME)) | 1060 | if present and tree.present and not tree.repo_client: |
1060 | if present and tree.present and not tree.repo_client: | 1061 | if initial_client and initial_client.topdir == self.topdir: |
1061 | if initial_client and initial_client.topdir == self.topdir: | 1062 | tree.repo_client = self |
1062 | tree.repo_client = self | 1063 | tree.present = present |
1063 | tree.present = present | 1064 | elif not os.path.exists(self.subdir): |
1064 | elif not os.path.exists(self.subdir): | 1065 | tree.present = False |
1065 | tree.present = False | 1066 | if present and tree.present: |
1066 | if present and tree.present: | 1067 | tree.repo_client._Load(initial_client=initial_client, |
1067 | tree.repo_client._Load(initial_client=initial_client, | 1068 | submanifest_depth=submanifest_depth + 1) |
1068 | submanifest_depth=submanifest_depth + 1) | ||
1069 | 1069 | ||
1070 | def _ParseManifestXml(self, path, include_root, parent_groups='', | 1070 | def _ParseManifestXml(self, path, include_root, parent_groups='', |
1071 | restrict_includes=True): | 1071 | restrict_includes=True): |
@@ -1267,11 +1267,10 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
1267 | if node.nodeName == 'superproject': | 1267 | if node.nodeName == 'superproject': |
1268 | name = self._reqatt(node, 'name') | 1268 | name = self._reqatt(node, 'name') |
1269 | # There can only be one superproject. | 1269 | # There can only be one superproject. |
1270 | if self._superproject.get('name'): | 1270 | if self._superproject: |
1271 | raise ManifestParseError( | 1271 | raise ManifestParseError( |
1272 | 'duplicate superproject in %s' % | 1272 | 'duplicate superproject in %s' % |
1273 | (self.manifestFile)) | 1273 | (self.manifestFile)) |
1274 | self._superproject['name'] = name | ||
1275 | remote_name = node.getAttribute('remote') | 1274 | remote_name = node.getAttribute('remote') |
1276 | if not remote_name: | 1275 | if not remote_name: |
1277 | remote = self._default.remote | 1276 | remote = self._default.remote |
@@ -1280,14 +1279,16 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
1280 | if remote is None: | 1279 | if remote is None: |
1281 | raise ManifestParseError("no remote for superproject %s within %s" % | 1280 | raise ManifestParseError("no remote for superproject %s within %s" % |
1282 | (name, self.manifestFile)) | 1281 | (name, self.manifestFile)) |
1283 | self._superproject['remote'] = remote.ToRemoteSpec(name) | ||
1284 | revision = node.getAttribute('revision') or remote.revision | 1282 | revision = node.getAttribute('revision') or remote.revision |
1285 | if not revision: | 1283 | if not revision: |
1286 | revision = self._default.revisionExpr | 1284 | revision = self._default.revisionExpr |
1287 | if not revision: | 1285 | if not revision: |
1288 | raise ManifestParseError('no revision for superproject %s within %s' % | 1286 | raise ManifestParseError('no revision for superproject %s within %s' % |
1289 | (name, self.manifestFile)) | 1287 | (name, self.manifestFile)) |
1290 | self._superproject['revision'] = revision | 1288 | self._superproject = Superproject(self, |
1289 | name=name, | ||
1290 | remote=remote.ToRemoteSpec(name), | ||
1291 | revision=revision) | ||
1291 | if node.nodeName == 'contactinfo': | 1292 | if node.nodeName == 'contactinfo': |
1292 | bugurl = self._reqatt(node, 'bugurl') | 1293 | bugurl = self._reqatt(node, 'bugurl') |
1293 | # This element can be repeated, later entries will clobber earlier ones. | 1294 | # This element can be repeated, later entries will clobber earlier ones. |