summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2012-03-28 20:15:45 -0700
committerShawn Pearce <sop@google.com>2012-04-13 09:46:00 -0700
commit5acde75e5d70b323197ffb2c9d4fdea3612098f5 (patch)
treee995a64614ce7406633ae6e99c2a0e6f86872e09 /project.py
parentd67872d2f47b2f09a0e2aa4adfd62e6f69154c9b (diff)
downloadgit-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 'project.py')
-rw-r--r--project.py46
1 files changed, 44 insertions, 2 deletions
diff --git a/project.py b/project.py
index 303abe33..b2eaa878 100644
--- a/project.py
+++ b/project.py
@@ -504,7 +504,8 @@ class Project(object):
504 relpath, 504 relpath,
505 revisionExpr, 505 revisionExpr,
506 revisionId, 506 revisionId,
507 rebase = True): 507 rebase = True,
508 groups = None):
508 self.manifest = manifest 509 self.manifest = manifest
509 self.name = name 510 self.name = name
510 self.remote = remote 511 self.remote = remote
@@ -524,6 +525,7 @@ class Project(object):
524 self.revisionId = revisionId 525 self.revisionId = revisionId
525 526
526 self.rebase = rebase 527 self.rebase = rebase
528 self.groups = groups
527 529
528 self.snapshots = {} 530 self.snapshots = {}
529 self.copyfiles = [] 531 self.copyfiles = []
@@ -645,6 +647,45 @@ class Project(object):
645 647
646 return heads 648 return heads
647 649
650 def MatchesGroups(self, manifest_groups):
651 """Returns true if the manifest groups specified at init should cause
652 this project to be synced.
653 Prefixing a manifest group with "-" inverts the meaning of a group.
654 All projects are implicitly labelled with "default" unless they are
655 explicitly labelled "-default".
656 If any non-inverted manifest groups are specified, the default label
657 is ignored.
658 Specifying only inverted groups implies "default".
659 """
660 project_groups = self.groups
661 if not manifest_groups:
662 return not project_groups or not "-default" in project_groups
663
664 if not project_groups:
665 project_groups = ["default"]
666 elif not ("default" in project_groups or "-default" in project_groups):
667 project_groups.append("default")
668
669 plus_groups = [x for x in manifest_groups if not x.startswith("-")]
670 minus_groups = [x[1:] for x in manifest_groups if x.startswith("-")]
671
672 if not plus_groups:
673 plus_groups.append("default")
674
675 for group in minus_groups:
676 if group in project_groups:
677 # project was excluded by -group
678 return False
679
680 for group in plus_groups:
681 if group in project_groups:
682 # project was included by group
683 return True
684
685 # groups were specified that did not include this project
686 if plus_groups:
687 return False
688 return True
648 689
649## Status Display ## 690## Status Display ##
650 691
@@ -2091,7 +2132,8 @@ class MetaProject(Project):
2091 remote = RemoteSpec('origin'), 2132 remote = RemoteSpec('origin'),
2092 relpath = '.repo/%s' % name, 2133 relpath = '.repo/%s' % name,
2093 revisionExpr = 'refs/heads/master', 2134 revisionExpr = 'refs/heads/master',
2094 revisionId = None) 2135 revisionId = None,
2136 groups = None)
2095 2137
2096 def PreSync(self): 2138 def PreSync(self):
2097 if self.Exists: 2139 if self.Exists: