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
This commit is contained in:
Conley Owens 2012-08-13 13:11:18 -07:00 committed by gerrit code review
parent e2126652a3
commit bb1b5f5f86
5 changed files with 18 additions and 16 deletions

View File

@ -70,7 +70,7 @@ class Command(object):
groups = mp.config.GetString('manifest.groups') groups = mp.config.GetString('manifest.groups')
if not 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] groups = [x for x in re.split('[,\s]+', groups) if x]
if not args: if not args:

View File

@ -184,11 +184,12 @@ the default element is used.
Attribute `groups`: List of groups to which this project belongs, Attribute `groups`: List of groups to which this project belongs,
whitespace or comma separated. All projects belong to the group whitespace or comma separated. All projects belong to the group
"default", and each project automatically belongs to a group of "all", and each project automatically belongs to a group of
it's name:`name` and path:`path`. E.g. for its name:`name` and path:`path`. E.g. for
<project name="monkeys" path="barrel-of"/>, that project <project name="monkeys" path="barrel-of"/>, that project
definition is implicitly in the following manifest groups: 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 Element annotation
------------------ ------------------

View File

@ -130,7 +130,7 @@ class XmlManifest(object):
groups = mp.config.GetString('manifest.groups') groups = mp.config.GetString('manifest.groups')
if not groups: if not groups:
groups = 'default' groups = 'all'
groups = [x for x in re.split(r'[,\s]+', groups) if x] groups = [x for x in re.split(r'[,\s]+', groups) if x]
doc = xml.dom.minidom.Document() doc = xml.dom.minidom.Document()
@ -211,7 +211,7 @@ class XmlManifest(object):
ce.setAttribute('dest', c.dest) ce.setAttribute('dest', c.dest)
e.appendChild(ce) 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] egroups = [g for g in p.groups if g not in default_groups]
if egroups: if egroups:
e.setAttribute('groups', ','.join(egroups)) e.setAttribute('groups', ','.join(egroups))

View File

@ -632,20 +632,21 @@ class Project(object):
"""Returns true if the manifest groups specified at init should cause """Returns true if the manifest groups specified at init should cause
this project to be synced. this project to be synced.
Prefixing a manifest group with "-" inverts the meaning of a group. 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 labels are resolved in order. In the example case of
project_groups: "default,group1,group2" project_groups: "all,group1,group2"
manifest_groups: "-group1,group2" manifest_groups: "-group1,group2"
the project will be matched. the project will be matched.
""" """
if self.groups is None: expanded_manifest_groups = manifest_groups or ['all', '-notdefault']
return True expanded_project_groups = ['all'] + (self.groups or [])
matched = False matched = False
for group in manifest_groups: for group in expanded_manifest_groups:
if group.startswith('-') and group[1:] in self.groups: if group.startswith('-') and group[1:] in expanded_project_groups:
matched = False matched = False
elif group in self.groups: elif group in expanded_project_groups:
matched = True matched = True
return matched return matched

View File

@ -90,12 +90,12 @@ to update the working directory files.
dest='depth', dest='depth',
help='create a shallow clone with given depth; see git clone') help='create a shallow clone with given depth; see git clone')
g.add_option('-g', '--groups', g.add_option('-g', '--groups',
dest='groups', default='default', dest='groups', default='all,-notdefault',
help='restrict manifest projects to ones with a specified group', help='restrict manifest projects to ones with a specified group',
metavar='GROUP') metavar='GROUP')
g.add_option('-p', '--platform', g.add_option('-p', '--platform',
dest='platform', default='auto', 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|...]', 'platform group [auto|all|none|linux|darwin|...]',
metavar='PLATFORM') metavar='PLATFORM')
@ -164,7 +164,7 @@ to update the working directory files.
groups = [x for x in groups if x] groups = [x for x in groups if x]
groupstr = ','.join(groups) 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 groupstr = None
m.config.SetString('manifest.groups', groupstr) m.config.SetString('manifest.groups', groupstr)