summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
authorConley Owens <cco3@android.com>2012-04-16 10:36:08 -0700
committerShawn O. Pearce <sop@google.com>2012-04-23 12:39:05 -0700
commit971de8ea7b7e474a4d9253b6c9f47da3f1130973 (patch)
treed8ac52741957b38d57d15f208e57b984d71ddc19 /project.py
parent24c130884018364f91baa8de0ff3541f4c32d1bb (diff)
downloadgit-repo-971de8ea7b7e474a4d9253b6c9f47da3f1130973.tar.gz
Refine groups functionality
Every project is in group "default". "-default" does not remove it from this project. All group names specified in the manifest are positive names as opposed to a mix of negative and positive. Specified groups are resolved in order. If init is supplied with --groups="group1,-group2", the following describes the project selection when syncing: * all projects in "group1" will be added, and * all projects in "group2" will be removed. Change-Id: I1df3dcdb64bbd4cd80d675f9b2d3becbf721f661
Diffstat (limited to 'project.py')
-rw-r--r--project.py48
1 files changed, 14 insertions, 34 deletions
diff --git a/project.py b/project.py
index e297926d..2b740007 100644
--- a/project.py
+++ b/project.py
@@ -657,41 +657,21 @@ class Project(object):
657 """Returns true if the manifest groups specified at init should cause 657 """Returns true if the manifest groups specified at init should cause
658 this project to be synced. 658 this project to be synced.
659 Prefixing a manifest group with "-" inverts the meaning of a group. 659 Prefixing a manifest group with "-" inverts the meaning of a group.
660 All projects are implicitly labelled with "default" unless they are 660 All projects are implicitly labelled with "default".
661 explicitly labelled "-default".
662 If any non-inverted manifest groups are specified, the default label
663 is ignored.
664 Specifying only inverted groups implies "default".
665 """
666 project_groups = self.groups
667 if not manifest_groups:
668 return not project_groups or not "-default" in project_groups
669
670 if not project_groups:
671 project_groups = ["default"]
672 elif not ("default" in project_groups or "-default" in project_groups):
673 project_groups.append("default")
674
675 plus_groups = [x for x in manifest_groups if not x.startswith("-")]
676 minus_groups = [x[1:] for x in manifest_groups if x.startswith("-")]
677
678 if not plus_groups:
679 plus_groups.append("default")
680
681 for group in minus_groups:
682 if group in project_groups:
683 # project was excluded by -group
684 return False
685 661
686 for group in plus_groups: 662 labels are resolved in order. In the example case of
687 if group in project_groups: 663 project_groups: "default,group1,group2"
688 # project was included by group 664 manifest_groups: "-group1,group2"
689 return True 665 the project will be matched.
690 666 """
691 # groups were specified that did not include this project 667 matched = False
692 if plus_groups: 668 for group in manifest_groups:
693 return False 669 if group.startswith('-') and group[1:] in self.groups:
694 return True 670 matched = False
671 elif group in self.groups:
672 matched = True
673
674 return matched
695 675
696## Status Display ## 676## Status Display ##
697 677