diff options
author | Fredrik de Groot <fredrik.de.groot@volvocars.com> | 2020-10-06 12:55:14 +0200 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2020-11-26 09:13:14 +0000 |
commit | 352c93b68084e97ec7a3c09f0bd3f2a161290211 (patch) | |
tree | cf2e19805c6046a12aa221dd6c9747da570994a9 /manifest_xml.py | |
parent | 7f7acfe9fd93cfd4a697f2bc851d1b8182f6336e (diff) | |
download | git-repo-352c93b68084e97ec7a3c09f0bd3f2a161290211.tar.gz |
manifest: add support for groups in includev2.10
Attrib groups can now be added to manifest include, thus
all projects in an included manifest file can easily be tagged
with a group without modifying all projects in that manifest file.
Include groups will add and recurse, meaning included manifest
projects will carry all parent includes. Intentionally, no support
added for group remove, to keep complexity down.
Group handling for projects is untouched, meaning a group set on
a project will still append to whatever was or was not inherited
in parent manifest includes, resulting in union of groups inherited
and set for the project itself.
Test: manual multi-level manifest include structure, in serial and parallel,
with different groups set on init
Test: added unit tests to cover the inheritance
Change-Id: Id2229aa6fd78d355ba598cc15c701b2ee71e5c6f
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/283587
Tested-by: Fredrik de Groot <fredrik.de.groot@volvocars.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'manifest_xml.py')
-rw-r--r-- | manifest_xml.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/manifest_xml.py b/manifest_xml.py index 95c67d73..ad0017cc 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
@@ -637,7 +637,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
637 | 637 | ||
638 | self._loaded = True | 638 | self._loaded = True |
639 | 639 | ||
640 | def _ParseManifestXml(self, path, include_root): | 640 | def _ParseManifestXml(self, path, include_root, parent_groups=''): |
641 | try: | 641 | try: |
642 | root = xml.dom.minidom.parse(path) | 642 | root = xml.dom.minidom.parse(path) |
643 | except (OSError, xml.parsers.expat.ExpatError) as e: | 643 | except (OSError, xml.parsers.expat.ExpatError) as e: |
@@ -656,12 +656,17 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
656 | for node in manifest.childNodes: | 656 | for node in manifest.childNodes: |
657 | if node.nodeName == 'include': | 657 | if node.nodeName == 'include': |
658 | name = self._reqatt(node, 'name') | 658 | name = self._reqatt(node, 'name') |
659 | include_groups = '' | ||
660 | if parent_groups: | ||
661 | include_groups = parent_groups | ||
662 | if node.hasAttribute('groups'): | ||
663 | include_groups = node.getAttribute('groups') + ',' + include_groups | ||
659 | fp = os.path.join(include_root, name) | 664 | fp = os.path.join(include_root, name) |
660 | if not os.path.isfile(fp): | 665 | if not os.path.isfile(fp): |
661 | raise ManifestParseError("include %s doesn't exist or isn't a file" | 666 | raise ManifestParseError("include %s doesn't exist or isn't a file" |
662 | % (name,)) | 667 | % (name,)) |
663 | try: | 668 | try: |
664 | nodes.extend(self._ParseManifestXml(fp, include_root)) | 669 | nodes.extend(self._ParseManifestXml(fp, include_root, include_groups)) |
665 | # should isolate this to the exact exception, but that's | 670 | # should isolate this to the exact exception, but that's |
666 | # tricky. actual parsing implementation may vary. | 671 | # tricky. actual parsing implementation may vary. |
667 | except (KeyboardInterrupt, RuntimeError, SystemExit): | 672 | except (KeyboardInterrupt, RuntimeError, SystemExit): |
@@ -670,6 +675,11 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
670 | raise ManifestParseError( | 675 | raise ManifestParseError( |
671 | "failed parsing included manifest %s: %s" % (name, e)) | 676 | "failed parsing included manifest %s: %s" % (name, e)) |
672 | else: | 677 | else: |
678 | if parent_groups and node.nodeName == 'project': | ||
679 | nodeGroups = parent_groups | ||
680 | if node.hasAttribute('groups'): | ||
681 | nodeGroups = node.getAttribute('groups') + ',' + nodeGroups | ||
682 | node.setAttribute('groups', nodeGroups) | ||
673 | nodes.append(node) | 683 | nodes.append(node) |
674 | return nodes | 684 | return nodes |
675 | 685 | ||