blob: 14b03a309cb36554d97effb63b687a9d787c7869 [file] [log] [blame]
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -07001# Copyright (C) 2008 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
Raman Tenneti993af5e2021-05-12 12:00:31 -070015import collections
Colin Cross23acdd32012-04-21 00:33:54 -070016import itertools
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070017import os
Raman Tenneti080877e2021-03-09 15:19:06 -080018import platform
Conley Owensdb728cd2011-09-26 16:34:01 -070019import re
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070020import sys
David Pursehouse59bbb582013-05-17 10:49:33 +090021import xml.dom.minidom
Mike Frysingeracf63b22019-06-13 02:24:21 -040022import urllib.parse
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070023
Simran Basib9a1b732015-08-20 12:19:28 -070024import gitc_utils
Daniel Kutik035f22a2022-12-13 12:34:23 +010025from git_config import GitConfig
David Pursehousee00aa6b2012-09-11 14:33:51 +090026from git_refs import R_HEADS, HEAD
LaMont Jonesd56e2eb2022-04-07 18:14:46 +000027from git_superproject import Superproject
Renaud Paquayd5cec5e2016-11-01 11:24:03 -070028import platform_utils
Gavin Makea2e3302023-03-11 06:46:20 +000029from project import (
30 Annotation,
31 RemoteSpec,
32 Project,
33 RepoProject,
34 ManifestProject,
35)
36from error import (
37 ManifestParseError,
38 ManifestInvalidPathError,
39 ManifestInvalidRevisionError,
40)
Raman Tenneti993af5e2021-05-12 12:00:31 -070041from wrapper import Wrapper
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070042
Gavin Makea2e3302023-03-11 06:46:20 +000043MANIFEST_FILE_NAME = "manifest.xml"
44LOCAL_MANIFEST_NAME = "local_manifest.xml"
45LOCAL_MANIFESTS_DIR_NAME = "local_manifests"
46SUBMANIFEST_DIR = "submanifests"
LaMont Jonescc879a92021-11-18 22:40:18 +000047# Limit submanifests to an arbitrary depth for loop detection.
48MAX_SUBMANIFEST_DEPTH = 8
LaMont Jonesb308db12022-02-25 17:05:21 +000049# Add all projects from sub manifest into a group.
Gavin Makea2e3302023-03-11 06:46:20 +000050SUBMANIFEST_GROUP_PREFIX = "submanifest:"
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070051
Raman Tenneti78f4dd32021-06-07 13:27:37 -070052# Add all projects from local manifest into a group.
Gavin Makea2e3302023-03-11 06:46:20 +000053LOCAL_MANIFEST_GROUP_PREFIX = "local:"
Raman Tenneti78f4dd32021-06-07 13:27:37 -070054
Raman Tenneti993af5e2021-05-12 12:00:31 -070055# ContactInfo has the self-registered bug url, supplied by the manifest authors.
Gavin Makea2e3302023-03-11 06:46:20 +000056ContactInfo = collections.namedtuple("ContactInfo", "bugurl")
Raman Tenneti993af5e2021-05-12 12:00:31 -070057
Anthony Kingcb07ba72015-03-28 23:26:04 +000058# urljoin gets confused if the scheme is not known.
Gavin Makea2e3302023-03-11 06:46:20 +000059urllib.parse.uses_relative.extend(
60 ["ssh", "git", "persistent-https", "sso", "rpc"]
61)
62urllib.parse.uses_netloc.extend(
63 ["ssh", "git", "persistent-https", "sso", "rpc"]
64)
Conley Owensdb728cd2011-09-26 16:34:01 -070065
David Pursehouse819827a2020-02-12 15:20:19 +090066
Mike Frysingerbb8ee7f2020-02-22 05:30:12 -050067def XmlBool(node, attr, default=None):
Gavin Makea2e3302023-03-11 06:46:20 +000068 """Determine boolean value of |node|'s |attr|.
Mike Frysingerbb8ee7f2020-02-22 05:30:12 -050069
Gavin Makea2e3302023-03-11 06:46:20 +000070 Invalid values will issue a non-fatal warning.
Mike Frysingerbb8ee7f2020-02-22 05:30:12 -050071
Gavin Makea2e3302023-03-11 06:46:20 +000072 Args:
73 node: XML node whose attributes we access.
74 attr: The attribute to access.
75 default: If the attribute is not set (value is empty), then use this.
Mike Frysingerbb8ee7f2020-02-22 05:30:12 -050076
Gavin Makea2e3302023-03-11 06:46:20 +000077 Returns:
78 True if the attribute is a valid string representing true.
79 False if the attribute is a valid string representing false.
80 |default| otherwise.
81 """
82 value = node.getAttribute(attr)
83 s = value.lower()
84 if s == "":
85 return default
86 elif s in {"yes", "true", "1"}:
87 return True
88 elif s in {"no", "false", "0"}:
89 return False
90 else:
91 print(
92 'warning: manifest: %s="%s": ignoring invalid XML boolean'
93 % (attr, value),
94 file=sys.stderr,
95 )
96 return default
Mike Frysingerbb8ee7f2020-02-22 05:30:12 -050097
98
99def XmlInt(node, attr, default=None):
Gavin Makea2e3302023-03-11 06:46:20 +0000100 """Determine integer value of |node|'s |attr|.
Mike Frysingerbb8ee7f2020-02-22 05:30:12 -0500101
Gavin Makea2e3302023-03-11 06:46:20 +0000102 Args:
103 node: XML node whose attributes we access.
104 attr: The attribute to access.
105 default: If the attribute is not set (value is empty), then use this.
Mike Frysingerbb8ee7f2020-02-22 05:30:12 -0500106
Gavin Makea2e3302023-03-11 06:46:20 +0000107 Returns:
108 The number if the attribute is a valid number.
Mike Frysingerbb8ee7f2020-02-22 05:30:12 -0500109
Gavin Makea2e3302023-03-11 06:46:20 +0000110 Raises:
111 ManifestParseError: The number is invalid.
112 """
113 value = node.getAttribute(attr)
114 if not value:
115 return default
Mike Frysingerbb8ee7f2020-02-22 05:30:12 -0500116
Gavin Makea2e3302023-03-11 06:46:20 +0000117 try:
118 return int(value)
119 except ValueError:
120 raise ManifestParseError(
121 'manifest: invalid %s="%s" integer' % (attr, value)
122 )
Mike Frysingerbb8ee7f2020-02-22 05:30:12 -0500123
124
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700125class _Default(object):
Gavin Makea2e3302023-03-11 06:46:20 +0000126 """Project defaults within the manifest."""
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700127
Gavin Makea2e3302023-03-11 06:46:20 +0000128 revisionExpr = None
129 destBranchExpr = None
130 upstreamExpr = None
131 remote = None
132 sync_j = None
133 sync_c = False
134 sync_s = False
135 sync_tags = True
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700136
Gavin Makea2e3302023-03-11 06:46:20 +0000137 def __eq__(self, other):
138 if not isinstance(other, _Default):
139 return False
140 return self.__dict__ == other.__dict__
Julien Campergue74879922013-10-09 14:38:46 +0200141
Gavin Makea2e3302023-03-11 06:46:20 +0000142 def __ne__(self, other):
143 if not isinstance(other, _Default):
144 return True
145 return self.__dict__ != other.__dict__
Julien Campergue74879922013-10-09 14:38:46 +0200146
David Pursehouse819827a2020-02-12 15:20:19 +0900147
Shawn O. Pearced1f70d92009-05-19 14:58:02 -0700148class _XmlRemote(object):
Gavin Makea2e3302023-03-11 06:46:20 +0000149 def __init__(
150 self,
151 name,
152 alias=None,
153 fetch=None,
154 pushUrl=None,
155 manifestUrl=None,
156 review=None,
157 revision=None,
158 ):
159 self.name = name
160 self.fetchUrl = fetch
161 self.pushUrl = pushUrl
162 self.manifestUrl = manifestUrl
163 self.remoteAlias = alias
164 self.reviewUrl = review
165 self.revision = revision
166 self.resolvedFetchUrl = self._resolveFetchUrl()
167 self.annotations = []
Shawn O. Pearced1f70d92009-05-19 14:58:02 -0700168
Gavin Makea2e3302023-03-11 06:46:20 +0000169 def __eq__(self, other):
170 if not isinstance(other, _XmlRemote):
171 return False
172 return (
173 sorted(self.annotations) == sorted(other.annotations)
174 and self.name == other.name
175 and self.fetchUrl == other.fetchUrl
176 and self.pushUrl == other.pushUrl
177 and self.remoteAlias == other.remoteAlias
178 and self.reviewUrl == other.reviewUrl
179 and self.revision == other.revision
180 )
David Pursehouse717ece92012-11-13 08:49:16 +0900181
Gavin Makea2e3302023-03-11 06:46:20 +0000182 def __ne__(self, other):
183 return not self.__eq__(other)
David Pursehouse717ece92012-11-13 08:49:16 +0900184
Gavin Makea2e3302023-03-11 06:46:20 +0000185 def _resolveFetchUrl(self):
186 if self.fetchUrl is None:
187 return ""
188 url = self.fetchUrl.rstrip("/")
189 manifestUrl = self.manifestUrl.rstrip("/")
190 # urljoin will gets confused over quite a few things. The ones we care
191 # about here are:
192 # * no scheme in the base url, like <hostname:port>
193 # We handle no scheme by replacing it with an obscure protocol, gopher
194 # and then replacing it with the original when we are done.
Anthony Kingcb07ba72015-03-28 23:26:04 +0000195
Gavin Makea2e3302023-03-11 06:46:20 +0000196 if manifestUrl.find(":") != manifestUrl.find("/") - 1:
197 url = urllib.parse.urljoin("gopher://" + manifestUrl, url)
198 url = re.sub(r"^gopher://", "", url)
199 else:
200 url = urllib.parse.urljoin(manifestUrl, url)
201 return url
Conley Owensceea3682011-10-20 10:45:47 -0700202
Gavin Makea2e3302023-03-11 06:46:20 +0000203 def ToRemoteSpec(self, projectName):
204 fetchUrl = self.resolvedFetchUrl.rstrip("/")
205 url = fetchUrl + "/" + projectName
206 remoteName = self.name
207 if self.remoteAlias:
208 remoteName = self.remoteAlias
209 return RemoteSpec(
210 remoteName,
211 url=url,
212 pushUrl=self.pushUrl,
213 review=self.reviewUrl,
214 orig_name=self.name,
215 fetchUrl=self.fetchUrl,
216 )
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700217
Gavin Makea2e3302023-03-11 06:46:20 +0000218 def AddAnnotation(self, name, value, keep):
219 self.annotations.append(Annotation(name, value, keep))
Jack Neus6ea0cae2021-07-20 20:52:33 +0000220
David Pursehouse819827a2020-02-12 15:20:19 +0900221
LaMont Jonescc879a92021-11-18 22:40:18 +0000222class _XmlSubmanifest:
Gavin Makea2e3302023-03-11 06:46:20 +0000223 """Manage the <submanifest> element specified in the manifest.
LaMont Jonescc879a92021-11-18 22:40:18 +0000224
Gavin Makea2e3302023-03-11 06:46:20 +0000225 Attributes:
226 name: a string, the name for this submanifest.
227 remote: a string, the remote.name for this submanifest.
228 project: a string, the name of the manifest project.
229 revision: a string, the commitish.
230 manifestName: a string, the submanifest file name.
231 groups: a list of strings, the groups to add to all projects in the
232 submanifest.
233 default_groups: a list of strings, the default groups to sync.
234 path: a string, the relative path for the submanifest checkout.
235 parent: an XmlManifest, the parent manifest.
236 annotations: (derived) a list of annotations.
237 present: (derived) a boolean, whether the sub manifest file is present.
238 """
LaMont Jonescc879a92021-11-18 22:40:18 +0000239
Gavin Makea2e3302023-03-11 06:46:20 +0000240 def __init__(
241 self,
242 name,
243 remote=None,
244 project=None,
245 revision=None,
246 manifestName=None,
247 groups=None,
248 default_groups=None,
249 path=None,
250 parent=None,
251 ):
252 self.name = name
253 self.remote = remote
254 self.project = project
255 self.revision = revision
256 self.manifestName = manifestName
257 self.groups = groups
258 self.default_groups = default_groups
259 self.path = path
260 self.parent = parent
261 self.annotations = []
262 outer_client = parent._outer_client or parent
263 if self.remote and not self.project:
264 raise ManifestParseError(
265 f"Submanifest {name}: must specify project when remote is "
266 "given."
267 )
268 # Construct the absolute path to the manifest file using the parent's
269 # method, so that we can correctly create our repo_client.
270 manifestFile = parent.SubmanifestInfoDir(
271 os.path.join(parent.path_prefix, self.relpath),
272 os.path.join("manifests", manifestName or "default.xml"),
273 )
274 linkFile = parent.SubmanifestInfoDir(
275 os.path.join(parent.path_prefix, self.relpath), MANIFEST_FILE_NAME
276 )
277 self.repo_client = RepoClient(
278 parent.repodir,
279 linkFile,
280 parent_groups=",".join(groups) or "",
281 submanifest_path=self.relpath,
282 outer_client=outer_client,
283 default_groups=default_groups,
284 )
LaMont Jonescc879a92021-11-18 22:40:18 +0000285
Gavin Makea2e3302023-03-11 06:46:20 +0000286 self.present = os.path.exists(manifestFile)
LaMont Jonescc879a92021-11-18 22:40:18 +0000287
Gavin Makea2e3302023-03-11 06:46:20 +0000288 def __eq__(self, other):
289 if not isinstance(other, _XmlSubmanifest):
290 return False
291 return (
292 self.name == other.name
293 and self.remote == other.remote
294 and self.project == other.project
295 and self.revision == other.revision
296 and self.manifestName == other.manifestName
297 and self.groups == other.groups
298 and self.default_groups == other.default_groups
299 and self.path == other.path
300 and sorted(self.annotations) == sorted(other.annotations)
301 )
LaMont Jonescc879a92021-11-18 22:40:18 +0000302
Gavin Makea2e3302023-03-11 06:46:20 +0000303 def __ne__(self, other):
304 return not self.__eq__(other)
LaMont Jonescc879a92021-11-18 22:40:18 +0000305
Gavin Makea2e3302023-03-11 06:46:20 +0000306 def ToSubmanifestSpec(self):
307 """Return a SubmanifestSpec object, populating attributes"""
308 mp = self.parent.manifestProject
309 remote = self.parent.remotes[
310 self.remote or self.parent.default.remote.name
311 ]
312 # If a project was given, generate the url from the remote and project.
313 # If not, use this manifestProject's url.
314 if self.project:
315 manifestUrl = remote.ToRemoteSpec(self.project).url
316 else:
317 manifestUrl = mp.GetRemote().url
318 manifestName = self.manifestName or "default.xml"
319 revision = self.revision or self.name
320 path = self.path or revision.split("/")[-1]
321 groups = self.groups or []
LaMont Jonescc879a92021-11-18 22:40:18 +0000322
Gavin Makea2e3302023-03-11 06:46:20 +0000323 return SubmanifestSpec(
324 self.name, manifestUrl, manifestName, revision, path, groups
325 )
LaMont Jonescc879a92021-11-18 22:40:18 +0000326
Gavin Makea2e3302023-03-11 06:46:20 +0000327 @property
328 def relpath(self):
329 """The path of this submanifest relative to the parent manifest."""
330 revision = self.revision or self.name
331 return self.path or revision.split("/")[-1]
LaMont Jonescc879a92021-11-18 22:40:18 +0000332
Gavin Makea2e3302023-03-11 06:46:20 +0000333 def GetGroupsStr(self):
334 """Returns the `groups` given for this submanifest."""
335 if self.groups:
336 return ",".join(self.groups)
337 return ""
LaMont Jones501733c2022-04-20 16:42:32 +0000338
Gavin Makea2e3302023-03-11 06:46:20 +0000339 def GetDefaultGroupsStr(self):
340 """Returns the `default-groups` given for this submanifest."""
341 return ",".join(self.default_groups or [])
342
343 def AddAnnotation(self, name, value, keep):
344 """Add annotations to the submanifest."""
345 self.annotations.append(Annotation(name, value, keep))
LaMont Jonescc879a92021-11-18 22:40:18 +0000346
347
348class SubmanifestSpec:
Gavin Makea2e3302023-03-11 06:46:20 +0000349 """The submanifest element, with all fields expanded."""
LaMont Jonescc879a92021-11-18 22:40:18 +0000350
Gavin Makea2e3302023-03-11 06:46:20 +0000351 def __init__(self, name, manifestUrl, manifestName, revision, path, groups):
352 self.name = name
353 self.manifestUrl = manifestUrl
354 self.manifestName = manifestName
355 self.revision = revision
356 self.path = path
357 self.groups = groups or []
LaMont Jonescc879a92021-11-18 22:40:18 +0000358
359
Shawn O. Pearcec8a300f2009-05-18 13:19:57 -0700360class XmlManifest(object):
Gavin Makea2e3302023-03-11 06:46:20 +0000361 """manages the repo configuration file"""
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700362
Gavin Makea2e3302023-03-11 06:46:20 +0000363 def __init__(
364 self,
365 repodir,
366 manifest_file,
367 local_manifests=None,
368 outer_client=None,
369 parent_groups="",
370 submanifest_path="",
371 default_groups=None,
372 ):
373 """Initialize.
Mike Frysinger8c1e9cb2020-09-06 14:53:18 -0400374
Gavin Makea2e3302023-03-11 06:46:20 +0000375 Args:
376 repodir: Path to the .repo/ dir for holding all internal checkout
377 state. It must be in the top directory of the repo client
378 checkout.
379 manifest_file: Full path to the manifest file to parse. This will
380 usually be |repodir|/|MANIFEST_FILE_NAME|.
381 local_manifests: Full path to the directory of local override
382 manifests. This will usually be
383 |repodir|/|LOCAL_MANIFESTS_DIR_NAME|.
384 outer_client: RepoClient of the outer manifest.
385 parent_groups: a string, the groups to apply to this projects.
386 submanifest_path: The submanifest root relative to the repo root.
387 default_groups: a string, the default manifest groups to use.
388 """
389 # TODO(vapier): Move this out of this class.
390 self.globalConfig = GitConfig.ForUser()
Mike Frysinger8c1e9cb2020-09-06 14:53:18 -0400391
Gavin Makea2e3302023-03-11 06:46:20 +0000392 self.repodir = os.path.abspath(repodir)
393 self._CheckLocalPath(submanifest_path)
394 self.topdir = os.path.dirname(self.repodir)
395 if submanifest_path:
396 # This avoids a trailing os.path.sep when submanifest_path is empty.
397 self.topdir = os.path.join(self.topdir, submanifest_path)
398 if manifest_file != os.path.abspath(manifest_file):
399 raise ManifestParseError("manifest_file must be abspath")
400 self.manifestFile = manifest_file
401 if not outer_client or outer_client == self:
402 # manifestFileOverrides only exists in the outer_client's manifest,
403 # since that is the only instance left when Unload() is called on
404 # the outer manifest.
405 self.manifestFileOverrides = {}
406 self.local_manifests = local_manifests
407 self._load_local_manifests = True
408 self.parent_groups = parent_groups
409 self.default_groups = default_groups
LaMont Jonescc879a92021-11-18 22:40:18 +0000410
Gavin Makea2e3302023-03-11 06:46:20 +0000411 if outer_client and self.isGitcClient:
412 raise ManifestParseError(
413 "Multi-manifest is incompatible with `gitc-init`"
414 )
LaMont Jonescc879a92021-11-18 22:40:18 +0000415
Gavin Makea2e3302023-03-11 06:46:20 +0000416 if submanifest_path and not outer_client:
417 # If passing a submanifest_path, there must be an outer_client.
418 raise ManifestParseError(f"Bad call to {self.__class__.__name__}")
LaMont Jonescc879a92021-11-18 22:40:18 +0000419
Gavin Makea2e3302023-03-11 06:46:20 +0000420 # If self._outer_client is None, this is not a checkout that supports
421 # multi-tree.
422 self._outer_client = outer_client or self
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700423
Gavin Makea2e3302023-03-11 06:46:20 +0000424 self.repoProject = RepoProject(
425 self,
426 "repo",
427 gitdir=os.path.join(repodir, "repo/.git"),
428 worktree=os.path.join(repodir, "repo"),
429 )
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700430
Gavin Makea2e3302023-03-11 06:46:20 +0000431 mp = self.SubmanifestProject(self.path_prefix)
432 self.manifestProject = mp
Mike Frysinger979d5bd2020-02-09 02:28:34 -0500433
Gavin Makea2e3302023-03-11 06:46:20 +0000434 # This is a bit hacky, but we're in a chicken & egg situation: all the
435 # normal repo settings live in the manifestProject which we just setup
436 # above, so we couldn't easily query before that. We assume Project()
437 # init doesn't care if this changes afterwards.
438 if os.path.exists(mp.gitdir) and mp.use_worktree:
439 mp.use_git_worktrees = True
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700440
Gavin Makea2e3302023-03-11 06:46:20 +0000441 self.Unload()
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700442
Gavin Makea2e3302023-03-11 06:46:20 +0000443 def Override(self, name, load_local_manifests=True):
444 """Use a different manifest, just for the current instantiation."""
445 path = None
Basil Gelloc7453502018-05-25 20:23:52 +0300446
Gavin Makea2e3302023-03-11 06:46:20 +0000447 # Look for a manifest by path in the filesystem (including the cwd).
448 if not load_local_manifests:
449 local_path = os.path.abspath(name)
450 if os.path.isfile(local_path):
451 path = local_path
Basil Gelloc7453502018-05-25 20:23:52 +0300452
Gavin Makea2e3302023-03-11 06:46:20 +0000453 # Look for manifests by name from the manifests repo.
454 if path is None:
455 path = os.path.join(self.manifestProject.worktree, name)
456 if not os.path.isfile(path):
457 raise ManifestParseError("manifest %s not found" % name)
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700458
Gavin Makea2e3302023-03-11 06:46:20 +0000459 self._load_local_manifests = load_local_manifests
460 self._outer_client.manifestFileOverrides[self.path_prefix] = path
461 self.Unload()
462 self._Load()
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700463
Gavin Makea2e3302023-03-11 06:46:20 +0000464 def Link(self, name):
465 """Update the repo metadata to use a different manifest."""
466 self.Override(name)
Nico Sallembiena1bfd2c2010-04-06 10:40:01 -0700467
Gavin Makea2e3302023-03-11 06:46:20 +0000468 # Old versions of repo would generate symlinks we need to clean up.
469 platform_utils.remove(self.manifestFile, missing_ok=True)
470 # This file is interpreted as if it existed inside the manifest repo.
471 # That allows us to use <include> with the relative file name.
472 with open(self.manifestFile, "w") as fp:
473 fp.write(
474 """<?xml version="1.0" encoding="UTF-8"?>
Mike Frysingera269b1c2020-02-21 00:49:41 -0500475<!--
476DO NOT EDIT THIS FILE! It is generated by repo and changes will be discarded.
477If you want to use a different manifest, use `repo init -m <file>` instead.
478
479If you want to customize your checkout by overriding manifest settings, use
480the local_manifests/ directory instead.
481
482For more information on repo manifests, check out:
483https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
484-->
485<manifest>
486 <include name="%s" />
487</manifest>
Gavin Makea2e3302023-03-11 06:46:20 +0000488"""
489 % (name,)
490 )
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700491
Gavin Makea2e3302023-03-11 06:46:20 +0000492 def _RemoteToXml(self, r, doc, root):
493 e = doc.createElement("remote")
494 root.appendChild(e)
495 e.setAttribute("name", r.name)
496 e.setAttribute("fetch", r.fetchUrl)
497 if r.pushUrl is not None:
498 e.setAttribute("pushurl", r.pushUrl)
499 if r.remoteAlias is not None:
500 e.setAttribute("alias", r.remoteAlias)
501 if r.reviewUrl is not None:
502 e.setAttribute("review", r.reviewUrl)
503 if r.revision is not None:
504 e.setAttribute("revision", r.revision)
Shawn O. Pearcec7a4eef2009-03-05 10:32:38 -0800505
Gavin Makea2e3302023-03-11 06:46:20 +0000506 for a in r.annotations:
507 if a.keep == "true":
508 ae = doc.createElement("annotation")
509 ae.setAttribute("name", a.name)
510 ae.setAttribute("value", a.value)
511 e.appendChild(ae)
Jack Neus6ea0cae2021-07-20 20:52:33 +0000512
Gavin Makea2e3302023-03-11 06:46:20 +0000513 def _SubmanifestToXml(self, r, doc, root):
514 """Generate XML <submanifest/> node."""
515 e = doc.createElement("submanifest")
516 root.appendChild(e)
517 e.setAttribute("name", r.name)
518 if r.remote is not None:
519 e.setAttribute("remote", r.remote)
520 if r.project is not None:
521 e.setAttribute("project", r.project)
522 if r.manifestName is not None:
523 e.setAttribute("manifest-name", r.manifestName)
524 if r.revision is not None:
525 e.setAttribute("revision", r.revision)
526 if r.path is not None:
527 e.setAttribute("path", r.path)
528 if r.groups:
529 e.setAttribute("groups", r.GetGroupsStr())
530 if r.default_groups:
531 e.setAttribute("default-groups", r.GetDefaultGroupsStr())
LaMont Jonescc879a92021-11-18 22:40:18 +0000532
Gavin Makea2e3302023-03-11 06:46:20 +0000533 for a in r.annotations:
534 if a.keep == "true":
535 ae = doc.createElement("annotation")
536 ae.setAttribute("name", a.name)
537 ae.setAttribute("value", a.value)
538 e.appendChild(ae)
LaMont Jonescc879a92021-11-18 22:40:18 +0000539
Gavin Makea2e3302023-03-11 06:46:20 +0000540 def _ParseList(self, field):
541 """Parse fields that contain flattened lists.
Mike Frysinger51e39d52020-12-04 05:32:06 -0500542
Gavin Makea2e3302023-03-11 06:46:20 +0000543 These are whitespace & comma separated. Empty elements will be
544 discarded.
545 """
546 return [x for x in re.split(r"[,\s]+", field) if x]
Josh Triplett884a3872014-06-12 14:57:29 -0700547
Gavin Makea2e3302023-03-11 06:46:20 +0000548 def ToXml(
549 self,
550 peg_rev=False,
551 peg_rev_upstream=True,
552 peg_rev_dest_branch=True,
553 groups=None,
554 omit_local=False,
555 ):
556 """Return the current manifest XML."""
557 mp = self.manifestProject
Colin Cross5acde752012-03-28 20:15:45 -0700558
Gavin Makea2e3302023-03-11 06:46:20 +0000559 if groups is None:
560 groups = mp.manifest_groups
561 if groups:
562 groups = self._ParseList(groups)
Colin Cross5acde752012-03-28 20:15:45 -0700563
Gavin Makea2e3302023-03-11 06:46:20 +0000564 doc = xml.dom.minidom.Document()
565 root = doc.createElement("manifest")
566 if self.is_submanifest:
567 root.setAttribute("path", self.path_prefix)
568 doc.appendChild(root)
Shawn O. Pearcec7a4eef2009-03-05 10:32:38 -0800569
Gavin Makea2e3302023-03-11 06:46:20 +0000570 # Save out the notice. There's a little bit of work here to give it the
571 # right whitespace, which assumes that the notice is automatically
572 # indented by 4 by minidom.
573 if self.notice:
574 notice_element = root.appendChild(doc.createElement("notice"))
575 notice_lines = self.notice.splitlines()
576 indented_notice = (
577 "\n".join(" " * 4 + line for line in notice_lines)
578 )[4:]
579 notice_element.appendChild(doc.createTextNode(indented_notice))
Doug Anderson2b8db3c2010-11-01 15:08:06 -0700580
Gavin Makea2e3302023-03-11 06:46:20 +0000581 d = self.default
Shawn O. Pearcec7a4eef2009-03-05 10:32:38 -0800582
Gavin Makea2e3302023-03-11 06:46:20 +0000583 for r in sorted(self.remotes):
584 self._RemoteToXml(self.remotes[r], doc, root)
585 if self.remotes:
586 root.appendChild(doc.createTextNode(""))
Shawn O. Pearcec7a4eef2009-03-05 10:32:38 -0800587
Gavin Makea2e3302023-03-11 06:46:20 +0000588 have_default = False
589 e = doc.createElement("default")
590 if d.remote:
591 have_default = True
592 e.setAttribute("remote", d.remote.name)
593 if d.revisionExpr:
594 have_default = True
595 e.setAttribute("revision", d.revisionExpr)
596 if d.destBranchExpr:
597 have_default = True
598 e.setAttribute("dest-branch", d.destBranchExpr)
599 if d.upstreamExpr:
600 have_default = True
601 e.setAttribute("upstream", d.upstreamExpr)
602 if d.sync_j is not None:
603 have_default = True
604 e.setAttribute("sync-j", "%d" % d.sync_j)
605 if d.sync_c:
606 have_default = True
607 e.setAttribute("sync-c", "true")
608 if d.sync_s:
609 have_default = True
610 e.setAttribute("sync-s", "true")
611 if not d.sync_tags:
612 have_default = True
613 e.setAttribute("sync-tags", "false")
614 if have_default:
615 root.appendChild(e)
616 root.appendChild(doc.createTextNode(""))
Shawn O. Pearcec7a4eef2009-03-05 10:32:38 -0800617
Gavin Makea2e3302023-03-11 06:46:20 +0000618 if self._manifest_server:
619 e = doc.createElement("manifest-server")
620 e.setAttribute("url", self._manifest_server)
621 root.appendChild(e)
622 root.appendChild(doc.createTextNode(""))
Nico Sallembiena1bfd2c2010-04-06 10:40:01 -0700623
Gavin Makea2e3302023-03-11 06:46:20 +0000624 for r in sorted(self.submanifests):
625 self._SubmanifestToXml(self.submanifests[r], doc, root)
626 if self.submanifests:
627 root.appendChild(doc.createTextNode(""))
LaMont Jonescc879a92021-11-18 22:40:18 +0000628
Gavin Makea2e3302023-03-11 06:46:20 +0000629 def output_projects(parent, parent_node, projects):
630 for project_name in projects:
631 for project in self._projects[project_name]:
632 output_project(parent, parent_node, project)
Shawn O. Pearcec7a4eef2009-03-05 10:32:38 -0800633
Gavin Makea2e3302023-03-11 06:46:20 +0000634 def output_project(parent, parent_node, p):
635 if not p.MatchesGroups(groups):
636 return
Che-Liang Chioub2bd91c2012-01-11 11:28:42 +0800637
Gavin Makea2e3302023-03-11 06:46:20 +0000638 if omit_local and self.IsFromLocalManifest(p):
639 return
LaMont Jonesa8cf5752022-07-15 20:31:33 +0000640
Gavin Makea2e3302023-03-11 06:46:20 +0000641 name = p.name
642 relpath = p.relpath
643 if parent:
644 name = self._UnjoinName(parent.name, name)
645 relpath = self._UnjoinRelpath(parent.relpath, relpath)
Colin Cross5acde752012-03-28 20:15:45 -0700646
Gavin Makea2e3302023-03-11 06:46:20 +0000647 e = doc.createElement("project")
648 parent_node.appendChild(e)
649 e.setAttribute("name", name)
650 if relpath != name:
651 e.setAttribute("path", relpath)
652 remoteName = None
653 if d.remote:
654 remoteName = d.remote.name
655 if not d.remote or p.remote.orig_name != remoteName:
656 remoteName = p.remote.orig_name
657 e.setAttribute("remote", remoteName)
658 if peg_rev:
659 if self.IsMirror:
660 value = p.bare_git.rev_parse(p.revisionExpr + "^0")
661 else:
662 value = p.work_git.rev_parse(HEAD + "^0")
663 e.setAttribute("revision", value)
664 if peg_rev_upstream:
665 if p.upstream:
666 e.setAttribute("upstream", p.upstream)
667 elif value != p.revisionExpr:
668 # Only save the origin if the origin is not a sha1, and
669 # the default isn't our value
670 e.setAttribute("upstream", p.revisionExpr)
671
672 if peg_rev_dest_branch:
673 if p.dest_branch:
674 e.setAttribute("dest-branch", p.dest_branch)
675 elif value != p.revisionExpr:
676 e.setAttribute("dest-branch", p.revisionExpr)
677
678 else:
679 revision = (
680 self.remotes[p.remote.orig_name].revision or d.revisionExpr
681 )
682 if not revision or revision != p.revisionExpr:
683 e.setAttribute("revision", p.revisionExpr)
684 elif p.revisionId:
685 e.setAttribute("revision", p.revisionId)
686 if p.upstream and (
687 p.upstream != p.revisionExpr or p.upstream != d.upstreamExpr
688 ):
689 e.setAttribute("upstream", p.upstream)
690
691 if p.dest_branch and p.dest_branch != d.destBranchExpr:
692 e.setAttribute("dest-branch", p.dest_branch)
693
694 for c in p.copyfiles:
695 ce = doc.createElement("copyfile")
696 ce.setAttribute("src", c.src)
697 ce.setAttribute("dest", c.dest)
698 e.appendChild(ce)
699
700 for lf in p.linkfiles:
701 le = doc.createElement("linkfile")
702 le.setAttribute("src", lf.src)
703 le.setAttribute("dest", lf.dest)
704 e.appendChild(le)
705
706 default_groups = ["all", "name:%s" % p.name, "path:%s" % p.relpath]
707 egroups = [g for g in p.groups if g not in default_groups]
708 if egroups:
709 e.setAttribute("groups", ",".join(egroups))
710
711 for a in p.annotations:
712 if a.keep == "true":
713 ae = doc.createElement("annotation")
714 ae.setAttribute("name", a.name)
715 ae.setAttribute("value", a.value)
716 e.appendChild(ae)
717
718 if p.sync_c:
719 e.setAttribute("sync-c", "true")
720
721 if p.sync_s:
722 e.setAttribute("sync-s", "true")
723
724 if not p.sync_tags:
725 e.setAttribute("sync-tags", "false")
726
727 if p.clone_depth:
728 e.setAttribute("clone-depth", str(p.clone_depth))
729
730 self._output_manifest_project_extras(p, e)
731
732 if p.subprojects:
733 subprojects = set(subp.name for subp in p.subprojects)
734 output_projects(p, e, list(sorted(subprojects)))
735
736 projects = set(p.name for p in self._paths.values() if not p.parent)
737 output_projects(None, root, list(sorted(projects)))
738
739 if self._repo_hooks_project:
740 root.appendChild(doc.createTextNode(""))
741 e = doc.createElement("repo-hooks")
742 e.setAttribute("in-project", self._repo_hooks_project.name)
743 e.setAttribute(
744 "enabled-list",
745 " ".join(self._repo_hooks_project.enabled_repo_hooks),
746 )
747 root.appendChild(e)
748
749 if self._superproject:
750 root.appendChild(doc.createTextNode(""))
751 e = doc.createElement("superproject")
752 e.setAttribute("name", self._superproject.name)
753 remoteName = None
754 if d.remote:
755 remoteName = d.remote.name
756 remote = self._superproject.remote
757 if not d.remote or remote.orig_name != remoteName:
758 remoteName = remote.orig_name
759 e.setAttribute("remote", remoteName)
760 revision = remote.revision or d.revisionExpr
761 if not revision or revision != self._superproject.revision:
762 e.setAttribute("revision", self._superproject.revision)
763 root.appendChild(e)
764
765 if self._contactinfo.bugurl != Wrapper().BUG_URL:
766 root.appendChild(doc.createTextNode(""))
767 e = doc.createElement("contactinfo")
768 e.setAttribute("bugurl", self._contactinfo.bugurl)
769 root.appendChild(e)
770
771 return doc
772
773 def ToDict(self, **kwargs):
774 """Return the current manifest as a dictionary."""
775 # Elements that may only appear once.
776 SINGLE_ELEMENTS = {
777 "notice",
778 "default",
779 "manifest-server",
780 "repo-hooks",
781 "superproject",
782 "contactinfo",
783 }
784 # Elements that may be repeated.
785 MULTI_ELEMENTS = {
786 "remote",
787 "remove-project",
788 "project",
789 "extend-project",
790 "include",
791 "submanifest",
792 # These are children of 'project' nodes.
793 "annotation",
794 "project",
795 "copyfile",
796 "linkfile",
797 }
798
799 doc = self.ToXml(**kwargs)
800 ret = {}
801
802 def append_children(ret, node):
803 for child in node.childNodes:
804 if child.nodeType == xml.dom.Node.ELEMENT_NODE:
805 attrs = child.attributes
806 element = dict(
807 (attrs.item(i).localName, attrs.item(i).value)
808 for i in range(attrs.length)
809 )
810 if child.nodeName in SINGLE_ELEMENTS:
811 ret[child.nodeName] = element
812 elif child.nodeName in MULTI_ELEMENTS:
813 ret.setdefault(child.nodeName, []).append(element)
814 else:
815 raise ManifestParseError(
816 'Unhandled element "%s"' % (child.nodeName,)
817 )
818
819 append_children(element, child)
820
821 append_children(ret, doc.firstChild)
822
823 return ret
824
825 def Save(self, fd, **kwargs):
826 """Write the current manifest out to the given file descriptor."""
827 doc = self.ToXml(**kwargs)
828 doc.writexml(fd, "", " ", "\n", "UTF-8")
829
830 def _output_manifest_project_extras(self, p, e):
831 """Manifests can modify e if they support extra project attributes."""
832
833 @property
834 def is_multimanifest(self):
835 """Whether this is a multimanifest checkout.
836
837 This is safe to use as long as the outermost manifest XML has been
838 parsed.
839 """
840 return bool(self._outer_client._submanifests)
841
842 @property
843 def is_submanifest(self):
844 """Whether this manifest is a submanifest.
845
846 This is safe to use as long as the outermost manifest XML has been
847 parsed.
848 """
849 return self._outer_client and self._outer_client != self
850
851 @property
852 def outer_client(self):
853 """The instance of the outermost manifest client."""
854 self._Load()
855 return self._outer_client
856
857 @property
858 def all_manifests(self):
859 """Generator yielding all (sub)manifests, in depth-first order."""
860 self._Load()
861 outer = self._outer_client
862 yield outer
863 for tree in outer.all_children:
864 yield tree
865
866 @property
867 def all_children(self):
868 """Generator yielding all (present) child submanifests."""
869 self._Load()
870 for child in self._submanifests.values():
871 if child.repo_client:
872 yield child.repo_client
873 for tree in child.repo_client.all_children:
874 yield tree
875
876 @property
877 def path_prefix(self):
878 """The path of this submanifest, relative to the outermost manifest."""
879 if not self._outer_client or self == self._outer_client:
880 return ""
881 return os.path.relpath(self.topdir, self._outer_client.topdir)
882
883 @property
884 def all_paths(self):
885 """All project paths for all (sub)manifests.
886
887 See also `paths`.
888
889 Returns:
890 A dictionary of {path: Project()}. `path` is relative to the outer
891 manifest.
892 """
893 ret = {}
894 for tree in self.all_manifests:
895 prefix = tree.path_prefix
896 ret.update(
897 {os.path.join(prefix, k): v for k, v in tree.paths.items()}
898 )
899 return ret
900
901 @property
902 def all_projects(self):
903 """All projects for all (sub)manifests. See `projects`."""
904 return list(
905 itertools.chain.from_iterable(
906 x._paths.values() for x in self.all_manifests
907 )
908 )
909
910 @property
911 def paths(self):
912 """Return all paths for this manifest.
913
914 Returns:
915 A dictionary of {path: Project()}. `path` is relative to this
916 manifest.
917 """
918 self._Load()
919 return self._paths
920
921 @property
922 def projects(self):
923 """Return a list of all Projects in this manifest."""
924 self._Load()
925 return list(self._paths.values())
926
927 @property
928 def remotes(self):
929 """Return a list of remotes for this manifest."""
930 self._Load()
931 return self._remotes
932
933 @property
934 def default(self):
935 """Return default values for this manifest."""
936 self._Load()
937 return self._default
938
939 @property
940 def submanifests(self):
941 """All submanifests in this manifest."""
942 self._Load()
943 return self._submanifests
944
945 @property
946 def repo_hooks_project(self):
947 self._Load()
948 return self._repo_hooks_project
949
950 @property
951 def superproject(self):
952 self._Load()
953 return self._superproject
954
955 @property
956 def contactinfo(self):
957 self._Load()
958 return self._contactinfo
959
960 @property
961 def notice(self):
962 self._Load()
963 return self._notice
964
965 @property
966 def manifest_server(self):
967 self._Load()
968 return self._manifest_server
969
970 @property
971 def CloneBundle(self):
972 clone_bundle = self.manifestProject.clone_bundle
973 if clone_bundle is None:
974 return False if self.manifestProject.partial_clone else True
Shawn O. Pearcec7a4eef2009-03-05 10:32:38 -0800975 else:
Gavin Makea2e3302023-03-11 06:46:20 +0000976 return clone_bundle
Sean McAllisteraf908cb2020-04-20 08:41:58 -0600977
Gavin Makea2e3302023-03-11 06:46:20 +0000978 @property
979 def CloneFilter(self):
980 if self.manifestProject.partial_clone:
981 return self.manifestProject.clone_filter
982 return None
Sean McAllisteraf908cb2020-04-20 08:41:58 -0600983
Gavin Makea2e3302023-03-11 06:46:20 +0000984 @property
985 def PartialCloneExclude(self):
986 exclude = self.manifest.manifestProject.partial_clone_exclude or ""
987 return set(x.strip() for x in exclude.split(","))
Shawn O. Pearcec7a4eef2009-03-05 10:32:38 -0800988
Gavin Makea2e3302023-03-11 06:46:20 +0000989 def SetManifestOverride(self, path):
990 """Override manifestFile. The caller must call Unload()"""
991 self._outer_client.manifest.manifestFileOverrides[
992 self.path_prefix
993 ] = path
Simon Ruggier7e59de22015-07-24 12:50:06 +0200994
Gavin Makea2e3302023-03-11 06:46:20 +0000995 @property
996 def UseLocalManifests(self):
997 return self._load_local_manifests
Shawn O. Pearcec7a4eef2009-03-05 10:32:38 -0800998
Gavin Makea2e3302023-03-11 06:46:20 +0000999 def SetUseLocalManifests(self, value):
1000 self._load_local_manifests = value
Jeff Hamiltone0df2322014-04-21 17:10:59 -05001001
Gavin Makea2e3302023-03-11 06:46:20 +00001002 @property
1003 def HasLocalManifests(self):
1004 return self._load_local_manifests and self.local_manifests
Colin Cross5acde752012-03-28 20:15:45 -07001005
Gavin Makea2e3302023-03-11 06:46:20 +00001006 def IsFromLocalManifest(self, project):
1007 """Is the project from a local manifest?"""
1008 return any(
1009 x.startswith(LOCAL_MANIFEST_GROUP_PREFIX) for x in project.groups
1010 )
James W. Mills24c13082012-04-12 15:04:13 -05001011
Gavin Makea2e3302023-03-11 06:46:20 +00001012 @property
1013 def IsMirror(self):
1014 return self.manifestProject.mirror
Anatol Pomazau79770d22012-04-20 14:41:59 -07001015
Gavin Makea2e3302023-03-11 06:46:20 +00001016 @property
1017 def UseGitWorktrees(self):
1018 return self.manifestProject.use_worktree
Che-Liang Chioub2bd91c2012-01-11 11:28:42 +08001019
Gavin Makea2e3302023-03-11 06:46:20 +00001020 @property
1021 def IsArchive(self):
1022 return self.manifestProject.archive
YOUNG HO CHAa32c92c2018-02-14 16:57:31 +09001023
Gavin Makea2e3302023-03-11 06:46:20 +00001024 @property
1025 def HasSubmodules(self):
1026 return self.manifestProject.submodules
Dan Willemsen88409222015-08-17 15:29:10 -07001027
Gavin Makea2e3302023-03-11 06:46:20 +00001028 @property
1029 def EnableGitLfs(self):
1030 return self.manifestProject.git_lfs
Simran Basib9a1b732015-08-20 12:19:28 -07001031
Gavin Makea2e3302023-03-11 06:46:20 +00001032 def FindManifestByPath(self, path):
1033 """Returns the manifest containing path."""
1034 path = os.path.abspath(path)
1035 manifest = self._outer_client or self
1036 old = None
1037 while manifest._submanifests and manifest != old:
1038 old = manifest
1039 for name in manifest._submanifests:
1040 tree = manifest._submanifests[name]
1041 if path.startswith(tree.repo_client.manifest.topdir):
1042 manifest = tree.repo_client
1043 break
1044 return manifest
Che-Liang Chioub2bd91c2012-01-11 11:28:42 +08001045
Gavin Makea2e3302023-03-11 06:46:20 +00001046 @property
1047 def subdir(self):
1048 """Returns the path for per-submanifest objects for this manifest."""
1049 return self.SubmanifestInfoDir(self.path_prefix)
Che-Liang Chioub2bd91c2012-01-11 11:28:42 +08001050
Gavin Makea2e3302023-03-11 06:46:20 +00001051 def SubmanifestInfoDir(self, submanifest_path, object_path=""):
1052 """Return the path to submanifest-specific info for a submanifest.
Doug Anderson37282b42011-03-04 11:54:18 -08001053
Gavin Makea2e3302023-03-11 06:46:20 +00001054 Return the full path of the directory in which to put per-manifest
1055 objects.
Raman Tenneti1bb4fb22021-01-07 16:50:45 -08001056
Gavin Makea2e3302023-03-11 06:46:20 +00001057 Args:
1058 submanifest_path: a string, the path of the submanifest, relative to
1059 the outermost topdir. If empty, then repodir is returned.
1060 object_path: a string, relative path to append to the submanifest
1061 info directory path.
1062 """
1063 if submanifest_path:
1064 return os.path.join(
1065 self.repodir, SUBMANIFEST_DIR, submanifest_path, object_path
1066 )
1067 else:
1068 return os.path.join(self.repodir, object_path)
Raman Tenneti1c3f57e2021-05-04 12:32:13 -07001069
Gavin Makea2e3302023-03-11 06:46:20 +00001070 def SubmanifestProject(self, submanifest_path):
1071 """Return a manifestProject for a submanifest."""
1072 subdir = self.SubmanifestInfoDir(submanifest_path)
1073 mp = ManifestProject(
1074 self,
1075 "manifests",
1076 gitdir=os.path.join(subdir, "manifests.git"),
1077 worktree=os.path.join(subdir, "manifests"),
1078 )
1079 return mp
Mike Frysinger23411d32020-09-02 04:31:10 -04001080
Gavin Makea2e3302023-03-11 06:46:20 +00001081 def GetDefaultGroupsStr(self, with_platform=True):
1082 """Returns the default group string to use.
Mike Frysinger23411d32020-09-02 04:31:10 -04001083
Gavin Makea2e3302023-03-11 06:46:20 +00001084 Args:
1085 with_platform: a boolean, whether to include the group for the
1086 underlying platform.
1087 """
1088 groups = ",".join(self.default_groups or ["default"])
1089 if with_platform:
1090 groups += f",platform-{platform.system().lower()}"
1091 return groups
Mike Frysinger23411d32020-09-02 04:31:10 -04001092
Gavin Makea2e3302023-03-11 06:46:20 +00001093 def GetGroupsStr(self):
1094 """Returns the manifest group string that should be synced."""
1095 return (
1096 self.manifestProject.manifest_groups or self.GetDefaultGroupsStr()
1097 )
Mike Frysinger23411d32020-09-02 04:31:10 -04001098
Gavin Makea2e3302023-03-11 06:46:20 +00001099 def Unload(self):
1100 """Unload the manifest.
Mike Frysinger23411d32020-09-02 04:31:10 -04001101
Gavin Makea2e3302023-03-11 06:46:20 +00001102 If the manifest files have been changed since Load() was called, this
1103 will cause the new/updated manifest to be used.
Mike Frysinger23411d32020-09-02 04:31:10 -04001104
Gavin Makea2e3302023-03-11 06:46:20 +00001105 """
1106 self._loaded = False
1107 self._projects = {}
1108 self._paths = {}
1109 self._remotes = {}
1110 self._default = None
1111 self._submanifests = {}
1112 self._repo_hooks_project = None
1113 self._superproject = None
1114 self._contactinfo = ContactInfo(Wrapper().BUG_URL)
1115 self._notice = None
1116 self.branch = None
1117 self._manifest_server = None
Mike Frysinger23411d32020-09-02 04:31:10 -04001118
Gavin Makea2e3302023-03-11 06:46:20 +00001119 def Load(self):
1120 """Read the manifest into memory."""
1121 # Do not expose internal arguments.
1122 self._Load()
Shawn O. Pearcec7a4eef2009-03-05 10:32:38 -08001123
Gavin Makea2e3302023-03-11 06:46:20 +00001124 def _Load(self, initial_client=None, submanifest_depth=0):
1125 if submanifest_depth > MAX_SUBMANIFEST_DEPTH:
1126 raise ManifestParseError(
1127 "maximum submanifest depth %d exceeded." % MAX_SUBMANIFEST_DEPTH
1128 )
1129 if not self._loaded:
1130 if self._outer_client and self._outer_client != self:
1131 # This will load all clients.
1132 self._outer_client._Load(initial_client=self)
Simran Basib9a1b732015-08-20 12:19:28 -07001133
Gavin Makea2e3302023-03-11 06:46:20 +00001134 savedManifestFile = self.manifestFile
1135 override = self._outer_client.manifestFileOverrides.get(
1136 self.path_prefix
1137 )
1138 if override:
1139 self.manifestFile = override
Mike Frysinger1d00a7e2021-12-21 00:40:31 -05001140
Gavin Makea2e3302023-03-11 06:46:20 +00001141 try:
1142 m = self.manifestProject
1143 b = m.GetBranch(m.CurrentBranch).merge
1144 if b is not None and b.startswith(R_HEADS):
1145 b = b[len(R_HEADS) :]
1146 self.branch = b
LaMont Jonescc879a92021-11-18 22:40:18 +00001147
Gavin Makea2e3302023-03-11 06:46:20 +00001148 parent_groups = self.parent_groups
1149 if self.path_prefix:
1150 parent_groups = (
1151 f"{SUBMANIFEST_GROUP_PREFIX}:path:"
1152 f"{self.path_prefix},{parent_groups}"
1153 )
LaMont Jonesff6b1da2022-06-01 21:03:34 +00001154
Gavin Makea2e3302023-03-11 06:46:20 +00001155 # The manifestFile was specified by the user which is why we
1156 # allow include paths to point anywhere.
1157 nodes = []
1158 nodes.append(
1159 self._ParseManifestXml(
1160 self.manifestFile,
1161 self.manifestProject.worktree,
1162 parent_groups=parent_groups,
1163 restrict_includes=False,
1164 )
1165 )
LaMont Jonescc879a92021-11-18 22:40:18 +00001166
Gavin Makea2e3302023-03-11 06:46:20 +00001167 if self._load_local_manifests and self.local_manifests:
1168 try:
1169 for local_file in sorted(
1170 platform_utils.listdir(self.local_manifests)
1171 ):
1172 if local_file.endswith(".xml"):
1173 local = os.path.join(
1174 self.local_manifests, local_file
1175 )
1176 # Since local manifests are entirely managed by
1177 # the user, allow them to point anywhere the
1178 # user wants.
1179 local_group = (
1180 f"{LOCAL_MANIFEST_GROUP_PREFIX}:"
1181 f"{local_file[:-4]}"
1182 )
1183 nodes.append(
1184 self._ParseManifestXml(
1185 local,
1186 self.subdir,
1187 parent_groups=(
1188 f"{local_group},{parent_groups}"
1189 ),
1190 restrict_includes=False,
1191 )
1192 )
1193 except OSError:
1194 pass
Raman Tenneti080877e2021-03-09 15:19:06 -08001195
Gavin Makea2e3302023-03-11 06:46:20 +00001196 try:
1197 self._ParseManifest(nodes)
1198 except ManifestParseError as e:
1199 # There was a problem parsing, unload ourselves in case they
1200 # catch this error and try again later, we will show the
1201 # correct error
1202 self.Unload()
1203 raise e
Raman Tenneti080877e2021-03-09 15:19:06 -08001204
Gavin Makea2e3302023-03-11 06:46:20 +00001205 if self.IsMirror:
1206 self._AddMetaProjectMirror(self.repoProject)
1207 self._AddMetaProjectMirror(self.manifestProject)
LaMont Jonesa2ff20d2022-04-07 16:49:06 +00001208
Gavin Makea2e3302023-03-11 06:46:20 +00001209 self._loaded = True
1210 finally:
1211 if override:
1212 self.manifestFile = savedManifestFile
LaMont Jonesa2ff20d2022-04-07 16:49:06 +00001213
Gavin Makea2e3302023-03-11 06:46:20 +00001214 # Now that we have loaded this manifest, load any submanifests as
1215 # well. We need to do this after self._loaded is set to avoid
1216 # looping.
1217 for name in self._submanifests:
1218 tree = self._submanifests[name]
1219 tree.ToSubmanifestSpec()
1220 present = os.path.exists(
1221 os.path.join(self.subdir, MANIFEST_FILE_NAME)
1222 )
1223 if present and tree.present and not tree.repo_client:
1224 if initial_client and initial_client.topdir == self.topdir:
1225 tree.repo_client = self
1226 tree.present = present
1227 elif not os.path.exists(self.subdir):
1228 tree.present = False
1229 if present and tree.present:
1230 tree.repo_client._Load(
1231 initial_client=initial_client,
1232 submanifest_depth=submanifest_depth + 1,
1233 )
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -07001234
Gavin Makea2e3302023-03-11 06:46:20 +00001235 def _ParseManifestXml(
Shuchuan Zeng3e3340d2023-04-18 10:36:50 +08001236 self,
1237 path,
1238 include_root,
1239 parent_groups="",
1240 restrict_includes=True,
1241 parent_node=None,
Gavin Makea2e3302023-03-11 06:46:20 +00001242 ):
1243 """Parse a manifest XML and return the computed nodes.
LaMont Jonesa2ff20d2022-04-07 16:49:06 +00001244
Gavin Makea2e3302023-03-11 06:46:20 +00001245 Args:
1246 path: The XML file to read & parse.
1247 include_root: The path to interpret include "name"s relative to.
1248 parent_groups: The groups to apply to this projects.
1249 restrict_includes: Whether to constrain the "name" attribute of
1250 includes.
Shuchuan Zeng3e3340d2023-04-18 10:36:50 +08001251 parent_node: The parent include node, to apply attribute to this
1252 projects.
LaMont Jonescc879a92021-11-18 22:40:18 +00001253
Gavin Makea2e3302023-03-11 06:46:20 +00001254 Returns:
1255 List of XML nodes.
1256 """
1257 try:
1258 root = xml.dom.minidom.parse(path)
1259 except (OSError, xml.parsers.expat.ExpatError) as e:
1260 raise ManifestParseError(
1261 "error parsing manifest %s: %s" % (path, e)
1262 )
David Pursehouse2d5a0df2012-11-13 02:50:36 +09001263
Gavin Makea2e3302023-03-11 06:46:20 +00001264 if not root or not root.childNodes:
1265 raise ManifestParseError("no root node in %s" % (path,))
Shawn O. Pearce5cc66792008-10-23 16:19:27 -07001266
Gavin Makea2e3302023-03-11 06:46:20 +00001267 for manifest in root.childNodes:
1268 if manifest.nodeName == "manifest":
1269 break
1270 else:
1271 raise ManifestParseError("no <manifest> in %s" % (path,))
Shawn O. Pearcee284ad12008-11-04 07:37:10 -08001272
LaMont Jonesb90a4222022-04-14 15:00:09 +00001273 nodes = []
Gavin Makea2e3302023-03-11 06:46:20 +00001274 for node in manifest.childNodes:
1275 if node.nodeName == "include":
1276 name = self._reqatt(node, "name")
1277 if restrict_includes:
1278 msg = self._CheckLocalPath(name)
1279 if msg:
1280 raise ManifestInvalidPathError(
1281 '<include> invalid "name": %s: %s' % (name, msg)
1282 )
1283 include_groups = ""
1284 if parent_groups:
1285 include_groups = parent_groups
1286 if node.hasAttribute("groups"):
1287 include_groups = (
1288 node.getAttribute("groups") + "," + include_groups
1289 )
1290 fp = os.path.join(include_root, name)
1291 if not os.path.isfile(fp):
1292 raise ManifestParseError(
1293 "include [%s/]%s doesn't exist or isn't a file"
1294 % (include_root, name)
1295 )
1296 try:
1297 nodes.extend(
Shuchuan Zeng3e3340d2023-04-18 10:36:50 +08001298 self._ParseManifestXml(
1299 fp, include_root, include_groups, parent_node=node
1300 )
Gavin Makea2e3302023-03-11 06:46:20 +00001301 )
1302 # should isolate this to the exact exception, but that's
1303 # tricky. actual parsing implementation may vary.
1304 except (
1305 KeyboardInterrupt,
1306 RuntimeError,
1307 SystemExit,
1308 ManifestParseError,
1309 ):
1310 raise
1311 except Exception as e:
1312 raise ManifestParseError(
1313 "failed parsing included manifest %s: %s" % (name, e)
1314 )
1315 else:
1316 if parent_groups and node.nodeName == "project":
1317 nodeGroups = parent_groups
1318 if node.hasAttribute("groups"):
1319 nodeGroups = (
1320 node.getAttribute("groups") + "," + nodeGroups
1321 )
1322 node.setAttribute("groups", nodeGroups)
Shuchuan Zeng3e3340d2023-04-18 10:36:50 +08001323 if (
1324 parent_node
1325 and node.nodeName == "project"
1326 and not node.hasAttribute("revision")
1327 ):
1328 node.setAttribute(
1329 "revision", parent_node.getAttribute("revision")
1330 )
Gavin Makea2e3302023-03-11 06:46:20 +00001331 nodes.append(node)
1332 return nodes
LaMont Jonesb90a4222022-04-14 15:00:09 +00001333
Gavin Makea2e3302023-03-11 06:46:20 +00001334 def _ParseManifest(self, node_list):
1335 for node in itertools.chain(*node_list):
1336 if node.nodeName == "remote":
1337 remote = self._ParseRemote(node)
1338 if remote:
1339 if remote.name in self._remotes:
1340 if remote != self._remotes[remote.name]:
1341 raise ManifestParseError(
1342 "remote %s already exists with different "
1343 "attributes" % (remote.name)
1344 )
1345 else:
1346 self._remotes[remote.name] = remote
LaMont Jonesb90a4222022-04-14 15:00:09 +00001347
Gavin Makea2e3302023-03-11 06:46:20 +00001348 for node in itertools.chain(*node_list):
1349 if node.nodeName == "default":
1350 new_default = self._ParseDefault(node)
1351 emptyDefault = (
1352 not node.hasAttributes() and not node.hasChildNodes()
1353 )
1354 if self._default is None:
1355 self._default = new_default
1356 elif not emptyDefault and new_default != self._default:
1357 raise ManifestParseError(
1358 "duplicate default in %s" % (self.manifestFile)
1359 )
LaMont Jonesb90a4222022-04-14 15:00:09 +00001360
Julien Campergue74879922013-10-09 14:38:46 +02001361 if self._default is None:
Gavin Makea2e3302023-03-11 06:46:20 +00001362 self._default = _Default()
Julien Campergue74879922013-10-09 14:38:46 +02001363
Gavin Makea2e3302023-03-11 06:46:20 +00001364 submanifest_paths = set()
1365 for node in itertools.chain(*node_list):
1366 if node.nodeName == "submanifest":
1367 submanifest = self._ParseSubmanifest(node)
1368 if submanifest:
1369 if submanifest.name in self._submanifests:
1370 if submanifest != self._submanifests[submanifest.name]:
1371 raise ManifestParseError(
1372 "submanifest %s already exists with different "
1373 "attributes" % (submanifest.name)
1374 )
1375 else:
1376 self._submanifests[submanifest.name] = submanifest
1377 submanifest_paths.add(submanifest.relpath)
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -07001378
Gavin Makea2e3302023-03-11 06:46:20 +00001379 for node in itertools.chain(*node_list):
1380 if node.nodeName == "notice":
1381 if self._notice is not None:
1382 raise ManifestParseError(
1383 "duplicate notice in %s" % (self.manifestFile)
1384 )
1385 self._notice = self._ParseNotice(node)
LaMont Jonescc879a92021-11-18 22:40:18 +00001386
Gavin Makea2e3302023-03-11 06:46:20 +00001387 for node in itertools.chain(*node_list):
1388 if node.nodeName == "manifest-server":
1389 url = self._reqatt(node, "url")
1390 if self._manifest_server is not None:
1391 raise ManifestParseError(
1392 "duplicate manifest-server in %s" % (self.manifestFile)
1393 )
1394 self._manifest_server = url
Doug Anderson2b8db3c2010-11-01 15:08:06 -07001395
Gavin Makea2e3302023-03-11 06:46:20 +00001396 def recursively_add_projects(project):
1397 projects = self._projects.setdefault(project.name, [])
1398 if project.relpath is None:
1399 raise ManifestParseError(
1400 "missing path for %s in %s"
1401 % (project.name, self.manifestFile)
1402 )
1403 if project.relpath in self._paths:
1404 raise ManifestParseError(
1405 "duplicate path %s in %s"
1406 % (project.relpath, self.manifestFile)
1407 )
1408 for tree in submanifest_paths:
1409 if project.relpath.startswith(tree):
1410 raise ManifestParseError(
1411 "project %s conflicts with submanifest path %s"
1412 % (project.relpath, tree)
1413 )
1414 self._paths[project.relpath] = project
1415 projects.append(project)
1416 for subproject in project.subprojects:
1417 recursively_add_projects(subproject)
Nico Sallembiena1bfd2c2010-04-06 10:40:01 -07001418
Gavin Makea2e3302023-03-11 06:46:20 +00001419 repo_hooks_project = None
1420 enabled_repo_hooks = None
1421 for node in itertools.chain(*node_list):
1422 if node.nodeName == "project":
1423 project = self._ParseProject(node)
1424 recursively_add_projects(project)
1425 if node.nodeName == "extend-project":
1426 name = self._reqatt(node, "name")
Che-Liang Chioub2bd91c2012-01-11 11:28:42 +08001427
Gavin Makea2e3302023-03-11 06:46:20 +00001428 if name not in self._projects:
1429 raise ManifestParseError(
1430 "extend-project element specifies non-existent "
1431 "project: %s" % name
1432 )
1433
1434 path = node.getAttribute("path")
1435 dest_path = node.getAttribute("dest-path")
1436 groups = node.getAttribute("groups")
1437 if groups:
1438 groups = self._ParseList(groups)
1439 revision = node.getAttribute("revision")
1440 remote_name = node.getAttribute("remote")
1441 if not remote_name:
1442 remote = self._default.remote
1443 else:
1444 remote = self._get_remote(node)
1445 dest_branch = node.getAttribute("dest-branch")
1446 upstream = node.getAttribute("upstream")
1447
1448 named_projects = self._projects[name]
1449 if dest_path and not path and len(named_projects) > 1:
1450 raise ManifestParseError(
1451 "extend-project cannot use dest-path when "
1452 "matching multiple projects: %s" % name
1453 )
1454 for p in self._projects[name]:
1455 if path and p.relpath != path:
1456 continue
1457 if groups:
1458 p.groups.extend(groups)
1459 if revision:
1460 p.SetRevision(revision)
1461
1462 if remote_name:
1463 p.remote = remote.ToRemoteSpec(name)
1464 if dest_branch:
1465 p.dest_branch = dest_branch
1466 if upstream:
1467 p.upstream = upstream
1468
1469 if dest_path:
1470 del self._paths[p.relpath]
1471 (
1472 relpath,
1473 worktree,
1474 gitdir,
1475 objdir,
1476 _,
1477 ) = self.GetProjectPaths(name, dest_path, remote.name)
1478 p.UpdatePaths(relpath, worktree, gitdir, objdir)
1479 self._paths[p.relpath] = p
1480
1481 if node.nodeName == "repo-hooks":
1482 # Only one project can be the hooks project
1483 if repo_hooks_project is not None:
1484 raise ManifestParseError(
1485 "duplicate repo-hooks in %s" % (self.manifestFile)
1486 )
1487
1488 # Get the name of the project and the (space-separated) list of
1489 # enabled.
1490 repo_hooks_project = self._reqatt(node, "in-project")
1491 enabled_repo_hooks = self._ParseList(
1492 self._reqatt(node, "enabled-list")
1493 )
1494 if node.nodeName == "superproject":
1495 name = self._reqatt(node, "name")
1496 # There can only be one superproject.
1497 if self._superproject:
1498 raise ManifestParseError(
1499 "duplicate superproject in %s" % (self.manifestFile)
1500 )
1501 remote_name = node.getAttribute("remote")
1502 if not remote_name:
1503 remote = self._default.remote
1504 else:
1505 remote = self._get_remote(node)
1506 if remote is None:
1507 raise ManifestParseError(
1508 "no remote for superproject %s within %s"
1509 % (name, self.manifestFile)
1510 )
1511 revision = node.getAttribute("revision") or remote.revision
1512 if not revision:
1513 revision = self._default.revisionExpr
1514 if not revision:
1515 raise ManifestParseError(
1516 "no revision for superproject %s within %s"
1517 % (name, self.manifestFile)
1518 )
1519 self._superproject = Superproject(
1520 self,
1521 name=name,
1522 remote=remote.ToRemoteSpec(name),
1523 revision=revision,
1524 )
1525 if node.nodeName == "contactinfo":
1526 bugurl = self._reqatt(node, "bugurl")
1527 # This element can be repeated, later entries will clobber
1528 # earlier ones.
1529 self._contactinfo = ContactInfo(bugurl)
1530
1531 if node.nodeName == "remove-project":
1532 name = self._reqatt(node, "name")
1533
1534 if name in self._projects:
1535 for p in self._projects[name]:
1536 del self._paths[p.relpath]
1537 del self._projects[name]
1538
1539 # If the manifest removes the hooks project, treat it as if
1540 # it deleted
1541 # the repo-hooks element too.
1542 if repo_hooks_project == name:
1543 repo_hooks_project = None
1544 elif not XmlBool(node, "optional", False):
1545 raise ManifestParseError(
1546 "remove-project element specifies non-existent "
1547 "project: %s" % name
1548 )
1549
1550 # Store repo hooks project information.
1551 if repo_hooks_project:
1552 # Store a reference to the Project.
1553 try:
1554 repo_hooks_projects = self._projects[repo_hooks_project]
1555 except KeyError:
1556 raise ManifestParseError(
1557 "project %s not found for repo-hooks" % (repo_hooks_project)
1558 )
1559
1560 if len(repo_hooks_projects) != 1:
1561 raise ManifestParseError(
1562 "internal error parsing repo-hooks in %s"
1563 % (self.manifestFile)
1564 )
1565 self._repo_hooks_project = repo_hooks_projects[0]
1566 # Store the enabled hooks in the Project object.
1567 self._repo_hooks_project.enabled_repo_hooks = enabled_repo_hooks
1568
1569 def _AddMetaProjectMirror(self, m):
1570 name = None
1571 m_url = m.GetRemote().url
1572 if m_url.endswith("/.git"):
1573 raise ManifestParseError("refusing to mirror %s" % m_url)
1574
1575 if self._default and self._default.remote:
1576 url = self._default.remote.resolvedFetchUrl
1577 if not url.endswith("/"):
1578 url += "/"
1579 if m_url.startswith(url):
1580 remote = self._default.remote
1581 name = m_url[len(url) :]
1582
1583 if name is None:
1584 s = m_url.rindex("/") + 1
1585 manifestUrl = self.manifestProject.config.GetString(
1586 "remote.origin.url"
1587 )
1588 remote = _XmlRemote(
1589 "origin", fetch=m_url[:s], manifestUrl=manifestUrl
1590 )
1591 name = m_url[s:]
1592
1593 if name.endswith(".git"):
1594 name = name[:-4]
Josh Triplett884a3872014-06-12 14:57:29 -07001595
1596 if name not in self._projects:
Gavin Makea2e3302023-03-11 06:46:20 +00001597 m.PreSync()
1598 gitdir = os.path.join(self.topdir, "%s.git" % name)
1599 project = Project(
1600 manifest=self,
1601 name=name,
1602 remote=remote.ToRemoteSpec(name),
1603 gitdir=gitdir,
1604 objdir=gitdir,
1605 worktree=None,
1606 relpath=name or None,
1607 revisionExpr=m.revisionExpr,
1608 revisionId=None,
1609 )
1610 self._projects[project.name] = [project]
1611 self._paths[project.relpath] = project
Josh Triplett884a3872014-06-12 14:57:29 -07001612
Gavin Makea2e3302023-03-11 06:46:20 +00001613 def _ParseRemote(self, node):
1614 """
1615 reads a <remote> element from the manifest file
1616 """
1617 name = self._reqatt(node, "name")
1618 alias = node.getAttribute("alias")
1619 if alias == "":
1620 alias = None
1621 fetch = self._reqatt(node, "fetch")
1622 pushUrl = node.getAttribute("pushurl")
1623 if pushUrl == "":
1624 pushUrl = None
1625 review = node.getAttribute("review")
1626 if review == "":
1627 review = None
1628 revision = node.getAttribute("revision")
1629 if revision == "":
1630 revision = None
1631 manifestUrl = self.manifestProject.config.GetString("remote.origin.url")
1632
1633 remote = _XmlRemote(
1634 name, alias, fetch, pushUrl, manifestUrl, review, revision
1635 )
1636
1637 for n in node.childNodes:
1638 if n.nodeName == "annotation":
1639 self._ParseAnnotation(remote, n)
1640
1641 return remote
1642
1643 def _ParseDefault(self, node):
1644 """
1645 reads a <default> element from the manifest file
1646 """
1647 d = _Default()
1648 d.remote = self._get_remote(node)
1649 d.revisionExpr = node.getAttribute("revision")
1650 if d.revisionExpr == "":
1651 d.revisionExpr = None
1652
1653 d.destBranchExpr = node.getAttribute("dest-branch") or None
1654 d.upstreamExpr = node.getAttribute("upstream") or None
1655
1656 d.sync_j = XmlInt(node, "sync-j", None)
1657 if d.sync_j is not None and d.sync_j <= 0:
1658 raise ManifestParseError(
1659 '%s: sync-j must be greater than 0, not "%s"'
1660 % (self.manifestFile, d.sync_j)
1661 )
1662
1663 d.sync_c = XmlBool(node, "sync-c", False)
1664 d.sync_s = XmlBool(node, "sync-s", False)
1665 d.sync_tags = XmlBool(node, "sync-tags", True)
1666 return d
1667
1668 def _ParseNotice(self, node):
1669 """
1670 reads a <notice> element from the manifest file
1671
1672 The <notice> element is distinct from other tags in the XML in that the
1673 data is conveyed between the start and end tag (it's not an
1674 empty-element tag).
1675
1676 The white space (carriage returns, indentation) for the notice element
1677 is relevant and is parsed in a way that is based on how python
1678 docstrings work. In fact, the code is remarkably similar to here:
1679 http://www.python.org/dev/peps/pep-0257/
1680 """
1681 # Get the data out of the node...
1682 notice = node.childNodes[0].data
1683
1684 # Figure out minimum indentation, skipping the first line (the same line
1685 # as the <notice> tag)...
1686 minIndent = sys.maxsize
1687 lines = notice.splitlines()
1688 for line in lines[1:]:
1689 lstrippedLine = line.lstrip()
1690 if lstrippedLine:
1691 indent = len(line) - len(lstrippedLine)
1692 minIndent = min(indent, minIndent)
1693
1694 # Strip leading / trailing blank lines and also indentation.
1695 cleanLines = [lines[0].strip()]
1696 for line in lines[1:]:
1697 cleanLines.append(line[minIndent:].rstrip())
1698
1699 # Clear completely blank lines from front and back...
1700 while cleanLines and not cleanLines[0]:
1701 del cleanLines[0]
1702 while cleanLines and not cleanLines[-1]:
1703 del cleanLines[-1]
1704
1705 return "\n".join(cleanLines)
1706
1707 def _ParseSubmanifest(self, node):
1708 """Reads a <submanifest> element from the manifest file."""
1709 name = self._reqatt(node, "name")
1710 remote = node.getAttribute("remote")
1711 if remote == "":
1712 remote = None
1713 project = node.getAttribute("project")
1714 if project == "":
1715 project = None
1716 revision = node.getAttribute("revision")
1717 if revision == "":
1718 revision = None
1719 manifestName = node.getAttribute("manifest-name")
1720 if manifestName == "":
1721 manifestName = None
1722 groups = ""
1723 if node.hasAttribute("groups"):
1724 groups = node.getAttribute("groups")
1725 groups = self._ParseList(groups)
1726 default_groups = self._ParseList(node.getAttribute("default-groups"))
1727 path = node.getAttribute("path")
1728 if path == "":
1729 path = None
1730 if revision:
1731 msg = self._CheckLocalPath(revision.split("/")[-1])
1732 if msg:
1733 raise ManifestInvalidPathError(
1734 '<submanifest> invalid "revision": %s: %s'
1735 % (revision, msg)
1736 )
1737 else:
1738 msg = self._CheckLocalPath(name)
1739 if msg:
1740 raise ManifestInvalidPathError(
1741 '<submanifest> invalid "name": %s: %s' % (name, msg)
1742 )
LaMont Jonescc879a92021-11-18 22:40:18 +00001743 else:
Gavin Makea2e3302023-03-11 06:46:20 +00001744 msg = self._CheckLocalPath(path)
1745 if msg:
1746 raise ManifestInvalidPathError(
1747 '<submanifest> invalid "path": %s: %s' % (path, msg)
1748 )
Josh Triplett884a3872014-06-12 14:57:29 -07001749
Gavin Makea2e3302023-03-11 06:46:20 +00001750 submanifest = _XmlSubmanifest(
1751 name,
1752 remote,
1753 project,
1754 revision,
1755 manifestName,
1756 groups,
1757 default_groups,
1758 path,
1759 self,
1760 )
Michael Kelly2f3c3312020-07-21 19:40:38 -07001761
Gavin Makea2e3302023-03-11 06:46:20 +00001762 for n in node.childNodes:
1763 if n.nodeName == "annotation":
1764 self._ParseAnnotation(submanifest, n)
Michael Kelly2f3c3312020-07-21 19:40:38 -07001765
Gavin Makea2e3302023-03-11 06:46:20 +00001766 return submanifest
Michael Kelly37c21c22020-06-13 02:10:40 -07001767
Gavin Makea2e3302023-03-11 06:46:20 +00001768 def _JoinName(self, parent_name, name):
1769 return os.path.join(parent_name, name)
Doug Anderson37282b42011-03-04 11:54:18 -08001770
Gavin Makea2e3302023-03-11 06:46:20 +00001771 def _UnjoinName(self, parent_name, name):
1772 return os.path.relpath(name, parent_name)
1773
1774 def _ParseProject(self, node, parent=None, **extra_proj_attrs):
1775 """
1776 reads a <project> element from the manifest file
1777 """
1778 name = self._reqatt(node, "name")
1779 msg = self._CheckLocalPath(name, dir_ok=True)
1780 if msg:
1781 raise ManifestInvalidPathError(
1782 '<project> invalid "name": %s: %s' % (name, msg)
1783 )
1784 if parent:
1785 name = self._JoinName(parent.name, name)
1786
1787 remote = self._get_remote(node)
Raman Tenneti1bb4fb22021-01-07 16:50:45 -08001788 if remote is None:
Gavin Makea2e3302023-03-11 06:46:20 +00001789 remote = self._default.remote
1790 if remote is None:
1791 raise ManifestParseError(
1792 "no remote for project %s within %s" % (name, self.manifestFile)
1793 )
Raman Tenneti993af5e2021-05-12 12:00:31 -07001794
Gavin Makea2e3302023-03-11 06:46:20 +00001795 revisionExpr = node.getAttribute("revision") or remote.revision
1796 if not revisionExpr:
1797 revisionExpr = self._default.revisionExpr
1798 if not revisionExpr:
1799 raise ManifestParseError(
1800 "no revision for project %s within %s"
1801 % (name, self.manifestFile)
1802 )
David Jamesb8433df2014-01-30 10:11:17 -08001803
Gavin Makea2e3302023-03-11 06:46:20 +00001804 path = node.getAttribute("path")
1805 if not path:
1806 path = name
Julien Camperguedd654222014-01-09 16:21:37 +01001807 else:
Gavin Makea2e3302023-03-11 06:46:20 +00001808 # NB: The "." project is handled specially in
1809 # Project.Sync_LocalHalf.
1810 msg = self._CheckLocalPath(path, dir_ok=True, cwd_dot_ok=True)
1811 if msg:
1812 raise ManifestInvalidPathError(
1813 '<project> invalid "path": %s: %s' % (path, msg)
1814 )
Julien Camperguedd654222014-01-09 16:21:37 +01001815
Gavin Makea2e3302023-03-11 06:46:20 +00001816 rebase = XmlBool(node, "rebase", True)
1817 sync_c = XmlBool(node, "sync-c", False)
1818 sync_s = XmlBool(node, "sync-s", self._default.sync_s)
1819 sync_tags = XmlBool(node, "sync-tags", self._default.sync_tags)
Julien Camperguedd654222014-01-09 16:21:37 +01001820
Gavin Makea2e3302023-03-11 06:46:20 +00001821 clone_depth = XmlInt(node, "clone-depth")
1822 if clone_depth is not None and clone_depth <= 0:
1823 raise ManifestParseError(
1824 '%s: clone-depth must be greater than 0, not "%s"'
1825 % (self.manifestFile, clone_depth)
1826 )
1827
1828 dest_branch = (
1829 node.getAttribute("dest-branch") or self._default.destBranchExpr
1830 )
1831
1832 upstream = node.getAttribute("upstream") or self._default.upstreamExpr
1833
1834 groups = ""
1835 if node.hasAttribute("groups"):
1836 groups = node.getAttribute("groups")
1837 groups = self._ParseList(groups)
1838
1839 if parent is None:
1840 (
1841 relpath,
1842 worktree,
1843 gitdir,
1844 objdir,
1845 use_git_worktrees,
1846 ) = self.GetProjectPaths(name, path, remote.name)
1847 else:
1848 use_git_worktrees = False
1849 relpath, worktree, gitdir, objdir = self.GetSubprojectPaths(
1850 parent, name, path
1851 )
1852
1853 default_groups = ["all", "name:%s" % name, "path:%s" % relpath]
1854 groups.extend(set(default_groups).difference(groups))
1855
1856 if self.IsMirror and node.hasAttribute("force-path"):
1857 if XmlBool(node, "force-path", False):
1858 gitdir = os.path.join(self.topdir, "%s.git" % path)
1859
1860 project = Project(
1861 manifest=self,
1862 name=name,
1863 remote=remote.ToRemoteSpec(name),
1864 gitdir=gitdir,
1865 objdir=objdir,
1866 worktree=worktree,
1867 relpath=relpath,
1868 revisionExpr=revisionExpr,
1869 revisionId=None,
1870 rebase=rebase,
1871 groups=groups,
1872 sync_c=sync_c,
1873 sync_s=sync_s,
1874 sync_tags=sync_tags,
1875 clone_depth=clone_depth,
1876 upstream=upstream,
1877 parent=parent,
1878 dest_branch=dest_branch,
1879 use_git_worktrees=use_git_worktrees,
1880 **extra_proj_attrs,
1881 )
1882
1883 for n in node.childNodes:
1884 if n.nodeName == "copyfile":
1885 self._ParseCopyFile(project, n)
1886 if n.nodeName == "linkfile":
1887 self._ParseLinkFile(project, n)
1888 if n.nodeName == "annotation":
1889 self._ParseAnnotation(project, n)
1890 if n.nodeName == "project":
1891 project.subprojects.append(
1892 self._ParseProject(n, parent=project)
1893 )
1894
1895 return project
1896
1897 def GetProjectPaths(self, name, path, remote):
1898 """Return the paths for a project.
1899
1900 Args:
1901 name: a string, the name of the project.
1902 path: a string, the path of the project.
1903 remote: a string, the remote.name of the project.
1904
1905 Returns:
1906 A tuple of (relpath, worktree, gitdir, objdir, use_git_worktrees)
1907 for the project with |name| and |path|.
1908 """
1909 # The manifest entries might have trailing slashes. Normalize them to
1910 # avoid unexpected filesystem behavior since we do string concatenation
1911 # below.
1912 path = path.rstrip("/")
1913 name = name.rstrip("/")
1914 remote = remote.rstrip("/")
1915 use_git_worktrees = False
1916 use_remote_name = self.is_multimanifest
1917 relpath = path
1918 if self.IsMirror:
1919 worktree = None
1920 gitdir = os.path.join(self.topdir, "%s.git" % name)
1921 objdir = gitdir
1922 else:
1923 if use_remote_name:
1924 namepath = os.path.join(remote, f"{name}.git")
1925 else:
1926 namepath = f"{name}.git"
1927 worktree = os.path.join(self.topdir, path).replace("\\", "/")
1928 gitdir = os.path.join(self.subdir, "projects", "%s.git" % path)
1929 # We allow people to mix git worktrees & non-git worktrees for now.
1930 # This allows for in situ migration of repo clients.
1931 if os.path.exists(gitdir) or not self.UseGitWorktrees:
1932 objdir = os.path.join(self.repodir, "project-objects", namepath)
1933 else:
1934 use_git_worktrees = True
1935 gitdir = os.path.join(self.repodir, "worktrees", namepath)
1936 objdir = gitdir
1937 return relpath, worktree, gitdir, objdir, use_git_worktrees
1938
1939 def GetProjectsWithName(self, name, all_manifests=False):
1940 """All projects with |name|.
1941
1942 Args:
1943 name: a string, the name of the project.
1944 all_manifests: a boolean, if True, then all manifests are searched.
1945 If False, then only this manifest is searched.
1946
1947 Returns:
1948 A list of Project instances with name |name|.
1949 """
1950 if all_manifests:
1951 return list(
1952 itertools.chain.from_iterable(
1953 x._projects.get(name, []) for x in self.all_manifests
1954 )
1955 )
1956 return self._projects.get(name, [])
1957
1958 def GetSubprojectName(self, parent, submodule_path):
1959 return os.path.join(parent.name, submodule_path)
1960
1961 def _JoinRelpath(self, parent_relpath, relpath):
1962 return os.path.join(parent_relpath, relpath)
1963
1964 def _UnjoinRelpath(self, parent_relpath, relpath):
1965 return os.path.relpath(relpath, parent_relpath)
1966
1967 def GetSubprojectPaths(self, parent, name, path):
1968 # The manifest entries might have trailing slashes. Normalize them to
1969 # avoid unexpected filesystem behavior since we do string concatenation
1970 # below.
1971 path = path.rstrip("/")
1972 name = name.rstrip("/")
1973 relpath = self._JoinRelpath(parent.relpath, path)
1974 gitdir = os.path.join(parent.gitdir, "subprojects", "%s.git" % path)
1975 objdir = os.path.join(
1976 parent.gitdir, "subproject-objects", "%s.git" % name
1977 )
1978 if self.IsMirror:
1979 worktree = None
1980 else:
1981 worktree = os.path.join(parent.worktree, path).replace("\\", "/")
1982 return relpath, worktree, gitdir, objdir
1983
1984 @staticmethod
1985 def _CheckLocalPath(path, dir_ok=False, cwd_dot_ok=False):
1986 """Verify |path| is reasonable for use in filesystem paths.
1987
1988 Used with <copyfile> & <linkfile> & <project> elements.
1989
1990 This only validates the |path| in isolation: it does not check against
1991 the current filesystem state. Thus it is suitable as a first-past in a
1992 parser.
1993
1994 It enforces a number of constraints:
1995 * No empty paths.
1996 * No "~" in paths.
1997 * No Unicode codepoints that filesystems might elide when normalizing.
1998 * No relative path components like "." or "..".
1999 * No absolute paths.
2000 * No ".git" or ".repo*" path components.
2001
2002 Args:
2003 path: The path name to validate.
2004 dir_ok: Whether |path| may force a directory (e.g. end in a /).
2005 cwd_dot_ok: Whether |path| may be just ".".
2006
2007 Returns:
2008 None if |path| is OK, a failure message otherwise.
2009 """
2010 if not path:
2011 return "empty paths not allowed"
2012
2013 if "~" in path:
2014 return "~ not allowed (due to 8.3 filenames on Windows filesystems)"
2015
2016 path_codepoints = set(path)
2017
2018 # Some filesystems (like Apple's HFS+) try to normalize Unicode
2019 # codepoints which means there are alternative names for ".git". Reject
2020 # paths with these in it as there shouldn't be any reasonable need for
2021 # them here. The set of codepoints here was cribbed from jgit's
2022 # implementation:
2023 # https://eclipse.googlesource.com/jgit/jgit/+/9110037e3e9461ff4dac22fee84ef3694ed57648/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java#884
2024 BAD_CODEPOINTS = {
2025 "\u200C", # ZERO WIDTH NON-JOINER
2026 "\u200D", # ZERO WIDTH JOINER
2027 "\u200E", # LEFT-TO-RIGHT MARK
2028 "\u200F", # RIGHT-TO-LEFT MARK
2029 "\u202A", # LEFT-TO-RIGHT EMBEDDING
2030 "\u202B", # RIGHT-TO-LEFT EMBEDDING
2031 "\u202C", # POP DIRECTIONAL FORMATTING
2032 "\u202D", # LEFT-TO-RIGHT OVERRIDE
2033 "\u202E", # RIGHT-TO-LEFT OVERRIDE
2034 "\u206A", # INHIBIT SYMMETRIC SWAPPING
2035 "\u206B", # ACTIVATE SYMMETRIC SWAPPING
2036 "\u206C", # INHIBIT ARABIC FORM SHAPING
2037 "\u206D", # ACTIVATE ARABIC FORM SHAPING
2038 "\u206E", # NATIONAL DIGIT SHAPES
2039 "\u206F", # NOMINAL DIGIT SHAPES
2040 "\uFEFF", # ZERO WIDTH NO-BREAK SPACE
2041 }
2042 if BAD_CODEPOINTS & path_codepoints:
2043 # This message is more expansive than reality, but should be fine.
2044 return "Unicode combining characters not allowed"
2045
2046 # Reject newlines as there shouldn't be any legitmate use for them,
2047 # they'll be confusing to users, and they can easily break tools that
2048 # expect to be able to iterate over newline delimited lists. This even
2049 # applies to our own code like .repo/project.list.
2050 if {"\r", "\n"} & path_codepoints:
2051 return "Newlines not allowed"
2052
2053 # Assume paths might be used on case-insensitive filesystems.
2054 path = path.lower()
2055
2056 # Split up the path by its components. We can't use os.path.sep
2057 # exclusively as some platforms (like Windows) will convert / to \ and
2058 # that bypasses all our constructed logic here. Especially since
2059 # manifest authors only use / in their paths.
2060 resep = re.compile(r"[/%s]" % re.escape(os.path.sep))
2061 # Strip off trailing slashes as those only produce '' elements, and we
2062 # use parts to look for individual bad components.
2063 parts = resep.split(path.rstrip("/"))
2064
2065 # Some people use src="." to create stable links to projects. Lets
2066 # allow that but reject all other uses of "." to keep things simple.
2067 if not cwd_dot_ok or parts != ["."]:
2068 for part in set(parts):
2069 if part in {".", "..", ".git"} or part.startswith(".repo"):
2070 return "bad component: %s" % (part,)
2071
2072 if not dir_ok and resep.match(path[-1]):
2073 return "dirs not allowed"
2074
2075 # NB: The two abspath checks here are to handle platforms with multiple
2076 # filesystem path styles (e.g. Windows).
2077 norm = os.path.normpath(path)
2078 if (
2079 norm == ".."
2080 or (
2081 len(norm) >= 3
2082 and norm.startswith("..")
2083 and resep.match(norm[0])
2084 )
2085 or os.path.isabs(norm)
2086 or norm.startswith("/")
2087 ):
2088 return "path cannot be outside"
2089
2090 @classmethod
2091 def _ValidateFilePaths(cls, element, src, dest):
2092 """Verify |src| & |dest| are reasonable for <copyfile> & <linkfile>.
2093
2094 We verify the path independent of any filesystem state as we won't have
2095 a checkout available to compare to. i.e. This is for parsing validation
2096 purposes only.
2097
2098 We'll do full/live sanity checking before we do the actual filesystem
2099 modifications in _CopyFile/_LinkFile/etc...
2100 """
2101 # |dest| is the file we write to or symlink we create.
2102 # It is relative to the top of the repo client checkout.
2103 msg = cls._CheckLocalPath(dest)
2104 if msg:
2105 raise ManifestInvalidPathError(
2106 '<%s> invalid "dest": %s: %s' % (element, dest, msg)
2107 )
2108
2109 # |src| is the file we read from or path we point to for symlinks.
2110 # It is relative to the top of the git project checkout.
2111 is_linkfile = element == "linkfile"
2112 msg = cls._CheckLocalPath(
2113 src, dir_ok=is_linkfile, cwd_dot_ok=is_linkfile
2114 )
2115 if msg:
2116 raise ManifestInvalidPathError(
2117 '<%s> invalid "src": %s: %s' % (element, src, msg)
2118 )
2119
2120 def _ParseCopyFile(self, project, node):
2121 src = self._reqatt(node, "src")
2122 dest = self._reqatt(node, "dest")
2123 if not self.IsMirror:
2124 # src is project relative;
2125 # dest is relative to the top of the tree.
2126 # We only validate paths if we actually plan to process them.
2127 self._ValidateFilePaths("copyfile", src, dest)
2128 project.AddCopyFile(src, dest, self.topdir)
2129
2130 def _ParseLinkFile(self, project, node):
2131 src = self._reqatt(node, "src")
2132 dest = self._reqatt(node, "dest")
2133 if not self.IsMirror:
2134 # src is project relative;
2135 # dest is relative to the top of the tree.
2136 # We only validate paths if we actually plan to process them.
2137 self._ValidateFilePaths("linkfile", src, dest)
2138 project.AddLinkFile(src, dest, self.topdir)
2139
2140 def _ParseAnnotation(self, element, node):
2141 name = self._reqatt(node, "name")
2142 value = self._reqatt(node, "value")
2143 try:
2144 keep = self._reqatt(node, "keep").lower()
2145 except ManifestParseError:
2146 keep = "true"
2147 if keep != "true" and keep != "false":
2148 raise ManifestParseError(
2149 'optional "keep" attribute must be ' '"true" or "false"'
2150 )
2151 element.AddAnnotation(name, value, keep)
2152
2153 def _get_remote(self, node):
2154 name = node.getAttribute("remote")
2155 if not name:
2156 return None
2157
2158 v = self._remotes.get(name)
2159 if not v:
2160 raise ManifestParseError(
2161 "remote %s not defined in %s" % (name, self.manifestFile)
2162 )
2163 return v
2164
2165 def _reqatt(self, node, attname):
2166 """
2167 reads a required attribute from the node.
2168 """
2169 v = node.getAttribute(attname)
2170 if not v:
2171 raise ManifestParseError(
2172 "no %s in <%s> within %s"
2173 % (attname, node.nodeName, self.manifestFile)
2174 )
2175 return v
2176
2177 def projectsDiff(self, manifest):
2178 """return the projects differences between two manifests.
2179
2180 The diff will be from self to given manifest.
2181
2182 """
2183 fromProjects = self.paths
2184 toProjects = manifest.paths
2185
2186 fromKeys = sorted(fromProjects.keys())
2187 toKeys = sorted(toProjects.keys())
2188
2189 diff = {
2190 "added": [],
2191 "removed": [],
2192 "missing": [],
2193 "changed": [],
2194 "unreachable": [],
2195 }
2196
2197 for proj in fromKeys:
2198 if proj not in toKeys:
2199 diff["removed"].append(fromProjects[proj])
2200 elif not fromProjects[proj].Exists:
2201 diff["missing"].append(toProjects[proj])
2202 toKeys.remove(proj)
2203 else:
2204 fromProj = fromProjects[proj]
2205 toProj = toProjects[proj]
2206 try:
2207 fromRevId = fromProj.GetCommitRevisionId()
2208 toRevId = toProj.GetCommitRevisionId()
2209 except ManifestInvalidRevisionError:
2210 diff["unreachable"].append((fromProj, toProj))
2211 else:
2212 if fromRevId != toRevId:
2213 diff["changed"].append((fromProj, toProj))
2214 toKeys.remove(proj)
2215
2216 for proj in toKeys:
2217 diff["added"].append(toProjects[proj])
2218
2219 return diff
Simran Basib9a1b732015-08-20 12:19:28 -07002220
2221
2222class GitcManifest(XmlManifest):
Gavin Makea2e3302023-03-11 06:46:20 +00002223 """Parser for GitC (git-in-the-cloud) manifests."""
Simran Basib9a1b732015-08-20 12:19:28 -07002224
Gavin Makea2e3302023-03-11 06:46:20 +00002225 def _ParseProject(self, node, parent=None):
2226 """Override _ParseProject and add support for GITC specific attributes.""" # noqa: E501
2227 return super()._ParseProject(
2228 node, parent=parent, old_revision=node.getAttribute("old-revision")
2229 )
Simran Basib9a1b732015-08-20 12:19:28 -07002230
Gavin Makea2e3302023-03-11 06:46:20 +00002231 def _output_manifest_project_extras(self, p, e):
2232 """Output GITC Specific Project attributes"""
2233 if p.old_revision:
2234 e.setAttribute("old-revision", str(p.old_revision))
Mike Frysinger8c1e9cb2020-09-06 14:53:18 -04002235
2236
2237class RepoClient(XmlManifest):
Gavin Makea2e3302023-03-11 06:46:20 +00002238 """Manages a repo client checkout."""
Mike Frysinger8c1e9cb2020-09-06 14:53:18 -04002239
Gavin Makea2e3302023-03-11 06:46:20 +00002240 def __init__(
2241 self, repodir, manifest_file=None, submanifest_path="", **kwargs
2242 ):
2243 """Initialize.
LaMont Jonesff6b1da2022-06-01 21:03:34 +00002244
Gavin Makea2e3302023-03-11 06:46:20 +00002245 Args:
2246 repodir: Path to the .repo/ dir for holding all internal checkout
2247 state. It must be in the top directory of the repo client
2248 checkout.
2249 manifest_file: Full path to the manifest file to parse. This will
2250 usually be |repodir|/|MANIFEST_FILE_NAME|.
2251 submanifest_path: The submanifest root relative to the repo root.
2252 **kwargs: Additional keyword arguments, passed to XmlManifest.
2253 """
2254 self.isGitcClient = False
2255 submanifest_path = submanifest_path or ""
2256 if submanifest_path:
2257 self._CheckLocalPath(submanifest_path)
2258 prefix = os.path.join(repodir, SUBMANIFEST_DIR, submanifest_path)
2259 else:
2260 prefix = repodir
Mike Frysinger8c1e9cb2020-09-06 14:53:18 -04002261
Gavin Makea2e3302023-03-11 06:46:20 +00002262 if os.path.exists(os.path.join(prefix, LOCAL_MANIFEST_NAME)):
2263 print(
2264 "error: %s is not supported; put local manifests in `%s` "
2265 "instead"
2266 % (
2267 LOCAL_MANIFEST_NAME,
2268 os.path.join(prefix, LOCAL_MANIFESTS_DIR_NAME),
2269 ),
2270 file=sys.stderr,
2271 )
2272 sys.exit(1)
Mike Frysinger8c1e9cb2020-09-06 14:53:18 -04002273
Gavin Makea2e3302023-03-11 06:46:20 +00002274 if manifest_file is None:
2275 manifest_file = os.path.join(prefix, MANIFEST_FILE_NAME)
2276 local_manifests = os.path.abspath(
2277 os.path.join(prefix, LOCAL_MANIFESTS_DIR_NAME)
2278 )
2279 super().__init__(
2280 repodir,
2281 manifest_file,
2282 local_manifests,
2283 submanifest_path=submanifest_path,
2284 **kwargs,
2285 )
Mike Frysinger8c1e9cb2020-09-06 14:53:18 -04002286
Gavin Makea2e3302023-03-11 06:46:20 +00002287 # TODO: Completely separate manifest logic out of the client.
2288 self.manifest = self
Mike Frysinger8c1e9cb2020-09-06 14:53:18 -04002289
2290
2291class GitcClient(RepoClient, GitcManifest):
Gavin Makea2e3302023-03-11 06:46:20 +00002292 """Manages a GitC client checkout."""
Mike Frysinger8c1e9cb2020-09-06 14:53:18 -04002293
Gavin Makea2e3302023-03-11 06:46:20 +00002294 def __init__(self, repodir, gitc_client_name):
2295 """Initialize the GitcManifest object."""
2296 self.gitc_client_name = gitc_client_name
2297 self.gitc_client_dir = os.path.join(
2298 gitc_utils.get_gitc_manifest_dir(), gitc_client_name
2299 )
Mike Frysinger8c1e9cb2020-09-06 14:53:18 -04002300
Gavin Makea2e3302023-03-11 06:46:20 +00002301 super().__init__(
2302 repodir, os.path.join(self.gitc_client_dir, ".manifest")
2303 )
2304 self.isGitcClient = True