From 971de8ea7b7e474a4d9253b6c9f47da3f1130973 Mon Sep 17 00:00:00 2001 From: Conley Owens Date: Mon, 16 Apr 2012 10:36:08 -0700 Subject: 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 --- project.py | 48 ++++++++++++++---------------------------------- 1 file changed, 14 insertions(+), 34 deletions(-) (limited to 'project.py') 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): """Returns true if the manifest groups specified at init should cause this project to be synced. Prefixing a manifest group with "-" inverts the meaning of a group. - All projects are implicitly labelled with "default" unless they are - explicitly labelled "-default". - If any non-inverted manifest groups are specified, the default label - is ignored. - Specifying only inverted groups implies "default". - """ - project_groups = self.groups - if not manifest_groups: - return not project_groups or not "-default" in project_groups - - if not project_groups: - project_groups = ["default"] - elif not ("default" in project_groups or "-default" in project_groups): - project_groups.append("default") - - plus_groups = [x for x in manifest_groups if not x.startswith("-")] - minus_groups = [x[1:] for x in manifest_groups if x.startswith("-")] - - if not plus_groups: - plus_groups.append("default") - - for group in minus_groups: - if group in project_groups: - # project was excluded by -group - return False + All projects are implicitly labelled with "default". - for group in plus_groups: - if group in project_groups: - # project was included by group - return True - - # groups were specified that did not include this project - if plus_groups: - return False - return True + labels are resolved in order. In the example case of + project_groups: "default,group1,group2" + manifest_groups: "-group1,group2" + the project will be matched. + """ + matched = False + for group in manifest_groups: + if group.startswith('-') and group[1:] in self.groups: + matched = False + elif group in self.groups: + matched = True + + return matched ## Status Display ## -- cgit v1.2.3-54-g00ecf