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
diff --git a/project.py b/project.py
index e297926..2b74000 100644
--- a/project.py
+++ b/project.py
@@ -657,41 +657,21 @@
     """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".
+       All projects are implicitly labelled with "default".
+
+       labels are resolved in order.  In the example case of
+       project_groups: "default,group1,group2"
+       manifest_groups: "-group1,group2"
+       the project will be matched.
     """
-    project_groups = self.groups
-    if not manifest_groups:
-      return not project_groups or not "-default" in project_groups
+    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
 
-    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
-
-    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
+    return matched
 
 ## Status Display ##