diff options
| -rw-r--r-- | docs/manifest-format.md | 4 | ||||
| -rw-r--r-- | manifest_xml.py | 41 | ||||
| -rw-r--r-- | project.py | 5 | ||||
| -rw-r--r-- | subcmds/info.py | 3 |
4 files changed, 39 insertions, 14 deletions
diff --git a/docs/manifest-format.md b/docs/manifest-format.md index 6e671080..0d26296d 100644 --- a/docs/manifest-format.md +++ b/docs/manifest-format.md | |||
| @@ -66,6 +66,7 @@ following DTD: | |||
| 66 | <!ATTLIST submanifest revision CDATA #IMPLIED> | 66 | <!ATTLIST submanifest revision CDATA #IMPLIED> |
| 67 | <!ATTLIST submanifest path CDATA #IMPLIED> | 67 | <!ATTLIST submanifest path CDATA #IMPLIED> |
| 68 | <!ATTLIST submanifest groups CDATA #IMPLIED> | 68 | <!ATTLIST submanifest groups CDATA #IMPLIED> |
| 69 | <!ATTLIST submanifest default-groups CDATA #IMPLIED> | ||
| 69 | 70 | ||
| 70 | <!ELEMENT project (annotation*, | 71 | <!ELEMENT project (annotation*, |
| 71 | project*, | 72 | project*, |
| @@ -302,6 +303,9 @@ in the included submanifest belong. This appends and recurses, meaning | |||
| 302 | all projects in submanifests carry all parent submanifest groups. | 303 | all projects in submanifests carry all parent submanifest groups. |
| 303 | Same syntax as the corresponding element of `project`. | 304 | Same syntax as the corresponding element of `project`. |
| 304 | 305 | ||
| 306 | Attribute `default-groups`: The list of manifest groups to sync if no | ||
| 307 | `--groups=` parameter was specified at init. When that list is empty, use this | ||
| 308 | list instead of "default" as the list of groups to sync. | ||
| 305 | 309 | ||
| 306 | ### Element project | 310 | ### Element project |
| 307 | 311 | ||
diff --git a/manifest_xml.py b/manifest_xml.py index dbab974b..3c43295e 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
| @@ -214,6 +214,7 @@ class _XmlSubmanifest: | |||
| 214 | revision: a string, the commitish. | 214 | revision: a string, the commitish. |
| 215 | manifestName: a string, the submanifest file name. | 215 | manifestName: a string, the submanifest file name. |
| 216 | groups: a list of strings, the groups to add to all projects in the submanifest. | 216 | groups: a list of strings, the groups to add to all projects in the submanifest. |
| 217 | default_groups: a list of strings, the default groups to sync. | ||
| 217 | path: a string, the relative path for the submanifest checkout. | 218 | path: a string, the relative path for the submanifest checkout. |
| 218 | parent: an XmlManifest, the parent manifest. | 219 | parent: an XmlManifest, the parent manifest. |
| 219 | annotations: (derived) a list of annotations. | 220 | annotations: (derived) a list of annotations. |
| @@ -226,6 +227,7 @@ class _XmlSubmanifest: | |||
| 226 | revision=None, | 227 | revision=None, |
| 227 | manifestName=None, | 228 | manifestName=None, |
| 228 | groups=None, | 229 | groups=None, |
| 230 | default_groups=None, | ||
| 229 | path=None, | 231 | path=None, |
| 230 | parent=None): | 232 | parent=None): |
| 231 | self.name = name | 233 | self.name = name |
| @@ -234,6 +236,7 @@ class _XmlSubmanifest: | |||
| 234 | self.revision = revision | 236 | self.revision = revision |
| 235 | self.manifestName = manifestName | 237 | self.manifestName = manifestName |
| 236 | self.groups = groups | 238 | self.groups = groups |
| 239 | self.default_groups = default_groups | ||
| 237 | self.path = path | 240 | self.path = path |
| 238 | self.parent = parent | 241 | self.parent = parent |
| 239 | self.annotations = [] | 242 | self.annotations = [] |
| @@ -250,7 +253,8 @@ class _XmlSubmanifest: | |||
| 250 | os.path.join(parent.path_prefix, self.relpath), MANIFEST_FILE_NAME) | 253 | os.path.join(parent.path_prefix, self.relpath), MANIFEST_FILE_NAME) |
| 251 | rc = self.repo_client = RepoClient( | 254 | rc = self.repo_client = RepoClient( |
| 252 | parent.repodir, linkFile, parent_groups=','.join(groups) or '', | 255 | parent.repodir, linkFile, parent_groups=','.join(groups) or '', |
| 253 | submanifest_path=self.relpath, outer_client=outer_client) | 256 | submanifest_path=self.relpath, outer_client=outer_client, |
| 257 | default_groups=default_groups) | ||
| 254 | 258 | ||
| 255 | self.present = os.path.exists(manifestFile) | 259 | self.present = os.path.exists(manifestFile) |
| 256 | 260 | ||
| @@ -264,6 +268,7 @@ class _XmlSubmanifest: | |||
| 264 | self.revision == other.revision and | 268 | self.revision == other.revision and |
| 265 | self.manifestName == other.manifestName and | 269 | self.manifestName == other.manifestName and |
| 266 | self.groups == other.groups and | 270 | self.groups == other.groups and |
| 271 | self.default_groups == other.default_groups and | ||
| 267 | self.path == other.path and | 272 | self.path == other.path and |
| 268 | sorted(self.annotations) == sorted(other.annotations)) | 273 | sorted(self.annotations) == sorted(other.annotations)) |
| 269 | 274 | ||
| @@ -284,6 +289,7 @@ class _XmlSubmanifest: | |||
| 284 | revision = self.revision or self.name | 289 | revision = self.revision or self.name |
| 285 | path = self.path or revision.split('/')[-1] | 290 | path = self.path or revision.split('/')[-1] |
| 286 | groups = self.groups or [] | 291 | groups = self.groups or [] |
| 292 | default_groups = self.default_groups or [] | ||
| 287 | 293 | ||
| 288 | return SubmanifestSpec(self.name, manifestUrl, manifestName, revision, path, | 294 | return SubmanifestSpec(self.name, manifestUrl, manifestName, revision, path, |
| 289 | groups) | 295 | groups) |
| @@ -300,6 +306,10 @@ class _XmlSubmanifest: | |||
| 300 | return ','.join(self.groups) | 306 | return ','.join(self.groups) |
| 301 | return '' | 307 | return '' |
| 302 | 308 | ||
| 309 | def GetDefaultGroupsStr(self): | ||
| 310 | """Returns the `default-groups` given for this submanifest.""" | ||
| 311 | return ','.join(self.default_groups or []) | ||
| 312 | |||
| 303 | def AddAnnotation(self, name, value, keep): | 313 | def AddAnnotation(self, name, value, keep): |
| 304 | """Add annotations to the submanifest.""" | 314 | """Add annotations to the submanifest.""" |
| 305 | self.annotations.append(Annotation(name, value, keep)) | 315 | self.annotations.append(Annotation(name, value, keep)) |
| @@ -327,7 +337,8 @@ class XmlManifest(object): | |||
| 327 | """manages the repo configuration file""" | 337 | """manages the repo configuration file""" |
| 328 | 338 | ||
| 329 | def __init__(self, repodir, manifest_file, local_manifests=None, | 339 | def __init__(self, repodir, manifest_file, local_manifests=None, |
| 330 | outer_client=None, parent_groups='', submanifest_path=''): | 340 | outer_client=None, parent_groups='', submanifest_path='', |
| 341 | default_groups=None): | ||
| 331 | """Initialize. | 342 | """Initialize. |
| 332 | 343 | ||
| 333 | Args: | 344 | Args: |
| @@ -340,6 +351,7 @@ class XmlManifest(object): | |||
| 340 | outer_client: RepoClient of the outertree. | 351 | outer_client: RepoClient of the outertree. |
| 341 | parent_groups: a string, the groups to apply to this projects. | 352 | parent_groups: a string, the groups to apply to this projects. |
| 342 | submanifest_path: The submanifest root relative to the repo root. | 353 | submanifest_path: The submanifest root relative to the repo root. |
| 354 | default_groups: a string, the default manifest groups to use. | ||
| 343 | """ | 355 | """ |
| 344 | # TODO(vapier): Move this out of this class. | 356 | # TODO(vapier): Move this out of this class. |
| 345 | self.globalConfig = GitConfig.ForUser() | 357 | self.globalConfig = GitConfig.ForUser() |
| @@ -358,6 +370,7 @@ class XmlManifest(object): | |||
| 358 | self.local_manifests = local_manifests | 370 | self.local_manifests = local_manifests |
| 359 | self._load_local_manifests = True | 371 | self._load_local_manifests = True |
| 360 | self.parent_groups = parent_groups | 372 | self.parent_groups = parent_groups |
| 373 | self.default_groups = default_groups | ||
| 361 | 374 | ||
| 362 | if outer_client and self.isGitcClient: | 375 | if outer_client and self.isGitcClient: |
| 363 | raise ManifestParseError('Multi-manifest is incompatible with `gitc-init`') | 376 | raise ManifestParseError('Multi-manifest is incompatible with `gitc-init`') |
| @@ -472,6 +485,8 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
| 472 | e.setAttribute('path', r.path) | 485 | e.setAttribute('path', r.path) |
| 473 | if r.groups: | 486 | if r.groups: |
| 474 | e.setAttribute('groups', r.GetGroupsStr()) | 487 | e.setAttribute('groups', r.GetGroupsStr()) |
| 488 | if r.default_groups: | ||
| 489 | e.setAttribute('default-groups', r.GetDefaultGroupsStr()) | ||
| 475 | 490 | ||
| 476 | for a in r.annotations: | 491 | for a in r.annotations: |
| 477 | if a.keep == 'true': | 492 | if a.keep == 'true': |
| @@ -967,16 +982,21 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
| 967 | worktree=os.path.join(subdir, 'manifests')) | 982 | worktree=os.path.join(subdir, 'manifests')) |
| 968 | return mp | 983 | return mp |
| 969 | 984 | ||
| 970 | def GetDefaultGroupsStr(self): | 985 | def GetDefaultGroupsStr(self, with_platform=True): |
| 971 | """Returns the default group string for the platform.""" | 986 | """Returns the default group string to use. |
| 972 | return 'default,platform-' + platform.system().lower() | 987 | |
| 988 | Args: | ||
| 989 | with_platform: a boolean, whether to include the group for the | ||
| 990 | underlying platform. | ||
| 991 | """ | ||
| 992 | groups = ','.join(self.default_groups or ['default']) | ||
| 993 | if with_platform: | ||
| 994 | groups += f',platform-{platform.system().lower()}' | ||
| 995 | return groups | ||
| 973 | 996 | ||
| 974 | def GetGroupsStr(self): | 997 | def GetGroupsStr(self): |
| 975 | """Returns the manifest group string that should be synced.""" | 998 | """Returns the manifest group string that should be synced.""" |
| 976 | groups = self.manifestProject.manifest_groups | 999 | return self.manifestProject.manifest_groups or self.GetDefaultGroupsStr() |
| 977 | if not groups: | ||
| 978 | groups = self.GetDefaultGroupsStr() | ||
| 979 | return groups | ||
| 980 | 1000 | ||
| 981 | def Unload(self): | 1001 | def Unload(self): |
| 982 | """Unload the manifest. | 1002 | """Unload the manifest. |
| @@ -1491,6 +1511,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
| 1491 | if node.hasAttribute('groups'): | 1511 | if node.hasAttribute('groups'): |
| 1492 | groups = node.getAttribute('groups') | 1512 | groups = node.getAttribute('groups') |
| 1493 | groups = self._ParseList(groups) | 1513 | groups = self._ParseList(groups) |
| 1514 | default_groups = self._ParseList(node.getAttribute('default-groups')) | ||
| 1494 | path = node.getAttribute('path') | 1515 | path = node.getAttribute('path') |
| 1495 | if path == '': | 1516 | if path == '': |
| 1496 | path = None | 1517 | path = None |
| @@ -1511,7 +1532,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
| 1511 | '<submanifest> invalid "path": %s: %s' % (path, msg)) | 1532 | '<submanifest> invalid "path": %s: %s' % (path, msg)) |
| 1512 | 1533 | ||
| 1513 | submanifest = _XmlSubmanifest(name, remote, project, revision, manifestName, | 1534 | submanifest = _XmlSubmanifest(name, remote, project, revision, manifestName, |
| 1514 | groups, path, self) | 1535 | groups, default_groups, path, self) |
| 1515 | 1536 | ||
| 1516 | for n in node.childNodes: | 1537 | for n in node.childNodes: |
| 1517 | if n.nodeName == 'annotation': | 1538 | if n.nodeName == 'annotation': |
| @@ -715,7 +715,8 @@ class Project(object): | |||
| 715 | The special manifest group "default" will match any project that | 715 | The special manifest group "default" will match any project that |
| 716 | does not have the special project group "notdefault" | 716 | does not have the special project group "notdefault" |
| 717 | """ | 717 | """ |
| 718 | expanded_manifest_groups = manifest_groups or ['default'] | 718 | default_groups = self.manifest.default_groups or ['default'] |
| 719 | expanded_manifest_groups = manifest_groups or default_groups | ||
| 719 | expanded_project_groups = ['all'] + (self.groups or []) | 720 | expanded_project_groups = ['all'] + (self.groups or []) |
| 720 | if 'notdefault' not in expanded_project_groups: | 721 | if 'notdefault' not in expanded_project_groups: |
| 721 | expanded_project_groups += ['default'] | 722 | expanded_project_groups += ['default'] |
| @@ -3496,7 +3497,7 @@ class ManifestProject(MetaProject): | |||
| 3496 | """ | 3497 | """ |
| 3497 | assert _kwargs_only == (), 'Sync only accepts keyword arguments.' | 3498 | assert _kwargs_only == (), 'Sync only accepts keyword arguments.' |
| 3498 | 3499 | ||
| 3499 | groups = groups or 'default' | 3500 | groups = groups or self.manifest.GetDefaultGroupsStr(with_platform=False) |
| 3500 | platform = platform or 'auto' | 3501 | platform = platform or 'auto' |
| 3501 | git_event_log = git_event_log or EventLog() | 3502 | git_event_log = git_event_log or EventLog() |
| 3502 | if outer_manifest and self.manifest.is_submanifest: | 3503 | if outer_manifest and self.manifest.is_submanifest: |
diff --git a/subcmds/info.py b/subcmds/info.py index 4bedf9d5..baa4c5b1 100644 --- a/subcmds/info.py +++ b/subcmds/info.py | |||
| @@ -65,8 +65,7 @@ class Info(PagedCommand): | |||
| 65 | self.manifest = self.manifest.outer_client | 65 | self.manifest = self.manifest.outer_client |
| 66 | manifestConfig = self.manifest.manifestProject.config | 66 | manifestConfig = self.manifest.manifestProject.config |
| 67 | mergeBranch = manifestConfig.GetBranch("default").merge | 67 | mergeBranch = manifestConfig.GetBranch("default").merge |
| 68 | manifestGroups = (manifestConfig.GetString('manifest.groups') | 68 | manifestGroups = self.manifest.GetGroupsStr() |
| 69 | or 'all,-notdefault') | ||
| 70 | 69 | ||
| 71 | self.heading("Manifest branch: ") | 70 | self.heading("Manifest branch: ") |
| 72 | if self.manifest.default.revisionExpr: | 71 | if self.manifest.default.revisionExpr: |
