summaryrefslogtreecommitdiffstats
path: root/manifest_xml.py
diff options
context:
space:
mode:
authorJosh Triplett <josh@joshtriplett.org>2014-06-12 14:57:29 -0700
committerJosh Triplett <josh@joshtriplett.org>2014-06-20 11:35:16 -0700
commit884a387ecae6ce0aa3739771eecfcc0cd376cf61 (patch)
treee2609db54ba18770932c3053152f7aaeb397b1ec /manifest_xml.py
parente9f75b1782dbf6ce9a8f22256316dbb66cdbab11 (diff)
downloadgit-repo-884a387ecae6ce0aa3739771eecfcc0cd376cf61.tar.gz
Add extend-project tag to support adding groups to an existing project
Currently, if a local manifest wants to add groups to an existing project, it must use remove-project and then re-add the project with the new groups. This makes the local manifest more fragile, requiring updates to the local manifest if the original manifest changes. Add a new extend-project tag, which supports adding groups to an existing project. Change-Id: Ib4d1352efd722a65dd263d02644b9ea5ab6ed400
Diffstat (limited to 'manifest_xml.py')
-rw-r--r--manifest_xml.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/manifest_xml.py b/manifest_xml.py
index fdc31778..bd1ab69b 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -164,6 +164,9 @@ class XmlManifest(object):
164 if r.revision is not None: 164 if r.revision is not None:
165 e.setAttribute('revision', r.revision) 165 e.setAttribute('revision', r.revision)
166 166
167 def _ParseGroups(self, groups):
168 return [x for x in re.split(r'[,\s]+', groups) if x]
169
167 def Save(self, fd, peg_rev=False, peg_rev_upstream=True): 170 def Save(self, fd, peg_rev=False, peg_rev_upstream=True):
168 """Write the current manifest out to the given file descriptor. 171 """Write the current manifest out to the given file descriptor.
169 """ 172 """
@@ -171,7 +174,7 @@ class XmlManifest(object):
171 174
172 groups = mp.config.GetString('manifest.groups') 175 groups = mp.config.GetString('manifest.groups')
173 if groups: 176 if groups:
174 groups = [x for x in re.split(r'[,\s]+', groups) if x] 177 groups = self._ParseGroups(groups)
175 178
176 doc = xml.dom.minidom.Document() 179 doc = xml.dom.minidom.Document()
177 root = doc.createElement('manifest') 180 root = doc.createElement('manifest')
@@ -505,6 +508,23 @@ class XmlManifest(object):
505 if node.nodeName == 'project': 508 if node.nodeName == 'project':
506 project = self._ParseProject(node) 509 project = self._ParseProject(node)
507 recursively_add_projects(project) 510 recursively_add_projects(project)
511 if node.nodeName == 'extend-project':
512 name = self._reqatt(node, 'name')
513
514 if name not in self._projects:
515 raise ManifestParseError('extend-project element specifies non-existent '
516 'project: %s' % name)
517
518 path = node.getAttribute('path')
519 groups = node.getAttribute('groups')
520 if groups:
521 groups = self._ParseGroups(groups)
522
523 for p in self._projects[name]:
524 if path and p.relpath != path:
525 continue
526 if groups:
527 p.groups.extend(groups)
508 if node.nodeName == 'repo-hooks': 528 if node.nodeName == 'repo-hooks':
509 # Get the name of the project and the (space-separated) list of enabled. 529 # Get the name of the project and the (space-separated) list of enabled.
510 repo_hooks_project = self._reqatt(node, 'in-project') 530 repo_hooks_project = self._reqatt(node, 'in-project')
@@ -745,7 +765,7 @@ class XmlManifest(object):
745 groups = '' 765 groups = ''
746 if node.hasAttribute('groups'): 766 if node.hasAttribute('groups'):
747 groups = node.getAttribute('groups') 767 groups = node.getAttribute('groups')
748 groups = [x for x in re.split(r'[,\s]+', groups) if x] 768 groups = self._ParseGroups(groups)
749 769
750 if parent is None: 770 if parent is None:
751 relpath, worktree, gitdir, objdir = self.GetProjectPaths(name, path) 771 relpath, worktree, gitdir, objdir = self.GetProjectPaths(name, path)