From 5acde75e5d70b323197ffb2c9d4fdea3612098f5 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 28 Mar 2012 20:15:45 -0700 Subject: Add manifest groups 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 Tested-by: Shawn Pearce --- manifest_xml.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'manifest_xml.py') 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): def Save(self, fd, peg_rev=False): """Write the current manifest out to the given file descriptor. """ + mp = self.manifestProject + + groups = mp.config.GetString('manifest.groups') + if groups: + groups = re.split('[,\s]+', groups) + doc = xml.dom.minidom.Document() root = doc.createElement('manifest') doc.appendChild(root) @@ -167,6 +173,10 @@ class XmlManifest(object): for p in sort_projects: p = self.projects[p] + + if not p.MatchesGroups(groups): + continue + e = doc.createElement('project') root.appendChild(e) e.setAttribute('name', p.name) @@ -190,6 +200,9 @@ class XmlManifest(object): ce.setAttribute('dest', c.dest) e.appendChild(ce) + if p.groups: + e.setAttribute('groups', ','.join(p.groups)) + if self._repo_hooks_project: root.appendChild(doc.createTextNode('')) e = doc.createElement('repo-hooks') @@ -504,6 +517,12 @@ class XmlManifest(object): else: rebase = rebase.lower() in ("yes", "true", "1") + groups = node.getAttribute('groups') + if groups: + groups = re.split('[,\s]+', groups) + else: + groups = None + if self.IsMirror: relpath = None worktree = None @@ -520,7 +539,8 @@ class XmlManifest(object): relpath = path, revisionExpr = revisionExpr, revisionId = None, - rebase = rebase) + rebase = rebase, + groups = groups) for n in node.childNodes: if n.nodeName == 'copyfile': -- cgit v1.2.3-54-g00ecf