diff options
| author | James W. Mills <jameswmills@gmail.com> | 2012-04-12 15:04:13 -0500 |
|---|---|---|
| committer | Shawn O. Pearce <sop@google.com> | 2012-04-23 12:35:08 -0700 |
| commit | 24c130884018364f91baa8de0ff3541f4c32d1bb (patch) | |
| tree | 213b269d05e2a5f2b70d895325301a9a9f30e4a2 /manifest_xml.py | |
| parent | b962a1f5e0daad323bdd66fad93f00a3738cc255 (diff) | |
| download | git-repo-24c130884018364f91baa8de0ff3541f4c32d1bb.tar.gz | |
Add project annotation handling to repo
Allow the optional addition of "annotation" nodes nested under
projects. Each annotation node must have "name" and "value"
attributes. These name/value pairs will be exported into the
environment during any forall command, prefixed with "REPO__"
In addition, an optional "keep" attribute with case insensitive "true"
or "false" values can be included to determine whether the annotation
will be exported with 'repo manifest'
Change-Id: Icd7540afaae02c958f769ce3d25661aa721a9de8
Signed-off-by: James W. Mills <jameswmills@gmail.com>
Diffstat (limited to 'manifest_xml.py')
| -rw-r--r-- | manifest_xml.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/manifest_xml.py b/manifest_xml.py index a250382f..9b804da9 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
| @@ -203,6 +203,13 @@ class XmlManifest(object): | |||
| 203 | if p.groups: | 203 | if p.groups: |
| 204 | e.setAttribute('groups', ','.join(p.groups)) | 204 | e.setAttribute('groups', ','.join(p.groups)) |
| 205 | 205 | ||
| 206 | for a in p.annotations: | ||
| 207 | if a.keep == "true": | ||
| 208 | ae = doc.createElement('annotation') | ||
| 209 | ae.setAttribute('name', a.name) | ||
| 210 | ae.setAttribute('value', a.value) | ||
| 211 | e.appendChild(ae) | ||
| 212 | |||
| 206 | if self._repo_hooks_project: | 213 | if self._repo_hooks_project: |
| 207 | root.appendChild(doc.createTextNode('')) | 214 | root.appendChild(doc.createTextNode('')) |
| 208 | e = doc.createElement('repo-hooks') | 215 | e = doc.createElement('repo-hooks') |
| @@ -545,6 +552,8 @@ class XmlManifest(object): | |||
| 545 | for n in node.childNodes: | 552 | for n in node.childNodes: |
| 546 | if n.nodeName == 'copyfile': | 553 | if n.nodeName == 'copyfile': |
| 547 | self._ParseCopyFile(project, n) | 554 | self._ParseCopyFile(project, n) |
| 555 | if n.nodeName == 'annotation': | ||
| 556 | self._ParseAnnotation(project, n) | ||
| 548 | 557 | ||
| 549 | return project | 558 | return project |
| 550 | 559 | ||
| @@ -556,6 +565,17 @@ class XmlManifest(object): | |||
| 556 | # dest is relative to the top of the tree | 565 | # dest is relative to the top of the tree |
| 557 | project.AddCopyFile(src, dest, os.path.join(self.topdir, dest)) | 566 | project.AddCopyFile(src, dest, os.path.join(self.topdir, dest)) |
| 558 | 567 | ||
| 568 | def _ParseAnnotation(self, project, node): | ||
| 569 | name = self._reqatt(node, 'name') | ||
| 570 | value = self._reqatt(node, 'value') | ||
| 571 | try: | ||
| 572 | keep = self._reqatt(node, 'keep').lower() | ||
| 573 | except ManifestParseError: | ||
| 574 | keep = "true" | ||
| 575 | if keep != "true" and keep != "false": | ||
| 576 | raise ManifestParseError, "optional \"keep\" attribute must be \"true\" or \"false\"" | ||
| 577 | project.AddAnnotation(name, value, keep) | ||
| 578 | |||
| 559 | def _get_remote(self, node): | 579 | def _get_remote(self, node): |
| 560 | name = node.getAttribute('remote') | 580 | name = node.getAttribute('remote') |
| 561 | if not name: | 581 | if not name: |
