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 <sop@google.com>
Tested-by: Shawn Pearce <sop@google.com>
This commit is contained in:
Colin Cross
2012-03-28 20:15:45 -07:00
committed by Shawn Pearce
parent d67872d2f4
commit 5acde75e5d
8 changed files with 108 additions and 7 deletions

View File

@@ -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':