diff options
| -rw-r--r-- | command.py | 7 | ||||
| -rw-r--r-- | docs/manifest-format.txt | 4 | ||||
| -rw-r--r-- | manifest_xml.py | 21 | ||||
| -rw-r--r-- | project.py | 48 | ||||
| -rwxr-xr-x | repo | 4 | ||||
| -rw-r--r-- | subcmds/init.py | 10 |
6 files changed, 42 insertions, 52 deletions
| @@ -58,7 +58,7 @@ class Command(object): | |||
| 58 | """Perform the action, after option parsing is complete. | 58 | """Perform the action, after option parsing is complete. |
| 59 | """ | 59 | """ |
| 60 | raise NotImplementedError | 60 | raise NotImplementedError |
| 61 | 61 | ||
| 62 | def GetProjects(self, args, missing_ok=False): | 62 | def GetProjects(self, args, missing_ok=False): |
| 63 | """A list of projects that match the arguments. | 63 | """A list of projects that match the arguments. |
| 64 | """ | 64 | """ |
| @@ -68,8 +68,9 @@ class Command(object): | |||
| 68 | mp = self.manifest.manifestProject | 68 | mp = self.manifest.manifestProject |
| 69 | 69 | ||
| 70 | groups = mp.config.GetString('manifest.groups') | 70 | groups = mp.config.GetString('manifest.groups') |
| 71 | if groups: | 71 | if groups is None: |
| 72 | groups = re.split('[,\s]+', groups) | 72 | groups = 'default' |
| 73 | groups = [x for x in re.split('[,\s]+', groups) if x] | ||
| 73 | 74 | ||
| 74 | if not args: | 75 | if not args: |
| 75 | for project in all.values(): | 76 | for project in all.values(): |
diff --git a/docs/manifest-format.txt b/docs/manifest-format.txt index e5f5ee18..764e41eb 100644 --- a/docs/manifest-format.txt +++ b/docs/manifest-format.txt | |||
| @@ -165,8 +165,8 @@ been extensively tested. If not supplied the revision given by | |||
| 165 | the default element is used. | 165 | the default element is used. |
| 166 | 166 | ||
| 167 | Attribute `groups`: List of groups to which this project belongs, | 167 | Attribute `groups`: List of groups to which this project belongs, |
| 168 | whitespace or comma separated. All projects are part of the group | 168 | whitespace or comma separated. All projects belong to the group |
| 169 | "default" unless "-default" is specified in the list of groups. | 169 | "default". |
| 170 | 170 | ||
| 171 | Element annotation | 171 | Element annotation |
| 172 | ------------------ | 172 | ------------------ |
diff --git a/manifest_xml.py b/manifest_xml.py index 9b804da9..5ffc49e9 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
| @@ -122,8 +122,9 @@ class XmlManifest(object): | |||
| 122 | mp = self.manifestProject | 122 | mp = self.manifestProject |
| 123 | 123 | ||
| 124 | groups = mp.config.GetString('manifest.groups') | 124 | groups = mp.config.GetString('manifest.groups') |
| 125 | if groups: | 125 | if groups is None: |
| 126 | groups = re.split('[,\s]+', groups) | 126 | groups = 'default' |
| 127 | groups = [x for x in re.split(r'[,\s]+', groups) if x] | ||
| 127 | 128 | ||
| 128 | doc = xml.dom.minidom.Document() | 129 | doc = xml.dom.minidom.Document() |
| 129 | root = doc.createElement('manifest') | 130 | root = doc.createElement('manifest') |
| @@ -200,8 +201,9 @@ class XmlManifest(object): | |||
| 200 | ce.setAttribute('dest', c.dest) | 201 | ce.setAttribute('dest', c.dest) |
| 201 | e.appendChild(ce) | 202 | e.appendChild(ce) |
| 202 | 203 | ||
| 203 | if p.groups: | 204 | egroups = [g for g in p.groups if g != 'default'] |
| 204 | e.setAttribute('groups', ','.join(p.groups)) | 205 | if egroups: |
| 206 | e.setAttribute('groups', ','.join(egroups)) | ||
| 205 | 207 | ||
| 206 | for a in p.annotations: | 208 | for a in p.annotations: |
| 207 | if a.keep == "true": | 209 | if a.keep == "true": |
| @@ -524,11 +526,12 @@ class XmlManifest(object): | |||
| 524 | else: | 526 | else: |
| 525 | rebase = rebase.lower() in ("yes", "true", "1") | 527 | rebase = rebase.lower() in ("yes", "true", "1") |
| 526 | 528 | ||
| 527 | groups = node.getAttribute('groups') | 529 | groups = '' |
| 528 | if groups: | 530 | if node.hasAttribute('groups'): |
| 529 | groups = re.split('[,\s]+', groups) | 531 | groups = node.getAttribute('groups') |
| 530 | else: | 532 | groups = [x for x in re.split('[,\s]+', groups) if x] |
| 531 | groups = None | 533 | if 'default' not in groups: |
| 534 | groups.append('default') | ||
| 532 | 535 | ||
| 533 | if self.IsMirror: | 536 | if self.IsMirror: |
| 534 | relpath = None | 537 | relpath = None |
| @@ -657,41 +657,21 @@ class Project(object): | |||
| 657 | """Returns true if the manifest groups specified at init should cause | 657 | """Returns true if the manifest groups specified at init should cause |
| 658 | this project to be synced. | 658 | this project to be synced. |
| 659 | Prefixing a manifest group with "-" inverts the meaning of a group. | 659 | Prefixing a manifest group with "-" inverts the meaning of a group. |
| 660 | All projects are implicitly labelled with "default" unless they are | 660 | All projects are implicitly labelled with "default". |
| 661 | explicitly labelled "-default". | ||
| 662 | If any non-inverted manifest groups are specified, the default label | ||
| 663 | is ignored. | ||
| 664 | Specifying only inverted groups implies "default". | ||
| 665 | """ | ||
| 666 | project_groups = self.groups | ||
| 667 | if not manifest_groups: | ||
| 668 | return not project_groups or not "-default" in project_groups | ||
| 669 | |||
| 670 | if not project_groups: | ||
| 671 | project_groups = ["default"] | ||
| 672 | elif not ("default" in project_groups or "-default" in project_groups): | ||
| 673 | project_groups.append("default") | ||
| 674 | |||
| 675 | plus_groups = [x for x in manifest_groups if not x.startswith("-")] | ||
| 676 | minus_groups = [x[1:] for x in manifest_groups if x.startswith("-")] | ||
| 677 | |||
| 678 | if not plus_groups: | ||
| 679 | plus_groups.append("default") | ||
| 680 | |||
| 681 | for group in minus_groups: | ||
| 682 | if group in project_groups: | ||
| 683 | # project was excluded by -group | ||
| 684 | return False | ||
| 685 | 661 | ||
| 686 | for group in plus_groups: | 662 | labels are resolved in order. In the example case of |
| 687 | if group in project_groups: | 663 | project_groups: "default,group1,group2" |
| 688 | # project was included by group | 664 | manifest_groups: "-group1,group2" |
| 689 | return True | 665 | the project will be matched. |
| 690 | 666 | """ | |
| 691 | # groups were specified that did not include this project | 667 | matched = False |
| 692 | if plus_groups: | 668 | for group in manifest_groups: |
| 693 | return False | 669 | if group.startswith('-') and group[1:] in self.groups: |
| 694 | return True | 670 | matched = False |
| 671 | elif group in self.groups: | ||
| 672 | matched = True | ||
| 673 | |||
| 674 | return matched | ||
| 695 | 675 | ||
| 696 | ## Status Display ## | 676 | ## Status Display ## |
| 697 | 677 | ||
| @@ -28,7 +28,7 @@ if __name__ == '__main__': | |||
| 28 | del magic | 28 | del magic |
| 29 | 29 | ||
| 30 | # increment this whenever we make important changes to this script | 30 | # increment this whenever we make important changes to this script |
| 31 | VERSION = (1, 15) | 31 | VERSION = (1, 16) |
| 32 | 32 | ||
| 33 | # increment this if the MAINTAINER_KEYS block is modified | 33 | # increment this if the MAINTAINER_KEYS block is modified |
| 34 | KEYRING_VERSION = (1,0) | 34 | KEYRING_VERSION = (1,0) |
| @@ -126,7 +126,7 @@ group.add_option('--depth', type='int', default=None, | |||
| 126 | dest='depth', | 126 | dest='depth', |
| 127 | help='create a shallow clone with given depth; see git clone') | 127 | help='create a shallow clone with given depth; see git clone') |
| 128 | group.add_option('-g', '--groups', | 128 | group.add_option('-g', '--groups', |
| 129 | dest='groups', default="", | 129 | dest='groups', default='default', |
| 130 | help='restrict manifest projects to ones with a specified group', | 130 | help='restrict manifest projects to ones with a specified group', |
| 131 | metavar='GROUP') | 131 | metavar='GROUP') |
| 132 | 132 | ||
diff --git a/subcmds/init.py b/subcmds/init.py index 6cf39d14..d1c497c1 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | # limitations under the License. | 14 | # limitations under the License. |
| 15 | 15 | ||
| 16 | import os | 16 | import os |
| 17 | import re | ||
| 17 | import shutil | 18 | import shutil |
| 18 | import sys | 19 | import sys |
| 19 | 20 | ||
| @@ -87,7 +88,7 @@ to update the working directory files. | |||
| 87 | dest='depth', | 88 | dest='depth', |
| 88 | help='create a shallow clone with given depth; see git clone') | 89 | help='create a shallow clone with given depth; see git clone') |
| 89 | g.add_option('-g', '--groups', | 90 | g.add_option('-g', '--groups', |
| 90 | dest='groups', default="", | 91 | dest='groups', default='default', |
| 91 | help='restrict manifest projects to ones with a specified group', | 92 | help='restrict manifest projects to ones with a specified group', |
| 92 | metavar='GROUP') | 93 | metavar='GROUP') |
| 93 | 94 | ||
| @@ -139,7 +140,12 @@ to update the working directory files. | |||
| 139 | r.ResetFetch() | 140 | r.ResetFetch() |
| 140 | r.Save() | 141 | r.Save() |
| 141 | 142 | ||
| 142 | m.config.SetString('manifest.groups', opt.groups) | 143 | groups = re.split('[,\s]+', opt.groups) |
| 144 | groups = [x for x in groups if x] | ||
| 145 | groupstr = ','.join(groups) | ||
| 146 | if groupstr == 'default': | ||
| 147 | groupstr = None | ||
| 148 | m.config.SetString('manifest.groups', groupstr) | ||
| 143 | 149 | ||
| 144 | if opt.reference: | 150 | if opt.reference: |
| 145 | m.config.SetString('repo.reference', opt.reference) | 151 | m.config.SetString('repo.reference', opt.reference) |
