mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
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:
parent
e2126652a3
commit
bb1b5f5f86
@ -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:
|
||||
|
@ -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
|
||||
<project name="monkeys" path="barrel-of"/>, 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
|
||||
------------------
|
||||
|
@ -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))
|
||||
|
15
project.py
15
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
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user