From bb1b5f5f863fca0e85764f5b35c117f5724d15c0 Mon Sep 17 00:00:00 2001 From: Conley Owens Date: Mon, 13 Aug 2012 13:11:18 -0700 Subject: [PATCH] Allow projects to be specified as notdefault Instead of every group being in the group "default", every project is now in the group "all". A group that should not be downloaded by default may be added to the group "notdefault". This allows all group names to be positive (instead of removing groups directly in the manifest with -default) and offers a clear way of selecting every project (--groups all). Change-Id: I99cd70309adb1f8460db3bbc6eff46bdcd22256f --- command.py | 2 +- docs/manifest-format.txt | 7 ++++--- manifest_xml.py | 4 ++-- project.py | 15 ++++++++------- subcmds/init.py | 6 +++--- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/command.py b/command.py index 4dbe2e77..5789582c 100644 --- a/command.py +++ b/command.py @@ -70,7 +70,7 @@ class Command(object): groups = mp.config.GetString('manifest.groups') if not groups: - groups = 'default,platform-' + platform.system().lower() + groups = 'all,-notdefault,platform-' + platform.system().lower() groups = [x for x in re.split('[,\s]+', groups) if x] if not args: diff --git a/docs/manifest-format.txt b/docs/manifest-format.txt index 338e0219..f499868c 100644 --- a/docs/manifest-format.txt +++ b/docs/manifest-format.txt @@ -184,11 +184,12 @@ the default element is used. Attribute `groups`: List of groups to which this project belongs, whitespace or comma separated. All projects belong to the group -"default", and each project automatically belongs to a group of -it's name:`name` and path:`path`. E.g. for +"all", and each project automatically belongs to a group of +its name:`name` and path:`path`. E.g. for , that project definition is implicitly in the following manifest groups: -default, name:monkeys, and path:barrel-of. +default, name:monkeys, and path:barrel-of. If you place a project in the +group "notdefault", it will not be automatically downloaded by repo. Element annotation ------------------ diff --git a/manifest_xml.py b/manifest_xml.py index 205e4af7..65b76379 100644 --- a/manifest_xml.py +++ b/manifest_xml.py @@ -130,7 +130,7 @@ class XmlManifest(object): groups = mp.config.GetString('manifest.groups') if not groups: - groups = 'default' + groups = 'all' groups = [x for x in re.split(r'[,\s]+', groups) if x] doc = xml.dom.minidom.Document() @@ -211,7 +211,7 @@ class XmlManifest(object): ce.setAttribute('dest', c.dest) e.appendChild(ce) - default_groups = ['default', 'name:%s' % p.name, 'path:%s' % p.relpath] + default_groups = ['all', 'name:%s' % p.name, 'path:%s' % p.relpath] egroups = [g for g in p.groups if g not in default_groups] if egroups: e.setAttribute('groups', ','.join(egroups)) diff --git a/project.py b/project.py index 06baccb5..60633b73 100644 --- a/project.py +++ b/project.py @@ -632,20 +632,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". + All projects are implicitly labelled with "all". labels are resolved in order. In the example case of - project_groups: "default,group1,group2" + project_groups: "all,group1,group2" manifest_groups: "-group1,group2" the project will be matched. """ - if self.groups is None: - return True + expanded_manifest_groups = manifest_groups or ['all', '-notdefault'] + expanded_project_groups = ['all'] + (self.groups or []) + matched = False - for group in manifest_groups: - if group.startswith('-') and group[1:] in self.groups: + for group in expanded_manifest_groups: + if group.startswith('-') and group[1:] in expanded_project_groups: matched = False - elif group in self.groups: + elif group in expanded_project_groups: matched = True return matched diff --git a/subcmds/init.py b/subcmds/init.py index b16f57c4..9a4f7118 100644 --- a/subcmds/init.py +++ b/subcmds/init.py @@ -90,12 +90,12 @@ to update the working directory files. dest='depth', help='create a shallow clone with given depth; see git clone') g.add_option('-g', '--groups', - dest='groups', default='default', + dest='groups', default='all,-notdefault', help='restrict manifest projects to ones with a specified group', metavar='GROUP') g.add_option('-p', '--platform', dest='platform', default='auto', - help='restrict manifest projects to ones with a specified' + help='restrict manifest projects to ones with a specified ' 'platform group [auto|all|none|linux|darwin|...]', metavar='PLATFORM') @@ -164,7 +164,7 @@ to update the working directory files. groups = [x for x in groups if x] groupstr = ','.join(groups) - if opt.platform == 'auto' and groupstr == 'default,platform-' + platform.system().lower(): + if opt.platform == 'auto' and groupstr == 'all,-notdefault,platform-' + platform.system().lower(): groupstr = None m.config.SetString('manifest.groups', groupstr)