diff options
Diffstat (limited to 'manifest_xml.py')
-rw-r--r-- | manifest_xml.py | 41 |
1 files changed, 31 insertions, 10 deletions
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': |