diff options
| author | Colin Cross <ccross@android.com> | 2012-03-28 20:15:45 -0700 |
|---|---|---|
| committer | Shawn Pearce <sop@google.com> | 2012-04-13 09:46:00 -0700 |
| commit | 5acde75e5d70b323197ffb2c9d4fdea3612098f5 (patch) | |
| tree | e995a64614ce7406633ae6e99c2a0e6f86872e09 /manifest_xml.py | |
| parent | d67872d2f47b2f09a0e2aa4adfd62e6f69154c9b (diff) | |
| download | git-repo-5acde75e5d70b323197ffb2c9d4fdea3612098f5.tar.gz | |
Add manifest groupsv1.8.2
Allows specifying a list of groups with a -g argument to repo init.
The groups act on a group= attribute specified on projects in the
manifest.
All projects are implicitly labelled with "default" unless they are
explicitly labelled "-default".
Prefixing a group with "-" removes matching projects from the list
of projects to sync.
If any non-inverted manifest groups are specified, the default label
is ignored.
Change-Id: I3a0dd7a93a8a1756205de1d03eee8c00906af0e5
Reviewed-on: https://gerrit-review.googlesource.com/34570
Reviewed-by: Shawn Pearce <sop@google.com>
Tested-by: Shawn Pearce <sop@google.com>
Diffstat (limited to 'manifest_xml.py')
| -rw-r--r-- | manifest_xml.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/manifest_xml.py b/manifest_xml.py index 44538690..a250382f 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
| @@ -119,6 +119,12 @@ class XmlManifest(object): | |||
| 119 | def Save(self, fd, peg_rev=False): | 119 | def Save(self, fd, peg_rev=False): |
| 120 | """Write the current manifest out to the given file descriptor. | 120 | """Write the current manifest out to the given file descriptor. |
| 121 | """ | 121 | """ |
| 122 | mp = self.manifestProject | ||
| 123 | |||
| 124 | groups = mp.config.GetString('manifest.groups') | ||
| 125 | if groups: | ||
| 126 | groups = re.split('[,\s]+', groups) | ||
| 127 | |||
| 122 | doc = xml.dom.minidom.Document() | 128 | doc = xml.dom.minidom.Document() |
| 123 | root = doc.createElement('manifest') | 129 | root = doc.createElement('manifest') |
| 124 | doc.appendChild(root) | 130 | doc.appendChild(root) |
| @@ -167,6 +173,10 @@ class XmlManifest(object): | |||
| 167 | 173 | ||
| 168 | for p in sort_projects: | 174 | for p in sort_projects: |
| 169 | p = self.projects[p] | 175 | p = self.projects[p] |
| 176 | |||
| 177 | if not p.MatchesGroups(groups): | ||
| 178 | continue | ||
| 179 | |||
| 170 | e = doc.createElement('project') | 180 | e = doc.createElement('project') |
| 171 | root.appendChild(e) | 181 | root.appendChild(e) |
| 172 | e.setAttribute('name', p.name) | 182 | e.setAttribute('name', p.name) |
| @@ -190,6 +200,9 @@ class XmlManifest(object): | |||
| 190 | ce.setAttribute('dest', c.dest) | 200 | ce.setAttribute('dest', c.dest) |
| 191 | e.appendChild(ce) | 201 | e.appendChild(ce) |
| 192 | 202 | ||
| 203 | if p.groups: | ||
| 204 | e.setAttribute('groups', ','.join(p.groups)) | ||
| 205 | |||
| 193 | if self._repo_hooks_project: | 206 | if self._repo_hooks_project: |
| 194 | root.appendChild(doc.createTextNode('')) | 207 | root.appendChild(doc.createTextNode('')) |
| 195 | e = doc.createElement('repo-hooks') | 208 | e = doc.createElement('repo-hooks') |
| @@ -504,6 +517,12 @@ class XmlManifest(object): | |||
| 504 | else: | 517 | else: |
| 505 | rebase = rebase.lower() in ("yes", "true", "1") | 518 | rebase = rebase.lower() in ("yes", "true", "1") |
| 506 | 519 | ||
| 520 | groups = node.getAttribute('groups') | ||
| 521 | if groups: | ||
| 522 | groups = re.split('[,\s]+', groups) | ||
| 523 | else: | ||
| 524 | groups = None | ||
| 525 | |||
| 507 | if self.IsMirror: | 526 | if self.IsMirror: |
| 508 | relpath = None | 527 | relpath = None |
| 509 | worktree = None | 528 | worktree = None |
| @@ -520,7 +539,8 @@ class XmlManifest(object): | |||
| 520 | relpath = path, | 539 | relpath = path, |
| 521 | revisionExpr = revisionExpr, | 540 | revisionExpr = revisionExpr, |
| 522 | revisionId = None, | 541 | revisionId = None, |
| 523 | rebase = rebase) | 542 | rebase = rebase, |
| 543 | groups = groups) | ||
| 524 | 544 | ||
| 525 | for n in node.childNodes: | 545 | for n in node.childNodes: |
| 526 | if n.nodeName == 'copyfile': | 546 | if n.nodeName == 'copyfile': |
