2008-10-21 14:00:00 +00:00
|
|
|
# Copyright (C) 2008 The Android Open Source Project
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
2021-05-12 19:00:31 +00:00
|
|
|
import collections
|
2012-04-21 07:33:54 +00:00
|
|
|
import itertools
|
2008-10-21 14:00:00 +00:00
|
|
|
import os
|
2021-03-09 23:19:06 +00:00
|
|
|
import platform
|
2011-09-26 23:34:01 +00:00
|
|
|
import re
|
2008-10-21 14:00:00 +00:00
|
|
|
import sys
|
2013-05-17 01:49:33 +00:00
|
|
|
import xml.dom.minidom
|
2019-06-13 06:24:21 +00:00
|
|
|
import urllib.parse
|
2008-10-21 14:00:00 +00:00
|
|
|
|
2015-08-20 19:19:28 +00:00
|
|
|
import gitc_utils
|
2022-12-13 11:34:23 +00:00
|
|
|
from git_config import GitConfig
|
2012-09-11 05:33:51 +00:00
|
|
|
from git_refs import R_HEADS, HEAD
|
2022-04-07 18:14:46 +00:00
|
|
|
from git_superproject import Superproject
|
2016-11-01 18:24:03 +00:00
|
|
|
import platform_utils
|
2022-03-29 21:54:22 +00:00
|
|
|
from project import (Annotation, RemoteSpec, Project, RepoProject,
|
|
|
|
ManifestProject)
|
2019-08-01 03:32:58 +00:00
|
|
|
from error import (ManifestParseError, ManifestInvalidPathError,
|
|
|
|
ManifestInvalidRevisionError)
|
2021-05-12 19:00:31 +00:00
|
|
|
from wrapper import Wrapper
|
2008-10-21 14:00:00 +00:00
|
|
|
|
|
|
|
MANIFEST_FILE_NAME = 'manifest.xml'
|
2008-10-23 23:19:27 +00:00
|
|
|
LOCAL_MANIFEST_NAME = 'local_manifest.xml'
|
2012-11-12 17:50:36 +00:00
|
|
|
LOCAL_MANIFESTS_DIR_NAME = 'local_manifests'
|
2021-11-18 22:40:18 +00:00
|
|
|
SUBMANIFEST_DIR = 'submanifests'
|
|
|
|
# Limit submanifests to an arbitrary depth for loop detection.
|
|
|
|
MAX_SUBMANIFEST_DEPTH = 8
|
2022-02-25 17:05:21 +00:00
|
|
|
# Add all projects from sub manifest into a group.
|
|
|
|
SUBMANIFEST_GROUP_PREFIX = 'submanifest:'
|
2008-10-21 14:00:00 +00:00
|
|
|
|
2021-06-07 20:27:37 +00:00
|
|
|
# Add all projects from local manifest into a group.
|
|
|
|
LOCAL_MANIFEST_GROUP_PREFIX = 'local:'
|
|
|
|
|
2021-05-12 19:00:31 +00:00
|
|
|
# ContactInfo has the self-registered bug url, supplied by the manifest authors.
|
|
|
|
ContactInfo = collections.namedtuple('ContactInfo', 'bugurl')
|
|
|
|
|
2015-03-28 23:26:04 +00:00
|
|
|
# urljoin gets confused if the scheme is not known.
|
2016-10-27 22:53:53 +00:00
|
|
|
urllib.parse.uses_relative.extend([
|
|
|
|
'ssh',
|
|
|
|
'git',
|
|
|
|
'persistent-https',
|
|
|
|
'sso',
|
|
|
|
'rpc'])
|
|
|
|
urllib.parse.uses_netloc.extend([
|
|
|
|
'ssh',
|
|
|
|
'git',
|
|
|
|
'persistent-https',
|
|
|
|
'sso',
|
|
|
|
'rpc'])
|
2011-09-26 23:34:01 +00:00
|
|
|
|
2020-02-12 06:20:19 +00:00
|
|
|
|
2020-02-22 10:30:12 +00:00
|
|
|
def XmlBool(node, attr, default=None):
|
|
|
|
"""Determine boolean value of |node|'s |attr|.
|
|
|
|
|
|
|
|
Invalid values will issue a non-fatal warning.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
node: XML node whose attributes we access.
|
|
|
|
attr: The attribute to access.
|
|
|
|
default: If the attribute is not set (value is empty), then use this.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
True if the attribute is a valid string representing true.
|
|
|
|
False if the attribute is a valid string representing false.
|
|
|
|
|default| otherwise.
|
|
|
|
"""
|
|
|
|
value = node.getAttribute(attr)
|
|
|
|
s = value.lower()
|
|
|
|
if s == '':
|
|
|
|
return default
|
|
|
|
elif s in {'yes', 'true', '1'}:
|
|
|
|
return True
|
|
|
|
elif s in {'no', 'false', '0'}:
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
print('warning: manifest: %s="%s": ignoring invalid XML boolean' %
|
|
|
|
(attr, value), file=sys.stderr)
|
|
|
|
return default
|
|
|
|
|
|
|
|
|
|
|
|
def XmlInt(node, attr, default=None):
|
|
|
|
"""Determine integer value of |node|'s |attr|.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
node: XML node whose attributes we access.
|
|
|
|
attr: The attribute to access.
|
|
|
|
default: If the attribute is not set (value is empty), then use this.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
The number if the attribute is a valid number.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
ManifestParseError: The number is invalid.
|
|
|
|
"""
|
|
|
|
value = node.getAttribute(attr)
|
|
|
|
if not value:
|
|
|
|
return default
|
|
|
|
|
|
|
|
try:
|
|
|
|
return int(value)
|
|
|
|
except ValueError:
|
|
|
|
raise ManifestParseError('manifest: invalid %s="%s" integer' %
|
|
|
|
(attr, value))
|
|
|
|
|
|
|
|
|
2008-10-21 14:00:00 +00:00
|
|
|
class _Default(object):
|
|
|
|
"""Project defaults within the manifest."""
|
|
|
|
|
2009-05-30 01:38:17 +00:00
|
|
|
revisionExpr = None
|
2013-09-25 22:06:09 +00:00
|
|
|
destBranchExpr = None
|
2018-05-04 18:53:29 +00:00
|
|
|
upstreamExpr = None
|
2008-10-21 14:00:00 +00:00
|
|
|
remote = None
|
sync: rework --jobs to provide better defaults
For --jobs-network, the logic is now:
* If the user specifies --jobs-network, use that.
* Else, if the user specifies --jobs, use that.
* Else, if the manifest specifies sync-j, use that.
* Else, default to 1.
Then we limit the jobs count based on the softlimit RLIMIT_NOFILE.
For --jobs-checkout, the logic is now:
* If the user specifies --jobs-checkout, use that.
* Else, if the user specifies --jobs, use that.
* Else, if the manifest specifies sync-j, use that.
* Else, default to DEFAULT_LOCAL_JOBS which is based on user's ncpus.
Then we limit the jobs count based on the softlimit RLIMIT_NOFILE.
For garbage collecting, the logic is now:
* If the user specifies --jobs, use that.
* Else, if the manifest specifies sync-j, use that.
* Else, default to the user's ncpus.
Then we limit the jobs count based on the softlimit RLIMIT_NOFILE.
Having to factor in the manifest settings makes this more complicated
which is why we delay processing of defaults until after we've synced
the manifest projects.
Bug: http://b/239712300
Change-Id: Id27cda63c76c156f1d63f6a20cb2c4ceeb3d547c
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/341394
Tested-by: Mike Frysinger <vapier@google.com>
Reviewed-by: LaMont Jones <lamontjones@google.com>
2022-07-20 21:15:29 +00:00
|
|
|
sync_j = None
|
2012-04-20 21:41:59 +00:00
|
|
|
sync_c = False
|
Represent git-submodule as nested projects, take 2
(Previous submission of this change broke Android buildbot due to
incorrect regular expression for parsing git-config output. During
investigation, we also found that Android, which pulls Chromium, has a
workaround for Chromium's submodules; its manifest includes Chromium's
submodules. This new change, in addition to fixing the regex, also
take this type of workarounds into consideration; it adds a new
attribute that makes repo not fetch submodules unless submodules have a
project element defined in the manifest, or this attribute is
overridden by a parent project element or by the default element.)
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I4b8344c1b9ccad2f58ad304573133e5d52e1faef
2012-01-11 03:28:42 +00:00
|
|
|
sync_s = False
|
2018-02-14 07:57:31 +00:00
|
|
|
sync_tags = True
|
2008-10-21 14:00:00 +00:00
|
|
|
|
2013-10-09 12:38:46 +00:00
|
|
|
def __eq__(self, other):
|
2021-06-09 15:21:25 +00:00
|
|
|
if not isinstance(other, _Default):
|
|
|
|
return False
|
2013-10-09 12:38:46 +00:00
|
|
|
return self.__dict__ == other.__dict__
|
|
|
|
|
|
|
|
def __ne__(self, other):
|
2021-06-09 15:21:25 +00:00
|
|
|
if not isinstance(other, _Default):
|
|
|
|
return True
|
2013-10-09 12:38:46 +00:00
|
|
|
return self.__dict__ != other.__dict__
|
|
|
|
|
2020-02-12 06:20:19 +00:00
|
|
|
|
2009-05-19 21:58:02 +00:00
|
|
|
class _XmlRemote(object):
|
|
|
|
def __init__(self,
|
|
|
|
name,
|
2012-07-02 14:32:50 +00:00
|
|
|
alias=None,
|
2009-05-19 21:58:02 +00:00
|
|
|
fetch=None,
|
2016-08-10 22:00:00 +00:00
|
|
|
pushUrl=None,
|
2011-09-26 23:34:01 +00:00
|
|
|
manifestUrl=None,
|
2014-05-06 10:54:01 +00:00
|
|
|
review=None,
|
2015-03-17 18:29:58 +00:00
|
|
|
revision=None):
|
2009-05-19 21:58:02 +00:00
|
|
|
self.name = name
|
|
|
|
self.fetchUrl = fetch
|
2016-08-10 22:00:00 +00:00
|
|
|
self.pushUrl = pushUrl
|
2011-09-26 23:34:01 +00:00
|
|
|
self.manifestUrl = manifestUrl
|
2012-07-02 14:32:50 +00:00
|
|
|
self.remoteAlias = alias
|
2009-05-19 21:58:02 +00:00
|
|
|
self.reviewUrl = review
|
2014-05-06 10:54:01 +00:00
|
|
|
self.revision = revision
|
2011-10-20 17:45:47 +00:00
|
|
|
self.resolvedFetchUrl = self._resolveFetchUrl()
|
2021-07-20 20:52:33 +00:00
|
|
|
self.annotations = []
|
2009-05-19 21:58:02 +00:00
|
|
|
|
2012-11-12 23:49:16 +00:00
|
|
|
def __eq__(self, other):
|
2021-06-09 15:21:25 +00:00
|
|
|
if not isinstance(other, _XmlRemote):
|
|
|
|
return False
|
2021-07-20 20:52:33 +00:00
|
|
|
return (sorted(self.annotations) == sorted(other.annotations) and
|
|
|
|
self.name == other.name and self.fetchUrl == other.fetchUrl and
|
|
|
|
self.pushUrl == other.pushUrl and self.remoteAlias == other.remoteAlias
|
|
|
|
and self.reviewUrl == other.reviewUrl and self.revision == other.revision)
|
2012-11-12 23:49:16 +00:00
|
|
|
|
|
|
|
def __ne__(self, other):
|
2021-07-20 20:52:33 +00:00
|
|
|
return not self.__eq__(other)
|
2012-11-12 23:49:16 +00:00
|
|
|
|
2011-10-20 17:45:47 +00:00
|
|
|
def _resolveFetchUrl(self):
|
2021-06-09 15:21:25 +00:00
|
|
|
if self.fetchUrl is None:
|
|
|
|
return ''
|
2011-10-20 17:45:47 +00:00
|
|
|
url = self.fetchUrl.rstrip('/')
|
2011-09-26 23:34:01 +00:00
|
|
|
manifestUrl = self.manifestUrl.rstrip('/')
|
2014-01-31 23:03:51 +00:00
|
|
|
# urljoin will gets confused over quite a few things. The ones we care
|
|
|
|
# about here are:
|
|
|
|
# * no scheme in the base url, like <hostname:port>
|
2015-03-28 23:26:04 +00:00
|
|
|
# We handle no scheme by replacing it with an obscure protocol, gopher
|
|
|
|
# and then replacing it with the original when we are done.
|
|
|
|
|
2011-09-26 23:34:01 +00:00
|
|
|
if manifestUrl.find(':') != manifestUrl.find('/') - 1:
|
2015-04-29 17:45:37 +00:00
|
|
|
url = urllib.parse.urljoin('gopher://' + manifestUrl, url)
|
|
|
|
url = re.sub(r'^gopher://', '', url)
|
2015-03-28 23:26:04 +00:00
|
|
|
else:
|
|
|
|
url = urllib.parse.urljoin(manifestUrl, url)
|
2013-01-02 23:40:48 +00:00
|
|
|
return url
|
2011-10-20 17:45:47 +00:00
|
|
|
|
|
|
|
def ToRemoteSpec(self, projectName):
|
2017-04-05 07:02:59 +00:00
|
|
|
fetchUrl = self.resolvedFetchUrl.rstrip('/')
|
|
|
|
url = fetchUrl + '/' + projectName
|
2012-07-02 14:32:50 +00:00
|
|
|
remoteName = self.name
|
2013-10-09 00:26:57 +00:00
|
|
|
if self.remoteAlias:
|
2013-10-15 01:48:40 +00:00
|
|
|
remoteName = self.remoteAlias
|
2016-04-06 23:03:54 +00:00
|
|
|
return RemoteSpec(remoteName,
|
|
|
|
url=url,
|
2016-08-10 22:00:00 +00:00
|
|
|
pushUrl=self.pushUrl,
|
2016-04-06 23:03:54 +00:00
|
|
|
review=self.reviewUrl,
|
2017-04-05 07:02:59 +00:00
|
|
|
orig_name=self.name,
|
|
|
|
fetchUrl=self.fetchUrl)
|
2008-10-21 14:00:00 +00:00
|
|
|
|
2021-07-20 20:52:33 +00:00
|
|
|
def AddAnnotation(self, name, value, keep):
|
|
|
|
self.annotations.append(Annotation(name, value, keep))
|
|
|
|
|
2020-02-12 06:20:19 +00:00
|
|
|
|
2021-11-18 22:40:18 +00:00
|
|
|
class _XmlSubmanifest:
|
|
|
|
"""Manage the <submanifest> element specified in the manifest.
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
name: a string, the name for this submanifest.
|
|
|
|
remote: a string, the remote.name for this submanifest.
|
|
|
|
project: a string, the name of the manifest project.
|
|
|
|
revision: a string, the commitish.
|
|
|
|
manifestName: a string, the submanifest file name.
|
|
|
|
groups: a list of strings, the groups to add to all projects in the submanifest.
|
2022-04-20 16:42:32 +00:00
|
|
|
default_groups: a list of strings, the default groups to sync.
|
2021-11-18 22:40:18 +00:00
|
|
|
path: a string, the relative path for the submanifest checkout.
|
2022-04-14 15:00:09 +00:00
|
|
|
parent: an XmlManifest, the parent manifest.
|
2021-11-18 22:40:18 +00:00
|
|
|
annotations: (derived) a list of annotations.
|
2022-04-14 15:00:09 +00:00
|
|
|
present: (derived) a boolean, whether the sub manifest file is present.
|
2021-11-18 22:40:18 +00:00
|
|
|
"""
|
|
|
|
def __init__(self,
|
|
|
|
name,
|
|
|
|
remote=None,
|
|
|
|
project=None,
|
|
|
|
revision=None,
|
|
|
|
manifestName=None,
|
|
|
|
groups=None,
|
2022-04-20 16:42:32 +00:00
|
|
|
default_groups=None,
|
2021-11-18 22:40:18 +00:00
|
|
|
path=None,
|
|
|
|
parent=None):
|
|
|
|
self.name = name
|
|
|
|
self.remote = remote
|
|
|
|
self.project = project
|
|
|
|
self.revision = revision
|
|
|
|
self.manifestName = manifestName
|
|
|
|
self.groups = groups
|
2022-04-20 16:42:32 +00:00
|
|
|
self.default_groups = default_groups
|
2021-11-18 22:40:18 +00:00
|
|
|
self.path = path
|
2022-04-14 15:00:09 +00:00
|
|
|
self.parent = parent
|
2021-11-18 22:40:18 +00:00
|
|
|
self.annotations = []
|
|
|
|
outer_client = parent._outer_client or parent
|
|
|
|
if self.remote and not self.project:
|
|
|
|
raise ManifestParseError(
|
|
|
|
f'Submanifest {name}: must specify project when remote is given.')
|
2022-03-23 19:03:02 +00:00
|
|
|
# Construct the absolute path to the manifest file using the parent's
|
|
|
|
# method, so that we can correctly create our repo_client.
|
|
|
|
manifestFile = parent.SubmanifestInfoDir(
|
|
|
|
os.path.join(parent.path_prefix, self.relpath),
|
|
|
|
os.path.join('manifests', manifestName or 'default.xml'))
|
2022-04-06 17:10:21 +00:00
|
|
|
linkFile = parent.SubmanifestInfoDir(
|
|
|
|
os.path.join(parent.path_prefix, self.relpath), MANIFEST_FILE_NAME)
|
2021-11-18 22:40:18 +00:00
|
|
|
rc = self.repo_client = RepoClient(
|
2022-04-06 17:10:21 +00:00
|
|
|
parent.repodir, linkFile, parent_groups=','.join(groups) or '',
|
2022-04-20 16:42:32 +00:00
|
|
|
submanifest_path=self.relpath, outer_client=outer_client,
|
|
|
|
default_groups=default_groups)
|
2021-11-18 22:40:18 +00:00
|
|
|
|
2022-04-06 17:10:21 +00:00
|
|
|
self.present = os.path.exists(manifestFile)
|
2021-11-18 22:40:18 +00:00
|
|
|
|
|
|
|
def __eq__(self, other):
|
|
|
|
if not isinstance(other, _XmlSubmanifest):
|
|
|
|
return False
|
|
|
|
return (
|
|
|
|
self.name == other.name and
|
|
|
|
self.remote == other.remote and
|
|
|
|
self.project == other.project and
|
|
|
|
self.revision == other.revision and
|
|
|
|
self.manifestName == other.manifestName and
|
|
|
|
self.groups == other.groups and
|
2022-04-20 16:42:32 +00:00
|
|
|
self.default_groups == other.default_groups and
|
2021-11-18 22:40:18 +00:00
|
|
|
self.path == other.path and
|
|
|
|
sorted(self.annotations) == sorted(other.annotations))
|
|
|
|
|
|
|
|
def __ne__(self, other):
|
|
|
|
return not self.__eq__(other)
|
|
|
|
|
2022-04-14 15:00:09 +00:00
|
|
|
def ToSubmanifestSpec(self):
|
2021-11-18 22:40:18 +00:00
|
|
|
"""Return a SubmanifestSpec object, populating attributes"""
|
2022-04-14 15:00:09 +00:00
|
|
|
mp = self.parent.manifestProject
|
|
|
|
remote = self.parent.remotes[self.remote or self.parent.default.remote.name]
|
2021-11-18 22:40:18 +00:00
|
|
|
# If a project was given, generate the url from the remote and project.
|
|
|
|
# If not, use this manifestProject's url.
|
|
|
|
if self.project:
|
|
|
|
manifestUrl = remote.ToRemoteSpec(self.project).url
|
|
|
|
else:
|
2022-07-10 08:56:04 +00:00
|
|
|
manifestUrl = mp.GetRemote().url
|
2021-11-18 22:40:18 +00:00
|
|
|
manifestName = self.manifestName or 'default.xml'
|
|
|
|
revision = self.revision or self.name
|
|
|
|
path = self.path or revision.split('/')[-1]
|
|
|
|
groups = self.groups or []
|
2022-04-20 16:42:32 +00:00
|
|
|
default_groups = self.default_groups or []
|
2021-11-18 22:40:18 +00:00
|
|
|
|
|
|
|
return SubmanifestSpec(self.name, manifestUrl, manifestName, revision, path,
|
|
|
|
groups)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def relpath(self):
|
|
|
|
"""The path of this submanifest relative to the parent manifest."""
|
|
|
|
revision = self.revision or self.name
|
|
|
|
return self.path or revision.split('/')[-1]
|
|
|
|
|
|
|
|
def GetGroupsStr(self):
|
|
|
|
"""Returns the `groups` given for this submanifest."""
|
|
|
|
if self.groups:
|
|
|
|
return ','.join(self.groups)
|
|
|
|
return ''
|
|
|
|
|
2022-04-20 16:42:32 +00:00
|
|
|
def GetDefaultGroupsStr(self):
|
|
|
|
"""Returns the `default-groups` given for this submanifest."""
|
|
|
|
return ','.join(self.default_groups or [])
|
|
|
|
|
2021-11-18 22:40:18 +00:00
|
|
|
def AddAnnotation(self, name, value, keep):
|
|
|
|
"""Add annotations to the submanifest."""
|
|
|
|
self.annotations.append(Annotation(name, value, keep))
|
|
|
|
|
|
|
|
|
|
|
|
class SubmanifestSpec:
|
|
|
|
"""The submanifest element, with all fields expanded."""
|
|
|
|
|
|
|
|
def __init__(self,
|
|
|
|
name,
|
|
|
|
manifestUrl,
|
|
|
|
manifestName,
|
|
|
|
revision,
|
|
|
|
path,
|
|
|
|
groups):
|
|
|
|
self.name = name
|
|
|
|
self.manifestUrl = manifestUrl
|
|
|
|
self.manifestName = manifestName
|
|
|
|
self.revision = revision
|
|
|
|
self.path = path
|
|
|
|
self.groups = groups or []
|
|
|
|
|
|
|
|
|
2009-05-18 20:19:57 +00:00
|
|
|
class XmlManifest(object):
|
2008-10-21 14:00:00 +00:00
|
|
|
"""manages the repo configuration file"""
|
|
|
|
|
2021-11-18 22:40:18 +00:00
|
|
|
def __init__(self, repodir, manifest_file, local_manifests=None,
|
2022-04-20 16:42:32 +00:00
|
|
|
outer_client=None, parent_groups='', submanifest_path='',
|
|
|
|
default_groups=None):
|
2020-09-06 18:53:18 +00:00
|
|
|
"""Initialize.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
repodir: Path to the .repo/ dir for holding all internal checkout state.
|
|
|
|
It must be in the top directory of the repo client checkout.
|
|
|
|
manifest_file: Full path to the manifest file to parse. This will usually
|
|
|
|
be |repodir|/|MANIFEST_FILE_NAME|.
|
|
|
|
local_manifests: Full path to the directory of local override manifests.
|
|
|
|
This will usually be |repodir|/|LOCAL_MANIFESTS_DIR_NAME|.
|
2022-06-01 21:03:34 +00:00
|
|
|
outer_client: RepoClient of the outer manifest.
|
2021-11-18 22:40:18 +00:00
|
|
|
parent_groups: a string, the groups to apply to this projects.
|
|
|
|
submanifest_path: The submanifest root relative to the repo root.
|
2022-04-20 16:42:32 +00:00
|
|
|
default_groups: a string, the default manifest groups to use.
|
2020-09-06 18:53:18 +00:00
|
|
|
"""
|
|
|
|
# TODO(vapier): Move this out of this class.
|
|
|
|
self.globalConfig = GitConfig.ForUser()
|
|
|
|
|
2008-10-21 14:00:00 +00:00
|
|
|
self.repodir = os.path.abspath(repodir)
|
2021-11-18 22:40:18 +00:00
|
|
|
self._CheckLocalPath(submanifest_path)
|
2022-08-22 19:26:14 +00:00
|
|
|
self.topdir = os.path.dirname(self.repodir)
|
|
|
|
if submanifest_path:
|
|
|
|
# This avoids a trailing os.path.sep when submanifest_path is empty.
|
|
|
|
self.topdir = os.path.join(self.topdir, submanifest_path)
|
2022-03-23 19:03:02 +00:00
|
|
|
if manifest_file != os.path.abspath(manifest_file):
|
|
|
|
raise ManifestParseError('manifest_file must be abspath')
|
2020-09-06 18:53:18 +00:00
|
|
|
self.manifestFile = manifest_file
|
2022-04-14 15:00:09 +00:00
|
|
|
if not outer_client or outer_client == self:
|
|
|
|
# manifestFileOverrides only exists in the outer_client's manifest, since
|
|
|
|
# that is the only instance left when Unload() is called on the outer
|
|
|
|
# manifest.
|
|
|
|
self.manifestFileOverrides = {}
|
2020-09-06 18:53:18 +00:00
|
|
|
self.local_manifests = local_manifests
|
2018-05-25 17:23:52 +00:00
|
|
|
self._load_local_manifests = True
|
2021-11-18 22:40:18 +00:00
|
|
|
self.parent_groups = parent_groups
|
2022-04-20 16:42:32 +00:00
|
|
|
self.default_groups = default_groups
|
2021-11-18 22:40:18 +00:00
|
|
|
|
|
|
|
if outer_client and self.isGitcClient:
|
|
|
|
raise ManifestParseError('Multi-manifest is incompatible with `gitc-init`')
|
|
|
|
|
|
|
|
if submanifest_path and not outer_client:
|
|
|
|
# If passing a submanifest_path, there must be an outer_client.
|
|
|
|
raise ManifestParseError(f'Bad call to {self.__class__.__name__}')
|
|
|
|
|
|
|
|
# If self._outer_client is None, this is not a checkout that supports
|
|
|
|
# multi-tree.
|
|
|
|
self._outer_client = outer_client or self
|
2008-10-21 14:00:00 +00:00
|
|
|
|
2022-03-29 21:54:22 +00:00
|
|
|
self.repoProject = RepoProject(self, 'repo',
|
2020-02-12 05:58:39 +00:00
|
|
|
gitdir=os.path.join(repodir, 'repo/.git'),
|
|
|
|
worktree=os.path.join(repodir, 'repo'))
|
2008-10-21 14:00:00 +00:00
|
|
|
|
2021-11-18 22:40:18 +00:00
|
|
|
mp = self.SubmanifestProject(self.path_prefix)
|
2020-02-09 07:28:34 +00:00
|
|
|
self.manifestProject = mp
|
|
|
|
|
|
|
|
# This is a bit hacky, but we're in a chicken & egg situation: all the
|
|
|
|
# normal repo settings live in the manifestProject which we just setup
|
|
|
|
# above, so we couldn't easily query before that. We assume Project()
|
|
|
|
# init doesn't care if this changes afterwards.
|
2022-04-05 19:30:46 +00:00
|
|
|
if os.path.exists(mp.gitdir) and mp.use_worktree:
|
2020-02-09 07:28:34 +00:00
|
|
|
mp.use_git_worktrees = True
|
2008-10-21 14:00:00 +00:00
|
|
|
|
2022-04-07 16:49:06 +00:00
|
|
|
self.Unload()
|
2008-10-21 14:00:00 +00:00
|
|
|
|
2018-05-25 17:23:52 +00:00
|
|
|
def Override(self, name, load_local_manifests=True):
|
2010-04-06 17:40:01 +00:00
|
|
|
"""Use a different manifest, just for the current instantiation.
|
2008-10-21 14:00:00 +00:00
|
|
|
"""
|
2018-05-25 17:23:52 +00:00
|
|
|
path = None
|
|
|
|
|
|
|
|
# Look for a manifest by path in the filesystem (including the cwd).
|
|
|
|
if not load_local_manifests:
|
|
|
|
local_path = os.path.abspath(name)
|
|
|
|
if os.path.isfile(local_path):
|
|
|
|
path = local_path
|
|
|
|
|
|
|
|
# Look for manifests by name from the manifests repo.
|
|
|
|
if path is None:
|
|
|
|
path = os.path.join(self.manifestProject.worktree, name)
|
|
|
|
if not os.path.isfile(path):
|
|
|
|
raise ManifestParseError('manifest %s not found' % name)
|
2008-10-21 14:00:00 +00:00
|
|
|
|
2022-04-14 15:00:09 +00:00
|
|
|
self._load_local_manifests = load_local_manifests
|
|
|
|
self._outer_client.manifestFileOverrides[self.path_prefix] = path
|
|
|
|
self.Unload()
|
|
|
|
self._Load()
|
2008-10-21 14:00:00 +00:00
|
|
|
|
2010-04-06 17:40:01 +00:00
|
|
|
def Link(self, name):
|
|
|
|
"""Update the repo metadata to use a different manifest.
|
|
|
|
"""
|
|
|
|
self.Override(name)
|
|
|
|
|
2020-02-21 05:49:41 +00:00
|
|
|
# Old versions of repo would generate symlinks we need to clean up.
|
2021-09-28 15:27:24 +00:00
|
|
|
platform_utils.remove(self.manifestFile, missing_ok=True)
|
2020-02-21 05:49:41 +00:00
|
|
|
# This file is interpreted as if it existed inside the manifest repo.
|
|
|
|
# That allows us to use <include> with the relative file name.
|
|
|
|
with open(self.manifestFile, 'w') as fp:
|
|
|
|
fp.write("""<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<!--
|
|
|
|
DO NOT EDIT THIS FILE! It is generated by repo and changes will be discarded.
|
|
|
|
If you want to use a different manifest, use `repo init -m <file>` instead.
|
|
|
|
|
|
|
|
If you want to customize your checkout by overriding manifest settings, use
|
|
|
|
the local_manifests/ directory instead.
|
|
|
|
|
|
|
|
For more information on repo manifests, check out:
|
|
|
|
https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
|
|
|
|
-->
|
|
|
|
<manifest>
|
|
|
|
<include name="%s" />
|
|
|
|
</manifest>
|
|
|
|
""" % (name,))
|
2008-10-21 14:00:00 +00:00
|
|
|
|
2009-03-05 18:32:38 +00:00
|
|
|
def _RemoteToXml(self, r, doc, root):
|
|
|
|
e = doc.createElement('remote')
|
|
|
|
root.appendChild(e)
|
|
|
|
e.setAttribute('name', r.name)
|
|
|
|
e.setAttribute('fetch', r.fetchUrl)
|
2016-08-10 22:00:00 +00:00
|
|
|
if r.pushUrl is not None:
|
|
|
|
e.setAttribute('pushurl', r.pushUrl)
|
2013-10-09 00:26:57 +00:00
|
|
|
if r.remoteAlias is not None:
|
|
|
|
e.setAttribute('alias', r.remoteAlias)
|
2009-03-05 18:32:38 +00:00
|
|
|
if r.reviewUrl is not None:
|
|
|
|
e.setAttribute('review', r.reviewUrl)
|
2014-05-06 10:54:01 +00:00
|
|
|
if r.revision is not None:
|
|
|
|
e.setAttribute('revision', r.revision)
|
2009-03-05 18:32:38 +00:00
|
|
|
|
2021-07-20 20:52:33 +00:00
|
|
|
for a in r.annotations:
|
|
|
|
if a.keep == 'true':
|
|
|
|
ae = doc.createElement('annotation')
|
|
|
|
ae.setAttribute('name', a.name)
|
|
|
|
ae.setAttribute('value', a.value)
|
|
|
|
e.appendChild(ae)
|
|
|
|
|
2021-11-18 22:40:18 +00:00
|
|
|
def _SubmanifestToXml(self, r, doc, root):
|
|
|
|
"""Generate XML <submanifest/> node."""
|
|
|
|
e = doc.createElement('submanifest')
|
|
|
|
root.appendChild(e)
|
|
|
|
e.setAttribute('name', r.name)
|
|
|
|
if r.remote is not None:
|
|
|
|
e.setAttribute('remote', r.remote)
|
|
|
|
if r.project is not None:
|
|
|
|
e.setAttribute('project', r.project)
|
|
|
|
if r.manifestName is not None:
|
|
|
|
e.setAttribute('manifest-name', r.manifestName)
|
|
|
|
if r.revision is not None:
|
|
|
|
e.setAttribute('revision', r.revision)
|
|
|
|
if r.path is not None:
|
|
|
|
e.setAttribute('path', r.path)
|
|
|
|
if r.groups:
|
|
|
|
e.setAttribute('groups', r.GetGroupsStr())
|
2022-04-20 16:42:32 +00:00
|
|
|
if r.default_groups:
|
|
|
|
e.setAttribute('default-groups', r.GetDefaultGroupsStr())
|
2021-11-18 22:40:18 +00:00
|
|
|
|
|
|
|
for a in r.annotations:
|
|
|
|
if a.keep == 'true':
|
|
|
|
ae = doc.createElement('annotation')
|
|
|
|
ae.setAttribute('name', a.name)
|
|
|
|
ae.setAttribute('value', a.value)
|
|
|
|
e.appendChild(ae)
|
|
|
|
|
2020-12-04 10:32:06 +00:00
|
|
|
def _ParseList(self, field):
|
|
|
|
"""Parse fields that contain flattened lists.
|
|
|
|
|
|
|
|
These are whitespace & comma separated. Empty elements will be discarded.
|
|
|
|
"""
|
|
|
|
return [x for x in re.split(r'[,\s]+', field) if x]
|
2014-06-12 21:57:29 +00:00
|
|
|
|
2022-07-15 20:31:33 +00:00
|
|
|
def ToXml(self, peg_rev=False, peg_rev_upstream=True,
|
|
|
|
peg_rev_dest_branch=True, groups=None, omit_local=False):
|
2020-09-02 08:31:10 +00:00
|
|
|
"""Return the current manifest XML."""
|
2012-03-29 03:15:45 +00:00
|
|
|
mp = self.manifestProject
|
|
|
|
|
2015-09-08 20:27:20 +00:00
|
|
|
if groups is None:
|
2022-04-05 19:30:46 +00:00
|
|
|
groups = mp.manifest_groups
|
Make -notdefault a default manifest group
When trying to render manifest with SHAs, projects in group notdefault
caused the following crash:
Traceback (most recent call last):
File ".repo/repo/main.py", line 385, in <module>
_Main(sys.argv[1:])
File ".repo/repo/main.py", line 365, in _Main
result = repo._Run(argv) or 0
File ".repo/repo/main.py", line 137, in _Run
result = cmd.Execute(copts, cargs)
File ".repo/repo/subcmds/manifest.py", line 129, in Execute
self._Output(opt, manifest)
File ".repo/repo/subcmds/manifest.py", line 79, in _Output
peg_rev = opt.peg_rev)
File ".repo/repo/manifest_xml.py", line 199, in Save
p.work_git.rev_parse(HEAD + '^0'))
File ".repo/repo/project.py", line 2035, in runner
capture_stderr = True)
File ".repo/repo/git_command.py", line 215, in __init__
raise GitError('%s: %s' % (command[1], e))
error.GitError: rev-parse: [Errno 2] No such file or directory: 'prebuilts/eclipse-build-deps'
This patch resolves the issue by making sure that -notdefault is always
used as a default manifest group so that notdefault projects are not
rendered out by the manifest subcmd.
Change-Id: I4a8bd18ea7600309f39ceff1b1ab6e1ff3adf21d
Signed-off-by: Matt Gumbel <matthew.k.gumbel@intel.com>
2012-12-21 18:14:53 +00:00
|
|
|
if groups:
|
2020-12-04 10:32:06 +00:00
|
|
|
groups = self._ParseList(groups)
|
2012-03-29 03:15:45 +00:00
|
|
|
|
2009-03-05 18:32:38 +00:00
|
|
|
doc = xml.dom.minidom.Document()
|
|
|
|
root = doc.createElement('manifest')
|
2021-11-18 22:40:18 +00:00
|
|
|
if self.is_submanifest:
|
|
|
|
root.setAttribute('path', self.path_prefix)
|
2009-03-05 18:32:38 +00:00
|
|
|
doc.appendChild(root)
|
|
|
|
|
2010-11-01 22:08:06 +00:00
|
|
|
# Save out the notice. There's a little bit of work here to give it the
|
|
|
|
# right whitespace, which assumes that the notice is automatically indented
|
|
|
|
# by 4 by minidom.
|
|
|
|
if self.notice:
|
|
|
|
notice_element = root.appendChild(doc.createElement('notice'))
|
|
|
|
notice_lines = self.notice.splitlines()
|
2020-02-12 05:31:05 +00:00
|
|
|
indented_notice = ('\n'.join(" " * 4 + line for line in notice_lines))[4:]
|
2010-11-01 22:08:06 +00:00
|
|
|
notice_element.appendChild(doc.createTextNode(indented_notice))
|
|
|
|
|
2009-03-05 18:32:38 +00:00
|
|
|
d = self.default
|
|
|
|
|
2013-03-01 13:44:38 +00:00
|
|
|
for r in sorted(self.remotes):
|
2009-03-05 18:32:38 +00:00
|
|
|
self._RemoteToXml(self.remotes[r], doc, root)
|
|
|
|
if self.remotes:
|
|
|
|
root.appendChild(doc.createTextNode(''))
|
|
|
|
|
|
|
|
have_default = False
|
|
|
|
e = doc.createElement('default')
|
|
|
|
if d.remote:
|
|
|
|
have_default = True
|
|
|
|
e.setAttribute('remote', d.remote.name)
|
2009-05-30 01:38:17 +00:00
|
|
|
if d.revisionExpr:
|
2009-03-05 18:32:38 +00:00
|
|
|
have_default = True
|
2009-05-30 01:38:17 +00:00
|
|
|
e.setAttribute('revision', d.revisionExpr)
|
2015-07-24 10:50:06 +00:00
|
|
|
if d.destBranchExpr:
|
|
|
|
have_default = True
|
|
|
|
e.setAttribute('dest-branch', d.destBranchExpr)
|
2018-05-04 18:53:29 +00:00
|
|
|
if d.upstreamExpr:
|
|
|
|
have_default = True
|
|
|
|
e.setAttribute('upstream', d.upstreamExpr)
|
sync: rework --jobs to provide better defaults
For --jobs-network, the logic is now:
* If the user specifies --jobs-network, use that.
* Else, if the user specifies --jobs, use that.
* Else, if the manifest specifies sync-j, use that.
* Else, default to 1.
Then we limit the jobs count based on the softlimit RLIMIT_NOFILE.
For --jobs-checkout, the logic is now:
* If the user specifies --jobs-checkout, use that.
* Else, if the user specifies --jobs, use that.
* Else, if the manifest specifies sync-j, use that.
* Else, default to DEFAULT_LOCAL_JOBS which is based on user's ncpus.
Then we limit the jobs count based on the softlimit RLIMIT_NOFILE.
For garbage collecting, the logic is now:
* If the user specifies --jobs, use that.
* Else, if the manifest specifies sync-j, use that.
* Else, default to the user's ncpus.
Then we limit the jobs count based on the softlimit RLIMIT_NOFILE.
Having to factor in the manifest settings makes this more complicated
which is why we delay processing of defaults until after we've synced
the manifest projects.
Bug: http://b/239712300
Change-Id: Id27cda63c76c156f1d63f6a20cb2c4ceeb3d547c
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/341394
Tested-by: Mike Frysinger <vapier@google.com>
Reviewed-by: LaMont Jones <lamontjones@google.com>
2022-07-20 21:15:29 +00:00
|
|
|
if d.sync_j is not None:
|
2011-09-23 00:44:31 +00:00
|
|
|
have_default = True
|
|
|
|
e.setAttribute('sync-j', '%d' % d.sync_j)
|
2012-04-20 21:41:59 +00:00
|
|
|
if d.sync_c:
|
|
|
|
have_default = True
|
|
|
|
e.setAttribute('sync-c', 'true')
|
Represent git-submodule as nested projects, take 2
(Previous submission of this change broke Android buildbot due to
incorrect regular expression for parsing git-config output. During
investigation, we also found that Android, which pulls Chromium, has a
workaround for Chromium's submodules; its manifest includes Chromium's
submodules. This new change, in addition to fixing the regex, also
take this type of workarounds into consideration; it adds a new
attribute that makes repo not fetch submodules unless submodules have a
project element defined in the manifest, or this attribute is
overridden by a parent project element or by the default element.)
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I4b8344c1b9ccad2f58ad304573133e5d52e1faef
2012-01-11 03:28:42 +00:00
|
|
|
if d.sync_s:
|
|
|
|
have_default = True
|
|
|
|
e.setAttribute('sync-s', 'true')
|
2018-02-14 07:57:31 +00:00
|
|
|
if not d.sync_tags:
|
|
|
|
have_default = True
|
|
|
|
e.setAttribute('sync-tags', 'false')
|
2009-03-05 18:32:38 +00:00
|
|
|
if have_default:
|
|
|
|
root.appendChild(e)
|
|
|
|
root.appendChild(doc.createTextNode(''))
|
|
|
|
|
2010-04-06 17:40:01 +00:00
|
|
|
if self._manifest_server:
|
|
|
|
e = doc.createElement('manifest-server')
|
|
|
|
e.setAttribute('url', self._manifest_server)
|
|
|
|
root.appendChild(e)
|
|
|
|
root.appendChild(doc.createTextNode(''))
|
|
|
|
|
2021-11-18 22:40:18 +00:00
|
|
|
for r in sorted(self.submanifests):
|
|
|
|
self._SubmanifestToXml(self.submanifests[r], doc, root)
|
|
|
|
if self.submanifests:
|
|
|
|
root.appendChild(doc.createTextNode(''))
|
|
|
|
|
Represent git-submodule as nested projects, take 2
(Previous submission of this change broke Android buildbot due to
incorrect regular expression for parsing git-config output. During
investigation, we also found that Android, which pulls Chromium, has a
workaround for Chromium's submodules; its manifest includes Chromium's
submodules. This new change, in addition to fixing the regex, also
take this type of workarounds into consideration; it adds a new
attribute that makes repo not fetch submodules unless submodules have a
project element defined in the manifest, or this attribute is
overridden by a parent project element or by the default element.)
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I4b8344c1b9ccad2f58ad304573133e5d52e1faef
2012-01-11 03:28:42 +00:00
|
|
|
def output_projects(parent, parent_node, projects):
|
2013-10-12 00:03:19 +00:00
|
|
|
for project_name in projects:
|
|
|
|
for project in self._projects[project_name]:
|
|
|
|
output_project(parent, parent_node, project)
|
Represent git-submodule as nested projects
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I541e9e2ac1a70304272dbe09724572aa1004eb5c
2012-01-11 03:28:42 +00:00
|
|
|
|
Represent git-submodule as nested projects, take 2
(Previous submission of this change broke Android buildbot due to
incorrect regular expression for parsing git-config output. During
investigation, we also found that Android, which pulls Chromium, has a
workaround for Chromium's submodules; its manifest includes Chromium's
submodules. This new change, in addition to fixing the regex, also
take this type of workarounds into consideration; it adds a new
attribute that makes repo not fetch submodules unless submodules have a
project element defined in the manifest, or this attribute is
overridden by a parent project element or by the default element.)
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I4b8344c1b9ccad2f58ad304573133e5d52e1faef
2012-01-11 03:28:42 +00:00
|
|
|
def output_project(parent, parent_node, p):
|
2012-10-26 19:18:00 +00:00
|
|
|
if not p.MatchesGroups(groups):
|
Represent git-submodule as nested projects, take 2
(Previous submission of this change broke Android buildbot due to
incorrect regular expression for parsing git-config output. During
investigation, we also found that Android, which pulls Chromium, has a
workaround for Chromium's submodules; its manifest includes Chromium's
submodules. This new change, in addition to fixing the regex, also
take this type of workarounds into consideration; it adds a new
attribute that makes repo not fetch submodules unless submodules have a
project element defined in the manifest, or this attribute is
overridden by a parent project element or by the default element.)
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I4b8344c1b9ccad2f58ad304573133e5d52e1faef
2012-01-11 03:28:42 +00:00
|
|
|
return
|
|
|
|
|
2022-07-15 20:31:33 +00:00
|
|
|
if omit_local and self.IsFromLocalManifest(p):
|
|
|
|
return
|
|
|
|
|
Represent git-submodule as nested projects, take 2
(Previous submission of this change broke Android buildbot due to
incorrect regular expression for parsing git-config output. During
investigation, we also found that Android, which pulls Chromium, has a
workaround for Chromium's submodules; its manifest includes Chromium's
submodules. This new change, in addition to fixing the regex, also
take this type of workarounds into consideration; it adds a new
attribute that makes repo not fetch submodules unless submodules have a
project element defined in the manifest, or this attribute is
overridden by a parent project element or by the default element.)
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I4b8344c1b9ccad2f58ad304573133e5d52e1faef
2012-01-11 03:28:42 +00:00
|
|
|
name = p.name
|
|
|
|
relpath = p.relpath
|
|
|
|
if parent:
|
|
|
|
name = self._UnjoinName(parent.name, name)
|
|
|
|
relpath = self._UnjoinRelpath(parent.relpath, relpath)
|
2012-03-29 03:15:45 +00:00
|
|
|
|
2009-03-05 18:32:38 +00:00
|
|
|
e = doc.createElement('project')
|
Represent git-submodule as nested projects, take 2
(Previous submission of this change broke Android buildbot due to
incorrect regular expression for parsing git-config output. During
investigation, we also found that Android, which pulls Chromium, has a
workaround for Chromium's submodules; its manifest includes Chromium's
submodules. This new change, in addition to fixing the regex, also
take this type of workarounds into consideration; it adds a new
attribute that makes repo not fetch submodules unless submodules have a
project element defined in the manifest, or this attribute is
overridden by a parent project element or by the default element.)
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I4b8344c1b9ccad2f58ad304573133e5d52e1faef
2012-01-11 03:28:42 +00:00
|
|
|
parent_node.appendChild(e)
|
|
|
|
e.setAttribute('name', name)
|
|
|
|
if relpath != name:
|
|
|
|
e.setAttribute('path', relpath)
|
2013-10-16 21:38:09 +00:00
|
|
|
remoteName = None
|
|
|
|
if d.remote:
|
2016-04-06 23:03:54 +00:00
|
|
|
remoteName = d.remote.name
|
|
|
|
if not d.remote or p.remote.orig_name != remoteName:
|
|
|
|
remoteName = p.remote.orig_name
|
2014-05-06 10:54:01 +00:00
|
|
|
e.setAttribute('remote', remoteName)
|
2009-03-05 18:32:38 +00:00
|
|
|
if peg_rev:
|
|
|
|
if self.IsMirror:
|
2012-09-29 03:21:57 +00:00
|
|
|
value = p.bare_git.rev_parse(p.revisionExpr + '^0')
|
2009-03-05 18:32:38 +00:00
|
|
|
else:
|
2012-09-29 03:21:57 +00:00
|
|
|
value = p.work_git.rev_parse(HEAD + '^0')
|
|
|
|
e.setAttribute('revision', value)
|
2015-07-10 21:54:54 +00:00
|
|
|
if peg_rev_upstream:
|
|
|
|
if p.upstream:
|
|
|
|
e.setAttribute('upstream', p.upstream)
|
|
|
|
elif value != p.revisionExpr:
|
|
|
|
# Only save the origin if the origin is not a sha1, and the default
|
|
|
|
# isn't our value
|
|
|
|
e.setAttribute('upstream', p.revisionExpr)
|
2020-04-20 14:41:58 +00:00
|
|
|
|
|
|
|
if peg_rev_dest_branch:
|
|
|
|
if p.dest_branch:
|
|
|
|
e.setAttribute('dest-branch', p.dest_branch)
|
|
|
|
elif value != p.revisionExpr:
|
|
|
|
e.setAttribute('dest-branch', p.revisionExpr)
|
|
|
|
|
2014-05-06 10:54:01 +00:00
|
|
|
else:
|
2016-04-06 23:03:54 +00:00
|
|
|
revision = self.remotes[p.remote.orig_name].revision or d.revisionExpr
|
2014-05-06 10:54:01 +00:00
|
|
|
if not revision or revision != p.revisionExpr:
|
|
|
|
e.setAttribute('revision', p.revisionExpr)
|
2021-02-06 17:44:15 +00:00
|
|
|
elif p.revisionId:
|
|
|
|
e.setAttribute('revision', p.revisionId)
|
2018-05-04 18:53:29 +00:00
|
|
|
if (p.upstream and (p.upstream != p.revisionExpr or
|
|
|
|
p.upstream != d.upstreamExpr)):
|
2014-07-24 10:57:08 +00:00
|
|
|
e.setAttribute('upstream', p.upstream)
|
2009-03-05 18:32:38 +00:00
|
|
|
|
2015-07-24 10:50:06 +00:00
|
|
|
if p.dest_branch and p.dest_branch != d.destBranchExpr:
|
|
|
|
e.setAttribute('dest-branch', p.dest_branch)
|
|
|
|
|
2009-03-05 18:32:38 +00:00
|
|
|
for c in p.copyfiles:
|
|
|
|
ce = doc.createElement('copyfile')
|
|
|
|
ce.setAttribute('src', c.src)
|
|
|
|
ce.setAttribute('dest', c.dest)
|
|
|
|
e.appendChild(ce)
|
|
|
|
|
2014-04-21 22:10:59 +00:00
|
|
|
for l in p.linkfiles:
|
|
|
|
le = doc.createElement('linkfile')
|
|
|
|
le.setAttribute('src', l.src)
|
|
|
|
le.setAttribute('dest', l.dest)
|
|
|
|
e.appendChild(le)
|
|
|
|
|
2012-08-13 20:11:18 +00:00
|
|
|
default_groups = ['all', 'name:%s' % p.name, 'path:%s' % p.relpath]
|
2012-08-06 21:52:29 +00:00
|
|
|
egroups = [g for g in p.groups if g not in default_groups]
|
2012-04-16 17:36:08 +00:00
|
|
|
if egroups:
|
|
|
|
e.setAttribute('groups', ','.join(egroups))
|
2012-03-29 03:15:45 +00:00
|
|
|
|
2012-04-12 20:04:13 +00:00
|
|
|
for a in p.annotations:
|
|
|
|
if a.keep == "true":
|
|
|
|
ae = doc.createElement('annotation')
|
|
|
|
ae.setAttribute('name', a.name)
|
|
|
|
ae.setAttribute('value', a.value)
|
|
|
|
e.appendChild(ae)
|
|
|
|
|
2012-04-20 21:41:59 +00:00
|
|
|
if p.sync_c:
|
|
|
|
e.setAttribute('sync-c', 'true')
|
|
|
|
|
Represent git-submodule as nested projects, take 2
(Previous submission of this change broke Android buildbot due to
incorrect regular expression for parsing git-config output. During
investigation, we also found that Android, which pulls Chromium, has a
workaround for Chromium's submodules; its manifest includes Chromium's
submodules. This new change, in addition to fixing the regex, also
take this type of workarounds into consideration; it adds a new
attribute that makes repo not fetch submodules unless submodules have a
project element defined in the manifest, or this attribute is
overridden by a parent project element or by the default element.)
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I4b8344c1b9ccad2f58ad304573133e5d52e1faef
2012-01-11 03:28:42 +00:00
|
|
|
if p.sync_s:
|
|
|
|
e.setAttribute('sync-s', 'true')
|
|
|
|
|
2018-02-14 07:57:31 +00:00
|
|
|
if not p.sync_tags:
|
|
|
|
e.setAttribute('sync-tags', 'false')
|
|
|
|
|
2015-08-17 22:29:10 +00:00
|
|
|
if p.clone_depth:
|
|
|
|
e.setAttribute('clone-depth', str(p.clone_depth))
|
|
|
|
|
2015-08-20 19:19:28 +00:00
|
|
|
self._output_manifest_project_extras(p, e)
|
|
|
|
|
Represent git-submodule as nested projects, take 2
(Previous submission of this change broke Android buildbot due to
incorrect regular expression for parsing git-config output. During
investigation, we also found that Android, which pulls Chromium, has a
workaround for Chromium's submodules; its manifest includes Chromium's
submodules. This new change, in addition to fixing the regex, also
take this type of workarounds into consideration; it adds a new
attribute that makes repo not fetch submodules unless submodules have a
project element defined in the manifest, or this attribute is
overridden by a parent project element or by the default element.)
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I4b8344c1b9ccad2f58ad304573133e5d52e1faef
2012-01-11 03:28:42 +00:00
|
|
|
if p.subprojects:
|
2013-10-12 00:03:19 +00:00
|
|
|
subprojects = set(subp.name for subp in p.subprojects)
|
|
|
|
output_projects(p, e, list(sorted(subprojects)))
|
Represent git-submodule as nested projects, take 2
(Previous submission of this change broke Android buildbot due to
incorrect regular expression for parsing git-config output. During
investigation, we also found that Android, which pulls Chromium, has a
workaround for Chromium's submodules; its manifest includes Chromium's
submodules. This new change, in addition to fixing the regex, also
take this type of workarounds into consideration; it adds a new
attribute that makes repo not fetch submodules unless submodules have a
project element defined in the manifest, or this attribute is
overridden by a parent project element or by the default element.)
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I4b8344c1b9ccad2f58ad304573133e5d52e1faef
2012-01-11 03:28:42 +00:00
|
|
|
|
2013-10-12 00:03:19 +00:00
|
|
|
projects = set(p.name for p in self._paths.values() if not p.parent)
|
|
|
|
output_projects(None, root, list(sorted(projects)))
|
Represent git-submodule as nested projects, take 2
(Previous submission of this change broke Android buildbot due to
incorrect regular expression for parsing git-config output. During
investigation, we also found that Android, which pulls Chromium, has a
workaround for Chromium's submodules; its manifest includes Chromium's
submodules. This new change, in addition to fixing the regex, also
take this type of workarounds into consideration; it adds a new
attribute that makes repo not fetch submodules unless submodules have a
project element defined in the manifest, or this attribute is
overridden by a parent project element or by the default element.)
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I4b8344c1b9ccad2f58ad304573133e5d52e1faef
2012-01-11 03:28:42 +00:00
|
|
|
|
Support repo-level pre-upload hook and prep for future hooks.
All repo-level hooks are expected to live in a single project at the
top level of that project. The name of the hooks project is provided
in the manifest.xml. The manifest also lists which hooks are enabled
to make it obvious if a file somehow failed to sync down (or got
deleted).
Before running any hook, we will prompt the user to make sure that it
is OK. A user can deny running the hook, allow once, or allow
"forever" (until hooks change). This tries to keep with the git
spirit of not automatically running anything on the user's computer
that got synced down. Note that individual repo commands can add
always options to avoid these prompts as they see fit (see below for
the 'upload' options).
When hooks are run, they are loaded into the current interpreter (the
one running repo) and their main() function is run. This mechanism is
used (instead of using subprocess) to make it easier to expand to a
richer hook interface in the future. During loading, the
interpreter's sys.path is updated to contain the directory containing
the hooks so that hooks can be split into multiple files.
The upload command has two options that control hook behavior:
- no-verify=False, verify=False (DEFAULT):
If stdout is a tty, can prompt about running upload hooks if needed.
If user denies running hooks, the upload is cancelled. If stdout is
not a tty and we would need to prompt about upload hooks, upload is
cancelled.
- no-verify=False, verify=True:
Always run upload hooks with no prompt.
- no-verify=True, verify=False:
Never run upload hooks, but upload anyway (AKA bypass hooks).
- no-verify=True, verify=True:
Invalid
Sample bit of manifest.xml code for enabling hooks (assumes you have a
project named 'hooks' where hooks are stored):
<repo-hooks in-project="hooks" enabled-list="pre-upload" />
Sample main() function in pre-upload.py in hooks directory:
def main(project_list, **kwargs):
print ('These projects will be uploaded: %s' %
', '.join(project_list))
print ('I am being a good boy and ignoring anything in kwargs\n'
'that I don\'t understand.')
print 'I fail 50% of the time. How flaky.'
if random.random() <= .5:
raise Exception('Pre-upload hook failed. Have a nice day.')
Change-Id: I5cefa2cd5865c72589263cf8e2f152a43c122f70
2011-03-04 19:54:18 +00:00
|
|
|
if self._repo_hooks_project:
|
|
|
|
root.appendChild(doc.createTextNode(''))
|
|
|
|
e = doc.createElement('repo-hooks')
|
|
|
|
e.setAttribute('in-project', self._repo_hooks_project.name)
|
|
|
|
e.setAttribute('enabled-list',
|
|
|
|
' '.join(self._repo_hooks_project.enabled_repo_hooks))
|
|
|
|
root.appendChild(e)
|
|
|
|
|
2021-01-08 00:50:45 +00:00
|
|
|
if self._superproject:
|
|
|
|
root.appendChild(doc.createTextNode(''))
|
|
|
|
e = doc.createElement('superproject')
|
2022-04-07 18:14:46 +00:00
|
|
|
e.setAttribute('name', self._superproject.name)
|
2021-01-08 00:50:45 +00:00
|
|
|
remoteName = None
|
|
|
|
if d.remote:
|
|
|
|
remoteName = d.remote.name
|
2022-04-07 18:14:46 +00:00
|
|
|
remote = self._superproject.remote
|
2021-01-08 00:50:45 +00:00
|
|
|
if not d.remote or remote.orig_name != remoteName:
|
|
|
|
remoteName = remote.orig_name
|
|
|
|
e.setAttribute('remote', remoteName)
|
2021-09-27 06:20:32 +00:00
|
|
|
revision = remote.revision or d.revisionExpr
|
2022-04-07 18:14:46 +00:00
|
|
|
if not revision or revision != self._superproject.revision:
|
|
|
|
e.setAttribute('revision', self._superproject.revision)
|
2021-01-08 00:50:45 +00:00
|
|
|
root.appendChild(e)
|
|
|
|
|
2021-05-12 19:00:31 +00:00
|
|
|
if self._contactinfo.bugurl != Wrapper().BUG_URL:
|
2021-05-04 19:32:13 +00:00
|
|
|
root.appendChild(doc.createTextNode(''))
|
|
|
|
e = doc.createElement('contactinfo')
|
2021-05-12 19:00:31 +00:00
|
|
|
e.setAttribute('bugurl', self._contactinfo.bugurl)
|
2021-05-04 19:32:13 +00:00
|
|
|
root.appendChild(e)
|
|
|
|
|
2020-09-02 08:31:10 +00:00
|
|
|
return doc
|
|
|
|
|
|
|
|
def ToDict(self, **kwargs):
|
|
|
|
"""Return the current manifest as a dictionary."""
|
|
|
|
# Elements that may only appear once.
|
|
|
|
SINGLE_ELEMENTS = {
|
|
|
|
'notice',
|
|
|
|
'default',
|
|
|
|
'manifest-server',
|
|
|
|
'repo-hooks',
|
2021-01-08 00:50:45 +00:00
|
|
|
'superproject',
|
2021-05-04 19:32:13 +00:00
|
|
|
'contactinfo',
|
2020-09-02 08:31:10 +00:00
|
|
|
}
|
|
|
|
# Elements that may be repeated.
|
|
|
|
MULTI_ELEMENTS = {
|
|
|
|
'remote',
|
|
|
|
'remove-project',
|
|
|
|
'project',
|
|
|
|
'extend-project',
|
|
|
|
'include',
|
2021-11-18 22:40:18 +00:00
|
|
|
'submanifest',
|
2020-09-02 08:31:10 +00:00
|
|
|
# These are children of 'project' nodes.
|
|
|
|
'annotation',
|
|
|
|
'project',
|
|
|
|
'copyfile',
|
|
|
|
'linkfile',
|
|
|
|
}
|
|
|
|
|
|
|
|
doc = self.ToXml(**kwargs)
|
|
|
|
ret = {}
|
|
|
|
|
|
|
|
def append_children(ret, node):
|
|
|
|
for child in node.childNodes:
|
|
|
|
if child.nodeType == xml.dom.Node.ELEMENT_NODE:
|
|
|
|
attrs = child.attributes
|
|
|
|
element = dict((attrs.item(i).localName, attrs.item(i).value)
|
|
|
|
for i in range(attrs.length))
|
|
|
|
if child.nodeName in SINGLE_ELEMENTS:
|
|
|
|
ret[child.nodeName] = element
|
|
|
|
elif child.nodeName in MULTI_ELEMENTS:
|
|
|
|
ret.setdefault(child.nodeName, []).append(element)
|
|
|
|
else:
|
|
|
|
raise ManifestParseError('Unhandled element "%s"' % (child.nodeName,))
|
|
|
|
|
|
|
|
append_children(element, child)
|
|
|
|
|
|
|
|
append_children(ret, doc.firstChild)
|
|
|
|
|
|
|
|
return ret
|
|
|
|
|
|
|
|
def Save(self, fd, **kwargs):
|
|
|
|
"""Write the current manifest out to the given file descriptor."""
|
|
|
|
doc = self.ToXml(**kwargs)
|
2009-03-05 18:32:38 +00:00
|
|
|
doc.writexml(fd, '', ' ', '\n', 'UTF-8')
|
|
|
|
|
2015-08-20 19:19:28 +00:00
|
|
|
def _output_manifest_project_extras(self, p, e):
|
|
|
|
"""Manifests can modify e if they support extra project attributes."""
|
|
|
|
|
2021-11-18 22:40:18 +00:00
|
|
|
@property
|
|
|
|
def is_multimanifest(self):
|
2021-12-21 05:40:31 +00:00
|
|
|
"""Whether this is a multimanifest checkout.
|
|
|
|
|
|
|
|
This is safe to use as long as the outermost manifest XML has been parsed.
|
|
|
|
"""
|
|
|
|
return bool(self._outer_client._submanifests)
|
2021-11-18 22:40:18 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def is_submanifest(self):
|
2022-06-01 21:03:34 +00:00
|
|
|
"""Whether this manifest is a submanifest.
|
|
|
|
|
|
|
|
This is safe to use as long as the outermost manifest XML has been parsed.
|
|
|
|
"""
|
2021-11-18 22:40:18 +00:00
|
|
|
return self._outer_client and self._outer_client != self
|
|
|
|
|
|
|
|
@property
|
|
|
|
def outer_client(self):
|
2022-06-01 21:03:34 +00:00
|
|
|
"""The instance of the outermost manifest client."""
|
2021-11-18 22:40:18 +00:00
|
|
|
self._Load()
|
|
|
|
return self._outer_client
|
|
|
|
|
|
|
|
@property
|
|
|
|
def all_manifests(self):
|
2022-06-01 21:03:34 +00:00
|
|
|
"""Generator yielding all (sub)manifests, in depth-first order."""
|
2021-11-18 22:40:18 +00:00
|
|
|
self._Load()
|
|
|
|
outer = self._outer_client
|
|
|
|
yield outer
|
|
|
|
for tree in outer.all_children:
|
|
|
|
yield tree
|
|
|
|
|
|
|
|
@property
|
|
|
|
def all_children(self):
|
2022-06-01 21:03:34 +00:00
|
|
|
"""Generator yielding all (present) child submanifests."""
|
2021-11-18 22:40:18 +00:00
|
|
|
self._Load()
|
|
|
|
for child in self._submanifests.values():
|
|
|
|
if child.repo_client:
|
|
|
|
yield child.repo_client
|
|
|
|
for tree in child.repo_client.all_children:
|
|
|
|
yield tree
|
|
|
|
|
|
|
|
@property
|
|
|
|
def path_prefix(self):
|
|
|
|
"""The path of this submanifest, relative to the outermost manifest."""
|
|
|
|
if not self._outer_client or self == self._outer_client:
|
|
|
|
return ''
|
|
|
|
return os.path.relpath(self.topdir, self._outer_client.topdir)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def all_paths(self):
|
2022-06-01 21:03:34 +00:00
|
|
|
"""All project paths for all (sub)manifests.
|
|
|
|
|
|
|
|
See also `paths`.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
A dictionary of {path: Project()}. `path` is relative to the outer
|
|
|
|
manifest.
|
|
|
|
"""
|
2021-11-18 22:40:18 +00:00
|
|
|
ret = {}
|
|
|
|
for tree in self.all_manifests:
|
|
|
|
prefix = tree.path_prefix
|
|
|
|
ret.update({os.path.join(prefix, k): v for k, v in tree.paths.items()})
|
|
|
|
return ret
|
|
|
|
|
|
|
|
@property
|
|
|
|
def all_projects(self):
|
|
|
|
"""All projects for all (sub)manifests. See `projects`."""
|
|
|
|
return list(itertools.chain.from_iterable(x._paths.values() for x in self.all_manifests))
|
|
|
|
|
2013-10-12 00:03:19 +00:00
|
|
|
@property
|
|
|
|
def paths(self):
|
2021-11-18 22:40:18 +00:00
|
|
|
"""Return all paths for this manifest.
|
|
|
|
|
2022-06-01 21:03:34 +00:00
|
|
|
Returns:
|
2021-11-18 22:40:18 +00:00
|
|
|
A dictionary of {path: Project()}. `path` is relative to this manifest.
|
|
|
|
"""
|
2013-10-12 00:03:19 +00:00
|
|
|
self._Load()
|
|
|
|
return self._paths
|
|
|
|
|
2008-10-21 14:00:00 +00:00
|
|
|
@property
|
|
|
|
def projects(self):
|
2021-11-18 22:40:18 +00:00
|
|
|
"""Return a list of all Projects in this manifest."""
|
2008-10-21 14:00:00 +00:00
|
|
|
self._Load()
|
2014-05-05 22:30:49 +00:00
|
|
|
return list(self._paths.values())
|
2008-10-21 14:00:00 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def remotes(self):
|
2022-06-01 21:03:34 +00:00
|
|
|
"""Return a list of remotes for this manifest."""
|
2008-10-21 14:00:00 +00:00
|
|
|
self._Load()
|
|
|
|
return self._remotes
|
|
|
|
|
|
|
|
@property
|
|
|
|
def default(self):
|
2022-06-01 21:03:34 +00:00
|
|
|
"""Return default values for this manifest."""
|
2008-10-21 14:00:00 +00:00
|
|
|
self._Load()
|
|
|
|
return self._default
|
|
|
|
|
2021-11-18 22:40:18 +00:00
|
|
|
@property
|
|
|
|
def submanifests(self):
|
|
|
|
"""All submanifests in this manifest."""
|
|
|
|
self._Load()
|
|
|
|
return self._submanifests
|
|
|
|
|
Support repo-level pre-upload hook and prep for future hooks.
All repo-level hooks are expected to live in a single project at the
top level of that project. The name of the hooks project is provided
in the manifest.xml. The manifest also lists which hooks are enabled
to make it obvious if a file somehow failed to sync down (or got
deleted).
Before running any hook, we will prompt the user to make sure that it
is OK. A user can deny running the hook, allow once, or allow
"forever" (until hooks change). This tries to keep with the git
spirit of not automatically running anything on the user's computer
that got synced down. Note that individual repo commands can add
always options to avoid these prompts as they see fit (see below for
the 'upload' options).
When hooks are run, they are loaded into the current interpreter (the
one running repo) and their main() function is run. This mechanism is
used (instead of using subprocess) to make it easier to expand to a
richer hook interface in the future. During loading, the
interpreter's sys.path is updated to contain the directory containing
the hooks so that hooks can be split into multiple files.
The upload command has two options that control hook behavior:
- no-verify=False, verify=False (DEFAULT):
If stdout is a tty, can prompt about running upload hooks if needed.
If user denies running hooks, the upload is cancelled. If stdout is
not a tty and we would need to prompt about upload hooks, upload is
cancelled.
- no-verify=False, verify=True:
Always run upload hooks with no prompt.
- no-verify=True, verify=False:
Never run upload hooks, but upload anyway (AKA bypass hooks).
- no-verify=True, verify=True:
Invalid
Sample bit of manifest.xml code for enabling hooks (assumes you have a
project named 'hooks' where hooks are stored):
<repo-hooks in-project="hooks" enabled-list="pre-upload" />
Sample main() function in pre-upload.py in hooks directory:
def main(project_list, **kwargs):
print ('These projects will be uploaded: %s' %
', '.join(project_list))
print ('I am being a good boy and ignoring anything in kwargs\n'
'that I don\'t understand.')
print 'I fail 50% of the time. How flaky.'
if random.random() <= .5:
raise Exception('Pre-upload hook failed. Have a nice day.')
Change-Id: I5cefa2cd5865c72589263cf8e2f152a43c122f70
2011-03-04 19:54:18 +00:00
|
|
|
@property
|
|
|
|
def repo_hooks_project(self):
|
|
|
|
self._Load()
|
|
|
|
return self._repo_hooks_project
|
|
|
|
|
2021-01-08 00:50:45 +00:00
|
|
|
@property
|
|
|
|
def superproject(self):
|
|
|
|
self._Load()
|
|
|
|
return self._superproject
|
|
|
|
|
2021-05-04 19:32:13 +00:00
|
|
|
@property
|
|
|
|
def contactinfo(self):
|
|
|
|
self._Load()
|
|
|
|
return self._contactinfo
|
|
|
|
|
2010-11-01 22:08:06 +00:00
|
|
|
@property
|
|
|
|
def notice(self):
|
|
|
|
self._Load()
|
|
|
|
return self._notice
|
|
|
|
|
2010-04-06 17:40:01 +00:00
|
|
|
@property
|
|
|
|
def manifest_server(self):
|
|
|
|
self._Load()
|
2011-11-30 21:41:02 +00:00
|
|
|
return self._manifest_server
|
2010-04-06 17:40:01 +00:00
|
|
|
|
2020-05-20 23:03:45 +00:00
|
|
|
@property
|
|
|
|
def CloneBundle(self):
|
2022-04-05 19:30:46 +00:00
|
|
|
clone_bundle = self.manifestProject.clone_bundle
|
2020-05-20 23:03:45 +00:00
|
|
|
if clone_bundle is None:
|
2022-04-05 19:30:46 +00:00
|
|
|
return False if self.manifestProject.partial_clone else True
|
2020-05-20 23:03:45 +00:00
|
|
|
else:
|
|
|
|
return clone_bundle
|
|
|
|
|
2019-06-03 18:24:30 +00:00
|
|
|
@property
|
|
|
|
def CloneFilter(self):
|
2022-04-05 19:30:46 +00:00
|
|
|
if self.manifestProject.partial_clone:
|
|
|
|
return self.manifestProject.clone_filter
|
2019-06-03 18:24:30 +00:00
|
|
|
return None
|
|
|
|
|
2021-04-13 03:57:25 +00:00
|
|
|
@property
|
|
|
|
def PartialCloneExclude(self):
|
2022-04-05 19:30:46 +00:00
|
|
|
exclude = self.manifest.manifestProject.partial_clone_exclude or ''
|
2021-04-13 03:57:25 +00:00
|
|
|
return set(x.strip() for x in exclude.split(','))
|
|
|
|
|
2022-04-14 15:00:09 +00:00
|
|
|
def SetManifestOverride(self, path):
|
|
|
|
"""Override manifestFile. The caller must call Unload()"""
|
|
|
|
self._outer_client.manifest.manifestFileOverrides[self.path_prefix] = path
|
|
|
|
|
2021-07-02 16:25:48 +00:00
|
|
|
@property
|
|
|
|
def UseLocalManifests(self):
|
|
|
|
return self._load_local_manifests
|
|
|
|
|
|
|
|
def SetUseLocalManifests(self, value):
|
|
|
|
self._load_local_manifests = value
|
|
|
|
|
2021-05-03 02:47:29 +00:00
|
|
|
@property
|
|
|
|
def HasLocalManifests(self):
|
|
|
|
return self._load_local_manifests and self.local_manifests
|
|
|
|
|
2022-02-14 17:48:31 +00:00
|
|
|
def IsFromLocalManifest(self, project):
|
2021-11-18 22:40:18 +00:00
|
|
|
"""Is the project from a local manifest?"""
|
2022-02-14 17:48:31 +00:00
|
|
|
return any(x.startswith(LOCAL_MANIFEST_GROUP_PREFIX)
|
|
|
|
for x in project.groups)
|
|
|
|
|
2008-11-04 15:37:10 +00:00
|
|
|
@property
|
|
|
|
def IsMirror(self):
|
2022-04-05 19:30:46 +00:00
|
|
|
return self.manifestProject.mirror
|
2008-11-04 15:37:10 +00:00
|
|
|
|
2020-02-09 07:28:34 +00:00
|
|
|
@property
|
|
|
|
def UseGitWorktrees(self):
|
2022-04-05 19:30:46 +00:00
|
|
|
return self.manifestProject.use_worktree
|
2020-02-09 07:28:34 +00:00
|
|
|
|
2013-10-16 09:02:35 +00:00
|
|
|
@property
|
|
|
|
def IsArchive(self):
|
2022-04-05 19:30:46 +00:00
|
|
|
return self.manifestProject.archive
|
2013-10-16 09:02:35 +00:00
|
|
|
|
2017-03-21 23:05:12 +00:00
|
|
|
@property
|
|
|
|
def HasSubmodules(self):
|
2022-04-05 19:30:46 +00:00
|
|
|
return self.manifestProject.submodules
|
2017-03-21 23:05:12 +00:00
|
|
|
|
init: add an option --enable-git-lfs-filter
It was reported that git-lfs did not work with git-repo. Specifically,
`git read-tree -u` run by `repo sync` would fail git-lfs's smudge
filter. See https://github.com/github/git-lfs/issues/1422.
In fact, by the time `git read-tree -u` is run, the repository is not
bare. It is just that, the working directory is not the same as the
.git directory. git-lfs's filter should work. No one seems to have
delved into that issue.
Today, with newer versions of git-repo and git-lfs, that issue will
not reproduce. Tested with
- git 2.33, git-lfs 2.13 on macOS
- git 2.17, git-lfs 2.3 on ubuntu
So, it seems fine to add an option --enable-git-lfs-filter, default to
false, and stat that it may not work with older versions of git and
git-lfs in the help doc.
Bug: https://crbug.com/gerrit/14516
Change-Id: I8d21854eeeea541e072f63d6b10ad1253b1a9826
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/328359
Tested-by: XD Trol <milestonejxd@gmail.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
2022-01-17 15:29:04 +00:00
|
|
|
@property
|
|
|
|
def EnableGitLfs(self):
|
2022-04-05 19:30:46 +00:00
|
|
|
return self.manifestProject.git_lfs
|
init: add an option --enable-git-lfs-filter
It was reported that git-lfs did not work with git-repo. Specifically,
`git read-tree -u` run by `repo sync` would fail git-lfs's smudge
filter. See https://github.com/github/git-lfs/issues/1422.
In fact, by the time `git read-tree -u` is run, the repository is not
bare. It is just that, the working directory is not the same as the
.git directory. git-lfs's filter should work. No one seems to have
delved into that issue.
Today, with newer versions of git-repo and git-lfs, that issue will
not reproduce. Tested with
- git 2.33, git-lfs 2.13 on macOS
- git 2.17, git-lfs 2.3 on ubuntu
So, it seems fine to add an option --enable-git-lfs-filter, default to
false, and stat that it may not work with older versions of git and
git-lfs in the help doc.
Bug: https://crbug.com/gerrit/14516
Change-Id: I8d21854eeeea541e072f63d6b10ad1253b1a9826
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/328359
Tested-by: XD Trol <milestonejxd@gmail.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
2022-01-17 15:29:04 +00:00
|
|
|
|
2021-11-18 22:40:18 +00:00
|
|
|
def FindManifestByPath(self, path):
|
|
|
|
"""Returns the manifest containing path."""
|
|
|
|
path = os.path.abspath(path)
|
|
|
|
manifest = self._outer_client or self
|
|
|
|
old = None
|
|
|
|
while manifest._submanifests and manifest != old:
|
|
|
|
old = manifest
|
|
|
|
for name in manifest._submanifests:
|
|
|
|
tree = manifest._submanifests[name]
|
|
|
|
if path.startswith(tree.repo_client.manifest.topdir):
|
|
|
|
manifest = tree.repo_client
|
|
|
|
break
|
|
|
|
return manifest
|
|
|
|
|
|
|
|
@property
|
|
|
|
def subdir(self):
|
|
|
|
"""Returns the path for per-submanifest objects for this manifest."""
|
|
|
|
return self.SubmanifestInfoDir(self.path_prefix)
|
|
|
|
|
|
|
|
def SubmanifestInfoDir(self, submanifest_path, object_path=''):
|
|
|
|
"""Return the path to submanifest-specific info for a submanifest.
|
|
|
|
|
|
|
|
Return the full path of the directory in which to put per-manifest objects.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
submanifest_path: a string, the path of the submanifest, relative to the
|
|
|
|
outermost topdir. If empty, then repodir is returned.
|
|
|
|
object_path: a string, relative path to append to the submanifest info
|
|
|
|
directory path.
|
|
|
|
"""
|
|
|
|
if submanifest_path:
|
|
|
|
return os.path.join(self.repodir, SUBMANIFEST_DIR, submanifest_path,
|
|
|
|
object_path)
|
|
|
|
else:
|
|
|
|
return os.path.join(self.repodir, object_path)
|
|
|
|
|
|
|
|
def SubmanifestProject(self, submanifest_path):
|
|
|
|
"""Return a manifestProject for a submanifest."""
|
|
|
|
subdir = self.SubmanifestInfoDir(submanifest_path)
|
2022-03-29 21:54:22 +00:00
|
|
|
mp = ManifestProject(self, 'manifests',
|
|
|
|
gitdir=os.path.join(subdir, 'manifests.git'),
|
|
|
|
worktree=os.path.join(subdir, 'manifests'))
|
2021-11-18 22:40:18 +00:00
|
|
|
return mp
|
|
|
|
|
2022-04-20 16:42:32 +00:00
|
|
|
def GetDefaultGroupsStr(self, with_platform=True):
|
|
|
|
"""Returns the default group string to use.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
with_platform: a boolean, whether to include the group for the
|
|
|
|
underlying platform.
|
|
|
|
"""
|
|
|
|
groups = ','.join(self.default_groups or ['default'])
|
|
|
|
if with_platform:
|
|
|
|
groups += f',platform-{platform.system().lower()}'
|
|
|
|
return groups
|
2021-03-09 23:19:06 +00:00
|
|
|
|
|
|
|
def GetGroupsStr(self):
|
|
|
|
"""Returns the manifest group string that should be synced."""
|
2022-04-20 16:42:32 +00:00
|
|
|
return self.manifestProject.manifest_groups or self.GetDefaultGroupsStr()
|
2021-03-09 23:19:06 +00:00
|
|
|
|
2022-04-07 16:49:06 +00:00
|
|
|
def Unload(self):
|
|
|
|
"""Unload the manifest.
|
|
|
|
|
|
|
|
If the manifest files have been changed since Load() was called, this will
|
|
|
|
cause the new/updated manifest to be used.
|
|
|
|
|
|
|
|
"""
|
2008-10-21 14:00:00 +00:00
|
|
|
self._loaded = False
|
|
|
|
self._projects = {}
|
2013-10-12 00:03:19 +00:00
|
|
|
self._paths = {}
|
2008-10-21 14:00:00 +00:00
|
|
|
self._remotes = {}
|
|
|
|
self._default = None
|
2021-11-18 22:40:18 +00:00
|
|
|
self._submanifests = {}
|
Support repo-level pre-upload hook and prep for future hooks.
All repo-level hooks are expected to live in a single project at the
top level of that project. The name of the hooks project is provided
in the manifest.xml. The manifest also lists which hooks are enabled
to make it obvious if a file somehow failed to sync down (or got
deleted).
Before running any hook, we will prompt the user to make sure that it
is OK. A user can deny running the hook, allow once, or allow
"forever" (until hooks change). This tries to keep with the git
spirit of not automatically running anything on the user's computer
that got synced down. Note that individual repo commands can add
always options to avoid these prompts as they see fit (see below for
the 'upload' options).
When hooks are run, they are loaded into the current interpreter (the
one running repo) and their main() function is run. This mechanism is
used (instead of using subprocess) to make it easier to expand to a
richer hook interface in the future. During loading, the
interpreter's sys.path is updated to contain the directory containing
the hooks so that hooks can be split into multiple files.
The upload command has two options that control hook behavior:
- no-verify=False, verify=False (DEFAULT):
If stdout is a tty, can prompt about running upload hooks if needed.
If user denies running hooks, the upload is cancelled. If stdout is
not a tty and we would need to prompt about upload hooks, upload is
cancelled.
- no-verify=False, verify=True:
Always run upload hooks with no prompt.
- no-verify=True, verify=False:
Never run upload hooks, but upload anyway (AKA bypass hooks).
- no-verify=True, verify=True:
Invalid
Sample bit of manifest.xml code for enabling hooks (assumes you have a
project named 'hooks' where hooks are stored):
<repo-hooks in-project="hooks" enabled-list="pre-upload" />
Sample main() function in pre-upload.py in hooks directory:
def main(project_list, **kwargs):
print ('These projects will be uploaded: %s' %
', '.join(project_list))
print ('I am being a good boy and ignoring anything in kwargs\n'
'that I don\'t understand.')
print 'I fail 50% of the time. How flaky.'
if random.random() <= .5:
raise Exception('Pre-upload hook failed. Have a nice day.')
Change-Id: I5cefa2cd5865c72589263cf8e2f152a43c122f70
2011-03-04 19:54:18 +00:00
|
|
|
self._repo_hooks_project = None
|
2022-04-07 18:14:46 +00:00
|
|
|
self._superproject = None
|
2021-05-12 19:00:31 +00:00
|
|
|
self._contactinfo = ContactInfo(Wrapper().BUG_URL)
|
2010-11-01 22:08:06 +00:00
|
|
|
self._notice = None
|
2008-10-21 14:00:00 +00:00
|
|
|
self.branch = None
|
2010-04-06 17:40:01 +00:00
|
|
|
self._manifest_server = None
|
2008-10-21 14:00:00 +00:00
|
|
|
|
2022-04-07 16:49:06 +00:00
|
|
|
def Load(self):
|
|
|
|
"""Read the manifest into memory."""
|
|
|
|
# Do not expose internal arguments.
|
|
|
|
self._Load()
|
|
|
|
|
2021-11-18 22:40:18 +00:00
|
|
|
def _Load(self, initial_client=None, submanifest_depth=0):
|
|
|
|
if submanifest_depth > MAX_SUBMANIFEST_DEPTH:
|
|
|
|
raise ManifestParseError('maximum submanifest depth %d exceeded.' %
|
|
|
|
MAX_SUBMANIFEST_DEPTH)
|
2008-10-21 14:00:00 +00:00
|
|
|
if not self._loaded:
|
2021-11-18 22:40:18 +00:00
|
|
|
if self._outer_client and self._outer_client != self:
|
|
|
|
# This will load all clients.
|
|
|
|
self._outer_client._Load(initial_client=self)
|
|
|
|
|
2022-04-14 15:00:09 +00:00
|
|
|
savedManifestFile = self.manifestFile
|
|
|
|
override = self._outer_client.manifestFileOverrides.get(self.path_prefix)
|
|
|
|
if override:
|
|
|
|
self.manifestFile = override
|
2021-11-18 22:40:18 +00:00
|
|
|
|
2022-04-14 15:00:09 +00:00
|
|
|
try:
|
|
|
|
m = self.manifestProject
|
|
|
|
b = m.GetBranch(m.CurrentBranch).merge
|
|
|
|
if b is not None and b.startswith(R_HEADS):
|
|
|
|
b = b[len(R_HEADS):]
|
|
|
|
self.branch = b
|
|
|
|
|
|
|
|
parent_groups = self.parent_groups
|
|
|
|
if self.path_prefix:
|
|
|
|
parent_groups = f'{SUBMANIFEST_GROUP_PREFIX}:path:{self.path_prefix},{parent_groups}'
|
|
|
|
|
|
|
|
# The manifestFile was specified by the user which is why we allow include
|
|
|
|
# paths to point anywhere.
|
|
|
|
nodes = []
|
|
|
|
nodes.append(self._ParseManifestXml(
|
|
|
|
self.manifestFile, self.manifestProject.worktree,
|
|
|
|
parent_groups=parent_groups, restrict_includes=False))
|
|
|
|
|
|
|
|
if self._load_local_manifests and self.local_manifests:
|
|
|
|
try:
|
|
|
|
for local_file in sorted(platform_utils.listdir(self.local_manifests)):
|
|
|
|
if local_file.endswith('.xml'):
|
|
|
|
local = os.path.join(self.local_manifests, local_file)
|
|
|
|
# Since local manifests are entirely managed by the user, allow
|
|
|
|
# them to point anywhere the user wants.
|
|
|
|
local_group = f'{LOCAL_MANIFEST_GROUP_PREFIX}:{local_file[:-4]}'
|
|
|
|
nodes.append(self._ParseManifestXml(
|
|
|
|
local, self.subdir,
|
|
|
|
parent_groups=f'{local_group},{parent_groups}',
|
|
|
|
restrict_includes=False))
|
|
|
|
except OSError:
|
|
|
|
pass
|
2008-10-23 23:19:27 +00:00
|
|
|
|
2018-05-25 17:23:52 +00:00
|
|
|
try:
|
2022-04-14 15:00:09 +00:00
|
|
|
self._ParseManifest(nodes)
|
|
|
|
except ManifestParseError as e:
|
|
|
|
# There was a problem parsing, unload ourselves in case they catch
|
|
|
|
# this error and try again later, we will show the correct error
|
|
|
|
self.Unload()
|
|
|
|
raise e
|
2008-10-23 23:19:27 +00:00
|
|
|
|
2022-04-14 15:00:09 +00:00
|
|
|
if self.IsMirror:
|
|
|
|
self._AddMetaProjectMirror(self.repoProject)
|
|
|
|
self._AddMetaProjectMirror(self.manifestProject)
|
2008-11-04 15:37:10 +00:00
|
|
|
|
2022-04-14 15:00:09 +00:00
|
|
|
self._loaded = True
|
|
|
|
finally:
|
|
|
|
if override:
|
|
|
|
self.manifestFile = savedManifestFile
|
2008-10-21 14:00:00 +00:00
|
|
|
|
2022-06-01 21:03:34 +00:00
|
|
|
# Now that we have loaded this manifest, load any submanifests as well.
|
|
|
|
# We need to do this after self._loaded is set to avoid looping.
|
2022-04-07 18:14:46 +00:00
|
|
|
for name in self._submanifests:
|
|
|
|
tree = self._submanifests[name]
|
2022-04-14 15:00:09 +00:00
|
|
|
spec = tree.ToSubmanifestSpec()
|
2022-04-07 18:14:46 +00:00
|
|
|
present = os.path.exists(os.path.join(self.subdir, MANIFEST_FILE_NAME))
|
|
|
|
if present and tree.present and not tree.repo_client:
|
|
|
|
if initial_client and initial_client.topdir == self.topdir:
|
|
|
|
tree.repo_client = self
|
|
|
|
tree.present = present
|
|
|
|
elif not os.path.exists(self.subdir):
|
|
|
|
tree.present = False
|
|
|
|
if present and tree.present:
|
|
|
|
tree.repo_client._Load(initial_client=initial_client,
|
|
|
|
submanifest_depth=submanifest_depth + 1)
|
2021-11-18 22:40:18 +00:00
|
|
|
|
2021-03-02 02:38:08 +00:00
|
|
|
def _ParseManifestXml(self, path, include_root, parent_groups='',
|
|
|
|
restrict_includes=True):
|
|
|
|
"""Parse a manifest XML and return the computed nodes.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
path: The XML file to read & parse.
|
|
|
|
include_root: The path to interpret include "name"s relative to.
|
|
|
|
parent_groups: The groups to apply to this projects.
|
|
|
|
restrict_includes: Whether to constrain the "name" attribute of includes.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
List of XML nodes.
|
|
|
|
"""
|
2012-11-12 19:00:28 +00:00
|
|
|
try:
|
|
|
|
root = xml.dom.minidom.parse(path)
|
2012-11-12 17:50:36 +00:00
|
|
|
except (OSError, xml.parsers.expat.ExpatError) as e:
|
2012-11-12 19:00:28 +00:00
|
|
|
raise ManifestParseError("error parsing manifest %s: %s" % (path, e))
|
|
|
|
|
2008-10-21 14:00:00 +00:00
|
|
|
if not root or not root.childNodes:
|
2011-04-28 12:04:41 +00:00
|
|
|
raise ManifestParseError("no root node in %s" % (path,))
|
2008-10-21 14:00:00 +00:00
|
|
|
|
2012-08-26 17:25:59 +00:00
|
|
|
for manifest in root.childNodes:
|
|
|
|
if manifest.nodeName == 'manifest':
|
|
|
|
break
|
|
|
|
else:
|
2011-04-28 12:04:41 +00:00
|
|
|
raise ManifestParseError("no <manifest> in %s" % (path,))
|
|
|
|
|
2012-04-21 07:33:54 +00:00
|
|
|
nodes = []
|
2018-06-24 07:21:51 +00:00
|
|
|
for node in manifest.childNodes:
|
2012-11-14 02:36:51 +00:00
|
|
|
if node.nodeName == 'include':
|
|
|
|
name = self._reqatt(node, 'name')
|
2021-03-02 02:38:08 +00:00
|
|
|
if restrict_includes:
|
|
|
|
msg = self._CheckLocalPath(name)
|
|
|
|
if msg:
|
|
|
|
raise ManifestInvalidPathError(
|
|
|
|
'<include> invalid "name": %s: %s' % (name, msg))
|
2020-10-06 10:55:14 +00:00
|
|
|
include_groups = ''
|
|
|
|
if parent_groups:
|
|
|
|
include_groups = parent_groups
|
|
|
|
if node.hasAttribute('groups'):
|
|
|
|
include_groups = node.getAttribute('groups') + ',' + include_groups
|
2012-11-14 02:36:51 +00:00
|
|
|
fp = os.path.join(include_root, name)
|
|
|
|
if not os.path.isfile(fp):
|
2021-03-02 02:38:08 +00:00
|
|
|
raise ManifestParseError("include [%s/]%s doesn't exist or isn't a file"
|
|
|
|
% (include_root, name))
|
2012-11-14 02:36:51 +00:00
|
|
|
try:
|
2020-10-06 10:55:14 +00:00
|
|
|
nodes.extend(self._ParseManifestXml(fp, include_root, include_groups))
|
2012-11-14 02:36:51 +00:00
|
|
|
# should isolate this to the exact exception, but that's
|
|
|
|
# tricky. actual parsing implementation may vary.
|
2021-03-02 02:38:08 +00:00
|
|
|
except (KeyboardInterrupt, RuntimeError, SystemExit, ManifestParseError):
|
2012-11-14 02:36:51 +00:00
|
|
|
raise
|
|
|
|
except Exception as e:
|
|
|
|
raise ManifestParseError(
|
2019-07-05 05:38:05 +00:00
|
|
|
"failed parsing included manifest %s: %s" % (name, e))
|
2012-11-14 02:36:51 +00:00
|
|
|
else:
|
2020-10-06 10:55:14 +00:00
|
|
|
if parent_groups and node.nodeName == 'project':
|
|
|
|
nodeGroups = parent_groups
|
|
|
|
if node.hasAttribute('groups'):
|
|
|
|
nodeGroups = node.getAttribute('groups') + ',' + nodeGroups
|
|
|
|
node.setAttribute('groups', nodeGroups)
|
2012-11-14 02:36:51 +00:00
|
|
|
nodes.append(node)
|
2012-04-21 07:33:54 +00:00
|
|
|
return nodes
|
2011-04-28 12:04:41 +00:00
|
|
|
|
2012-04-21 07:33:54 +00:00
|
|
|
def _ParseManifest(self, node_list):
|
|
|
|
for node in itertools.chain(*node_list):
|
2008-10-21 14:00:00 +00:00
|
|
|
if node.nodeName == 'remote':
|
|
|
|
remote = self._ParseRemote(node)
|
2012-11-12 23:49:16 +00:00
|
|
|
if remote:
|
|
|
|
if remote.name in self._remotes:
|
|
|
|
if remote != self._remotes[remote.name]:
|
|
|
|
raise ManifestParseError(
|
|
|
|
'remote %s already exists with different attributes' %
|
|
|
|
(remote.name))
|
|
|
|
else:
|
|
|
|
self._remotes[remote.name] = remote
|
2008-10-21 14:00:00 +00:00
|
|
|
|
2012-04-21 07:33:54 +00:00
|
|
|
for node in itertools.chain(*node_list):
|
2008-10-21 14:00:00 +00:00
|
|
|
if node.nodeName == 'default':
|
2013-10-09 12:38:46 +00:00
|
|
|
new_default = self._ParseDefault(node)
|
2021-06-15 14:28:30 +00:00
|
|
|
emptyDefault = not node.hasAttributes() and not node.hasChildNodes()
|
2013-10-09 12:38:46 +00:00
|
|
|
if self._default is None:
|
|
|
|
self._default = new_default
|
2021-06-15 14:28:30 +00:00
|
|
|
elif not emptyDefault and new_default != self._default:
|
2013-10-15 01:48:40 +00:00
|
|
|
raise ManifestParseError('duplicate default in %s' %
|
|
|
|
(self.manifestFile))
|
2013-10-09 12:38:46 +00:00
|
|
|
|
2008-10-21 14:00:00 +00:00
|
|
|
if self._default is None:
|
|
|
|
self._default = _Default()
|
|
|
|
|
2021-11-18 22:40:18 +00:00
|
|
|
submanifest_paths = set()
|
|
|
|
for node in itertools.chain(*node_list):
|
|
|
|
if node.nodeName == 'submanifest':
|
|
|
|
submanifest = self._ParseSubmanifest(node)
|
|
|
|
if submanifest:
|
|
|
|
if submanifest.name in self._submanifests:
|
|
|
|
if submanifest != self._submanifests[submanifest.name]:
|
|
|
|
raise ManifestParseError(
|
|
|
|
'submanifest %s already exists with different attributes' %
|
|
|
|
(submanifest.name))
|
|
|
|
else:
|
|
|
|
self._submanifests[submanifest.name] = submanifest
|
|
|
|
submanifest_paths.add(submanifest.relpath)
|
|
|
|
|
2012-04-21 07:33:54 +00:00
|
|
|
for node in itertools.chain(*node_list):
|
2010-11-01 22:08:06 +00:00
|
|
|
if node.nodeName == 'notice':
|
|
|
|
if self._notice is not None:
|
Support repo-level pre-upload hook and prep for future hooks.
All repo-level hooks are expected to live in a single project at the
top level of that project. The name of the hooks project is provided
in the manifest.xml. The manifest also lists which hooks are enabled
to make it obvious if a file somehow failed to sync down (or got
deleted).
Before running any hook, we will prompt the user to make sure that it
is OK. A user can deny running the hook, allow once, or allow
"forever" (until hooks change). This tries to keep with the git
spirit of not automatically running anything on the user's computer
that got synced down. Note that individual repo commands can add
always options to avoid these prompts as they see fit (see below for
the 'upload' options).
When hooks are run, they are loaded into the current interpreter (the
one running repo) and their main() function is run. This mechanism is
used (instead of using subprocess) to make it easier to expand to a
richer hook interface in the future. During loading, the
interpreter's sys.path is updated to contain the directory containing
the hooks so that hooks can be split into multiple files.
The upload command has two options that control hook behavior:
- no-verify=False, verify=False (DEFAULT):
If stdout is a tty, can prompt about running upload hooks if needed.
If user denies running hooks, the upload is cancelled. If stdout is
not a tty and we would need to prompt about upload hooks, upload is
cancelled.
- no-verify=False, verify=True:
Always run upload hooks with no prompt.
- no-verify=True, verify=False:
Never run upload hooks, but upload anyway (AKA bypass hooks).
- no-verify=True, verify=True:
Invalid
Sample bit of manifest.xml code for enabling hooks (assumes you have a
project named 'hooks' where hooks are stored):
<repo-hooks in-project="hooks" enabled-list="pre-upload" />
Sample main() function in pre-upload.py in hooks directory:
def main(project_list, **kwargs):
print ('These projects will be uploaded: %s' %
', '.join(project_list))
print ('I am being a good boy and ignoring anything in kwargs\n'
'that I don\'t understand.')
print 'I fail 50% of the time. How flaky.'
if random.random() <= .5:
raise Exception('Pre-upload hook failed. Have a nice day.')
Change-Id: I5cefa2cd5865c72589263cf8e2f152a43c122f70
2011-03-04 19:54:18 +00:00
|
|
|
raise ManifestParseError(
|
|
|
|
'duplicate notice in %s' %
|
|
|
|
(self.manifestFile))
|
2010-11-01 22:08:06 +00:00
|
|
|
self._notice = self._ParseNotice(node)
|
|
|
|
|
2012-04-21 07:33:54 +00:00
|
|
|
for node in itertools.chain(*node_list):
|
2010-04-06 17:40:01 +00:00
|
|
|
if node.nodeName == 'manifest-server':
|
|
|
|
url = self._reqatt(node, 'url')
|
|
|
|
if self._manifest_server is not None:
|
2012-11-14 02:36:51 +00:00
|
|
|
raise ManifestParseError(
|
|
|
|
'duplicate manifest-server in %s' %
|
|
|
|
(self.manifestFile))
|
2010-04-06 17:40:01 +00:00
|
|
|
self._manifest_server = url
|
|
|
|
|
Represent git-submodule as nested projects, take 2
(Previous submission of this change broke Android buildbot due to
incorrect regular expression for parsing git-config output. During
investigation, we also found that Android, which pulls Chromium, has a
workaround for Chromium's submodules; its manifest includes Chromium's
submodules. This new change, in addition to fixing the regex, also
take this type of workarounds into consideration; it adds a new
attribute that makes repo not fetch submodules unless submodules have a
project element defined in the manifest, or this attribute is
overridden by a parent project element or by the default element.)
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I4b8344c1b9ccad2f58ad304573133e5d52e1faef
2012-01-11 03:28:42 +00:00
|
|
|
def recursively_add_projects(project):
|
2013-10-12 00:03:19 +00:00
|
|
|
projects = self._projects.setdefault(project.name, [])
|
|
|
|
if project.relpath is None:
|
Represent git-submodule as nested projects, take 2
(Previous submission of this change broke Android buildbot due to
incorrect regular expression for parsing git-config output. During
investigation, we also found that Android, which pulls Chromium, has a
workaround for Chromium's submodules; its manifest includes Chromium's
submodules. This new change, in addition to fixing the regex, also
take this type of workarounds into consideration; it adds a new
attribute that makes repo not fetch submodules unless submodules have a
project element defined in the manifest, or this attribute is
overridden by a parent project element or by the default element.)
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I4b8344c1b9ccad2f58ad304573133e5d52e1faef
2012-01-11 03:28:42 +00:00
|
|
|
raise ManifestParseError(
|
2013-10-12 00:03:19 +00:00
|
|
|
'missing path for %s in %s' %
|
Represent git-submodule as nested projects, take 2
(Previous submission of this change broke Android buildbot due to
incorrect regular expression for parsing git-config output. During
investigation, we also found that Android, which pulls Chromium, has a
workaround for Chromium's submodules; its manifest includes Chromium's
submodules. This new change, in addition to fixing the regex, also
take this type of workarounds into consideration; it adds a new
attribute that makes repo not fetch submodules unless submodules have a
project element defined in the manifest, or this attribute is
overridden by a parent project element or by the default element.)
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I4b8344c1b9ccad2f58ad304573133e5d52e1faef
2012-01-11 03:28:42 +00:00
|
|
|
(project.name, self.manifestFile))
|
2013-10-12 00:03:19 +00:00
|
|
|
if project.relpath in self._paths:
|
|
|
|
raise ManifestParseError(
|
|
|
|
'duplicate path %s in %s' %
|
|
|
|
(project.relpath, self.manifestFile))
|
2021-11-18 22:40:18 +00:00
|
|
|
for tree in submanifest_paths:
|
|
|
|
if project.relpath.startswith(tree):
|
|
|
|
raise ManifestParseError(
|
|
|
|
'project %s conflicts with submanifest path %s' %
|
|
|
|
(project.relpath, tree))
|
2013-10-12 00:03:19 +00:00
|
|
|
self._paths[project.relpath] = project
|
|
|
|
projects.append(project)
|
Represent git-submodule as nested projects, take 2
(Previous submission of this change broke Android buildbot due to
incorrect regular expression for parsing git-config output. During
investigation, we also found that Android, which pulls Chromium, has a
workaround for Chromium's submodules; its manifest includes Chromium's
submodules. This new change, in addition to fixing the regex, also
take this type of workarounds into consideration; it adds a new
attribute that makes repo not fetch submodules unless submodules have a
project element defined in the manifest, or this attribute is
overridden by a parent project element or by the default element.)
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I4b8344c1b9ccad2f58ad304573133e5d52e1faef
2012-01-11 03:28:42 +00:00
|
|
|
for subproject in project.subprojects:
|
|
|
|
recursively_add_projects(subproject)
|
|
|
|
|
2021-09-21 22:23:55 +00:00
|
|
|
repo_hooks_project = None
|
|
|
|
enabled_repo_hooks = None
|
2012-04-21 07:33:54 +00:00
|
|
|
for node in itertools.chain(*node_list):
|
2008-10-21 14:00:00 +00:00
|
|
|
if node.nodeName == 'project':
|
|
|
|
project = self._ParseProject(node)
|
Represent git-submodule as nested projects, take 2
(Previous submission of this change broke Android buildbot due to
incorrect regular expression for parsing git-config output. During
investigation, we also found that Android, which pulls Chromium, has a
workaround for Chromium's submodules; its manifest includes Chromium's
submodules. This new change, in addition to fixing the regex, also
take this type of workarounds into consideration; it adds a new
attribute that makes repo not fetch submodules unless submodules have a
project element defined in the manifest, or this attribute is
overridden by a parent project element or by the default element.)
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I4b8344c1b9ccad2f58ad304573133e5d52e1faef
2012-01-11 03:28:42 +00:00
|
|
|
recursively_add_projects(project)
|
2014-06-12 21:57:29 +00:00
|
|
|
if node.nodeName == 'extend-project':
|
|
|
|
name = self._reqatt(node, 'name')
|
|
|
|
|
|
|
|
if name not in self._projects:
|
|
|
|
raise ManifestParseError('extend-project element specifies non-existent '
|
|
|
|
'project: %s' % name)
|
|
|
|
|
|
|
|
path = node.getAttribute('path')
|
2020-06-13 09:10:40 +00:00
|
|
|
dest_path = node.getAttribute('dest-path')
|
2014-06-12 21:57:29 +00:00
|
|
|
groups = node.getAttribute('groups')
|
|
|
|
if groups:
|
2020-12-04 10:32:06 +00:00
|
|
|
groups = self._ParseList(groups)
|
2018-03-15 16:54:08 +00:00
|
|
|
revision = node.getAttribute('revision')
|
2021-11-18 22:40:18 +00:00
|
|
|
remote_name = node.getAttribute('remote')
|
|
|
|
if not remote_name:
|
|
|
|
remote = self._default.remote
|
|
|
|
else:
|
2020-02-04 02:38:53 +00:00
|
|
|
remote = self._get_remote(node)
|
2022-09-09 15:13:17 +00:00
|
|
|
dest_branch = node.getAttribute('dest-branch')
|
|
|
|
upstream = node.getAttribute('upstream')
|
2014-06-12 21:57:29 +00:00
|
|
|
|
2020-06-13 09:10:40 +00:00
|
|
|
named_projects = self._projects[name]
|
|
|
|
if dest_path and not path and len(named_projects) > 1:
|
|
|
|
raise ManifestParseError('extend-project cannot use dest-path when '
|
|
|
|
'matching multiple projects: %s' % name)
|
2014-06-12 21:57:29 +00:00
|
|
|
for p in self._projects[name]:
|
|
|
|
if path and p.relpath != path:
|
|
|
|
continue
|
|
|
|
if groups:
|
|
|
|
p.groups.extend(groups)
|
2018-03-15 16:54:08 +00:00
|
|
|
if revision:
|
2020-07-22 02:40:38 +00:00
|
|
|
p.SetRevision(revision)
|
|
|
|
|
2021-11-18 22:40:18 +00:00
|
|
|
if remote_name:
|
2020-02-04 02:38:53 +00:00
|
|
|
p.remote = remote.ToRemoteSpec(name)
|
2022-09-09 15:13:17 +00:00
|
|
|
if dest_branch:
|
|
|
|
p.dest_branch = dest_branch
|
|
|
|
if upstream:
|
|
|
|
p.upstream = upstream
|
2020-07-22 02:40:38 +00:00
|
|
|
|
2020-06-13 09:10:40 +00:00
|
|
|
if dest_path:
|
|
|
|
del self._paths[p.relpath]
|
2021-11-18 22:40:18 +00:00
|
|
|
relpath, worktree, gitdir, objdir, _ = self.GetProjectPaths(
|
|
|
|
name, dest_path, remote.name)
|
2020-06-13 09:10:40 +00:00
|
|
|
p.UpdatePaths(relpath, worktree, gitdir, objdir)
|
|
|
|
self._paths[p.relpath] = p
|
|
|
|
|
Support repo-level pre-upload hook and prep for future hooks.
All repo-level hooks are expected to live in a single project at the
top level of that project. The name of the hooks project is provided
in the manifest.xml. The manifest also lists which hooks are enabled
to make it obvious if a file somehow failed to sync down (or got
deleted).
Before running any hook, we will prompt the user to make sure that it
is OK. A user can deny running the hook, allow once, or allow
"forever" (until hooks change). This tries to keep with the git
spirit of not automatically running anything on the user's computer
that got synced down. Note that individual repo commands can add
always options to avoid these prompts as they see fit (see below for
the 'upload' options).
When hooks are run, they are loaded into the current interpreter (the
one running repo) and their main() function is run. This mechanism is
used (instead of using subprocess) to make it easier to expand to a
richer hook interface in the future. During loading, the
interpreter's sys.path is updated to contain the directory containing
the hooks so that hooks can be split into multiple files.
The upload command has two options that control hook behavior:
- no-verify=False, verify=False (DEFAULT):
If stdout is a tty, can prompt about running upload hooks if needed.
If user denies running hooks, the upload is cancelled. If stdout is
not a tty and we would need to prompt about upload hooks, upload is
cancelled.
- no-verify=False, verify=True:
Always run upload hooks with no prompt.
- no-verify=True, verify=False:
Never run upload hooks, but upload anyway (AKA bypass hooks).
- no-verify=True, verify=True:
Invalid
Sample bit of manifest.xml code for enabling hooks (assumes you have a
project named 'hooks' where hooks are stored):
<repo-hooks in-project="hooks" enabled-list="pre-upload" />
Sample main() function in pre-upload.py in hooks directory:
def main(project_list, **kwargs):
print ('These projects will be uploaded: %s' %
', '.join(project_list))
print ('I am being a good boy and ignoring anything in kwargs\n'
'that I don\'t understand.')
print 'I fail 50% of the time. How flaky.'
if random.random() <= .5:
raise Exception('Pre-upload hook failed. Have a nice day.')
Change-Id: I5cefa2cd5865c72589263cf8e2f152a43c122f70
2011-03-04 19:54:18 +00:00
|
|
|
if node.nodeName == 'repo-hooks':
|
|
|
|
# Only one project can be the hooks project
|
2021-09-21 22:23:55 +00:00
|
|
|
if repo_hooks_project is not None:
|
Support repo-level pre-upload hook and prep for future hooks.
All repo-level hooks are expected to live in a single project at the
top level of that project. The name of the hooks project is provided
in the manifest.xml. The manifest also lists which hooks are enabled
to make it obvious if a file somehow failed to sync down (or got
deleted).
Before running any hook, we will prompt the user to make sure that it
is OK. A user can deny running the hook, allow once, or allow
"forever" (until hooks change). This tries to keep with the git
spirit of not automatically running anything on the user's computer
that got synced down. Note that individual repo commands can add
always options to avoid these prompts as they see fit (see below for
the 'upload' options).
When hooks are run, they are loaded into the current interpreter (the
one running repo) and their main() function is run. This mechanism is
used (instead of using subprocess) to make it easier to expand to a
richer hook interface in the future. During loading, the
interpreter's sys.path is updated to contain the directory containing
the hooks so that hooks can be split into multiple files.
The upload command has two options that control hook behavior:
- no-verify=False, verify=False (DEFAULT):
If stdout is a tty, can prompt about running upload hooks if needed.
If user denies running hooks, the upload is cancelled. If stdout is
not a tty and we would need to prompt about upload hooks, upload is
cancelled.
- no-verify=False, verify=True:
Always run upload hooks with no prompt.
- no-verify=True, verify=False:
Never run upload hooks, but upload anyway (AKA bypass hooks).
- no-verify=True, verify=True:
Invalid
Sample bit of manifest.xml code for enabling hooks (assumes you have a
project named 'hooks' where hooks are stored):
<repo-hooks in-project="hooks" enabled-list="pre-upload" />
Sample main() function in pre-upload.py in hooks directory:
def main(project_list, **kwargs):
print ('These projects will be uploaded: %s' %
', '.join(project_list))
print ('I am being a good boy and ignoring anything in kwargs\n'
'that I don\'t understand.')
print 'I fail 50% of the time. How flaky.'
if random.random() <= .5:
raise Exception('Pre-upload hook failed. Have a nice day.')
Change-Id: I5cefa2cd5865c72589263cf8e2f152a43c122f70
2011-03-04 19:54:18 +00:00
|
|
|
raise ManifestParseError(
|
|
|
|
'duplicate repo-hooks in %s' %
|
|
|
|
(self.manifestFile))
|
|
|
|
|
2021-09-21 22:23:55 +00:00
|
|
|
# Get the name of the project and the (space-separated) list of enabled.
|
|
|
|
repo_hooks_project = self._reqatt(node, 'in-project')
|
|
|
|
enabled_repo_hooks = self._ParseList(self._reqatt(node, 'enabled-list'))
|
2021-01-08 00:50:45 +00:00
|
|
|
if node.nodeName == 'superproject':
|
|
|
|
name = self._reqatt(node, 'name')
|
|
|
|
# There can only be one superproject.
|
2022-04-07 18:14:46 +00:00
|
|
|
if self._superproject:
|
2021-01-08 00:50:45 +00:00
|
|
|
raise ManifestParseError(
|
|
|
|
'duplicate superproject in %s' %
|
|
|
|
(self.manifestFile))
|
|
|
|
remote_name = node.getAttribute('remote')
|
|
|
|
if not remote_name:
|
|
|
|
remote = self._default.remote
|
|
|
|
else:
|
|
|
|
remote = self._get_remote(node)
|
|
|
|
if remote is None:
|
|
|
|
raise ManifestParseError("no remote for superproject %s within %s" %
|
|
|
|
(name, self.manifestFile))
|
2021-09-27 06:20:32 +00:00
|
|
|
revision = node.getAttribute('revision') or remote.revision
|
|
|
|
if not revision:
|
|
|
|
revision = self._default.revisionExpr
|
|
|
|
if not revision:
|
|
|
|
raise ManifestParseError('no revision for superproject %s within %s' %
|
|
|
|
(name, self.manifestFile))
|
2022-04-07 18:14:46 +00:00
|
|
|
self._superproject = Superproject(self,
|
|
|
|
name=name,
|
|
|
|
remote=remote.ToRemoteSpec(name),
|
|
|
|
revision=revision)
|
2021-05-04 19:32:13 +00:00
|
|
|
if node.nodeName == 'contactinfo':
|
|
|
|
bugurl = self._reqatt(node, 'bugurl')
|
|
|
|
# This element can be repeated, later entries will clobber earlier ones.
|
2021-05-12 19:00:31 +00:00
|
|
|
self._contactinfo = ContactInfo(bugurl)
|
|
|
|
|
2012-04-21 07:33:54 +00:00
|
|
|
if node.nodeName == 'remove-project':
|
|
|
|
name = self._reqatt(node, 'name')
|
2014-01-30 18:11:17 +00:00
|
|
|
|
2021-06-30 08:58:28 +00:00
|
|
|
if name in self._projects:
|
|
|
|
for p in self._projects[name]:
|
|
|
|
del self._paths[p.relpath]
|
|
|
|
del self._projects[name]
|
|
|
|
|
|
|
|
# If the manifest removes the hooks project, treat it as if it deleted
|
|
|
|
# the repo-hooks element too.
|
2021-09-21 22:23:55 +00:00
|
|
|
if repo_hooks_project == name:
|
|
|
|
repo_hooks_project = None
|
2021-06-30 08:58:28 +00:00
|
|
|
elif not XmlBool(node, 'optional', False):
|
2012-11-16 10:12:32 +00:00
|
|
|
raise ManifestParseError('remove-project element specifies non-existent '
|
|
|
|
'project: %s' % name)
|
2012-04-21 07:33:54 +00:00
|
|
|
|
2021-09-21 22:23:55 +00:00
|
|
|
# Store repo hooks project information.
|
|
|
|
if repo_hooks_project:
|
|
|
|
# Store a reference to the Project.
|
|
|
|
try:
|
|
|
|
repo_hooks_projects = self._projects[repo_hooks_project]
|
|
|
|
except KeyError:
|
|
|
|
raise ManifestParseError(
|
|
|
|
'project %s not found for repo-hooks' %
|
|
|
|
(repo_hooks_project))
|
|
|
|
|
|
|
|
if len(repo_hooks_projects) != 1:
|
|
|
|
raise ManifestParseError(
|
|
|
|
'internal error parsing repo-hooks in %s' %
|
|
|
|
(self.manifestFile))
|
|
|
|
self._repo_hooks_project = repo_hooks_projects[0]
|
|
|
|
# Store the enabled hooks in the Project object.
|
|
|
|
self._repo_hooks_project.enabled_repo_hooks = enabled_repo_hooks
|
|
|
|
|
2008-11-04 15:37:10 +00:00
|
|
|
def _AddMetaProjectMirror(self, m):
|
|
|
|
name = None
|
2022-07-10 08:56:04 +00:00
|
|
|
m_url = m.GetRemote().url
|
2008-11-04 15:37:10 +00:00
|
|
|
if m_url.endswith('/.git'):
|
2013-03-01 13:44:38 +00:00
|
|
|
raise ManifestParseError('refusing to mirror %s' % m_url)
|
2008-11-04 15:37:10 +00:00
|
|
|
|
|
|
|
if self._default and self._default.remote:
|
2011-10-20 17:45:47 +00:00
|
|
|
url = self._default.remote.resolvedFetchUrl
|
2008-11-04 15:37:10 +00:00
|
|
|
if not url.endswith('/'):
|
|
|
|
url += '/'
|
|
|
|
if m_url.startswith(url):
|
|
|
|
remote = self._default.remote
|
|
|
|
name = m_url[len(url):]
|
|
|
|
|
|
|
|
if name is None:
|
|
|
|
s = m_url.rindex('/') + 1
|
2011-09-26 23:34:01 +00:00
|
|
|
manifestUrl = self.manifestProject.config.GetString('remote.origin.url')
|
2012-08-02 18:46:22 +00:00
|
|
|
remote = _XmlRemote('origin', fetch=m_url[:s], manifestUrl=manifestUrl)
|
2008-11-04 15:37:10 +00:00
|
|
|
name = m_url[s:]
|
|
|
|
|
|
|
|
if name.endswith('.git'):
|
|
|
|
name = name[:-4]
|
|
|
|
|
|
|
|
if name not in self._projects:
|
|
|
|
m.PreSync()
|
|
|
|
gitdir = os.path.join(self.topdir, '%s.git' % name)
|
2020-02-12 04:56:59 +00:00
|
|
|
project = Project(manifest=self,
|
|
|
|
name=name,
|
|
|
|
remote=remote.ToRemoteSpec(name),
|
|
|
|
gitdir=gitdir,
|
|
|
|
objdir=gitdir,
|
|
|
|
worktree=None,
|
|
|
|
relpath=name or None,
|
|
|
|
revisionExpr=m.revisionExpr,
|
|
|
|
revisionId=None)
|
2013-10-12 00:03:19 +00:00
|
|
|
self._projects[project.name] = [project]
|
2014-02-17 04:07:32 +00:00
|
|
|
self._paths[project.relpath] = project
|
2008-11-04 15:37:10 +00:00
|
|
|
|
2008-10-21 14:00:00 +00:00
|
|
|
def _ParseRemote(self, node):
|
|
|
|
"""
|
|
|
|
reads a <remote> element from the manifest file
|
|
|
|
"""
|
|
|
|
name = self._reqatt(node, 'name')
|
2012-07-02 14:32:50 +00:00
|
|
|
alias = node.getAttribute('alias')
|
|
|
|
if alias == '':
|
|
|
|
alias = None
|
2008-10-21 14:00:00 +00:00
|
|
|
fetch = self._reqatt(node, 'fetch')
|
2016-08-10 22:00:00 +00:00
|
|
|
pushUrl = node.getAttribute('pushurl')
|
|
|
|
if pushUrl == '':
|
|
|
|
pushUrl = None
|
2008-10-21 14:00:00 +00:00
|
|
|
review = node.getAttribute('review')
|
2008-11-06 18:25:35 +00:00
|
|
|
if review == '':
|
|
|
|
review = None
|
2014-05-06 10:54:01 +00:00
|
|
|
revision = node.getAttribute('revision')
|
|
|
|
if revision == '':
|
|
|
|
revision = None
|
2011-09-26 23:34:01 +00:00
|
|
|
manifestUrl = self.manifestProject.config.GetString('remote.origin.url')
|
2021-07-20 20:52:33 +00:00
|
|
|
|
|
|
|
remote = _XmlRemote(name, alias, fetch, pushUrl, manifestUrl, review, revision)
|
|
|
|
|
|
|
|
for n in node.childNodes:
|
|
|
|
if n.nodeName == 'annotation':
|
|
|
|
self._ParseAnnotation(remote, n)
|
|
|
|
|
|
|
|
return remote
|
2008-10-21 14:00:00 +00:00
|
|
|
|
|
|
|
def _ParseDefault(self, node):
|
|
|
|
"""
|
|
|
|
reads a <default> element from the manifest file
|
|
|
|
"""
|
|
|
|
d = _Default()
|
|
|
|
d.remote = self._get_remote(node)
|
2009-05-30 01:38:17 +00:00
|
|
|
d.revisionExpr = node.getAttribute('revision')
|
|
|
|
if d.revisionExpr == '':
|
|
|
|
d.revisionExpr = None
|
2012-04-20 21:41:59 +00:00
|
|
|
|
2013-05-06 17:36:24 +00:00
|
|
|
d.destBranchExpr = node.getAttribute('dest-branch') or None
|
2018-05-04 18:53:29 +00:00
|
|
|
d.upstreamExpr = node.getAttribute('upstream') or None
|
2013-05-06 17:36:24 +00:00
|
|
|
|
sync: rework --jobs to provide better defaults
For --jobs-network, the logic is now:
* If the user specifies --jobs-network, use that.
* Else, if the user specifies --jobs, use that.
* Else, if the manifest specifies sync-j, use that.
* Else, default to 1.
Then we limit the jobs count based on the softlimit RLIMIT_NOFILE.
For --jobs-checkout, the logic is now:
* If the user specifies --jobs-checkout, use that.
* Else, if the user specifies --jobs, use that.
* Else, if the manifest specifies sync-j, use that.
* Else, default to DEFAULT_LOCAL_JOBS which is based on user's ncpus.
Then we limit the jobs count based on the softlimit RLIMIT_NOFILE.
For garbage collecting, the logic is now:
* If the user specifies --jobs, use that.
* Else, if the manifest specifies sync-j, use that.
* Else, default to the user's ncpus.
Then we limit the jobs count based on the softlimit RLIMIT_NOFILE.
Having to factor in the manifest settings makes this more complicated
which is why we delay processing of defaults until after we've synced
the manifest projects.
Bug: http://b/239712300
Change-Id: Id27cda63c76c156f1d63f6a20cb2c4ceeb3d547c
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/341394
Tested-by: Mike Frysinger <vapier@google.com>
Reviewed-by: LaMont Jones <lamontjones@google.com>
2022-07-20 21:15:29 +00:00
|
|
|
d.sync_j = XmlInt(node, 'sync-j', None)
|
|
|
|
if d.sync_j is not None and d.sync_j <= 0:
|
2020-02-22 10:30:12 +00:00
|
|
|
raise ManifestParseError('%s: sync-j must be greater than 0, not "%s"' %
|
|
|
|
(self.manifestFile, d.sync_j))
|
2018-02-14 07:57:31 +00:00
|
|
|
|
2020-02-22 10:30:12 +00:00
|
|
|
d.sync_c = XmlBool(node, 'sync-c', False)
|
|
|
|
d.sync_s = XmlBool(node, 'sync-s', False)
|
|
|
|
d.sync_tags = XmlBool(node, 'sync-tags', True)
|
2008-10-21 14:00:00 +00:00
|
|
|
return d
|
|
|
|
|
2010-11-01 22:08:06 +00:00
|
|
|
def _ParseNotice(self, node):
|
|
|
|
"""
|
|
|
|
reads a <notice> element from the manifest file
|
|
|
|
|
|
|
|
The <notice> element is distinct from other tags in the XML in that the
|
|
|
|
data is conveyed between the start and end tag (it's not an empty-element
|
|
|
|
tag).
|
|
|
|
|
|
|
|
The white space (carriage returns, indentation) for the notice element is
|
|
|
|
relevant and is parsed in a way that is based on how python docstrings work.
|
|
|
|
In fact, the code is remarkably similar to here:
|
|
|
|
http://www.python.org/dev/peps/pep-0257/
|
|
|
|
"""
|
|
|
|
# Get the data out of the node...
|
|
|
|
notice = node.childNodes[0].data
|
|
|
|
|
|
|
|
# Figure out minimum indentation, skipping the first line (the same line
|
|
|
|
# as the <notice> tag)...
|
2013-03-01 13:44:38 +00:00
|
|
|
minIndent = sys.maxsize
|
2010-11-01 22:08:06 +00:00
|
|
|
lines = notice.splitlines()
|
|
|
|
for line in lines[1:]:
|
|
|
|
lstrippedLine = line.lstrip()
|
|
|
|
if lstrippedLine:
|
|
|
|
indent = len(line) - len(lstrippedLine)
|
|
|
|
minIndent = min(indent, minIndent)
|
|
|
|
|
|
|
|
# Strip leading / trailing blank lines and also indentation.
|
|
|
|
cleanLines = [lines[0].strip()]
|
|
|
|
for line in lines[1:]:
|
|
|
|
cleanLines.append(line[minIndent:].rstrip())
|
|
|
|
|
|
|
|
# Clear completely blank lines from front and back...
|
|
|
|
while cleanLines and not cleanLines[0]:
|
|
|
|
del cleanLines[0]
|
|
|
|
while cleanLines and not cleanLines[-1]:
|
|
|
|
del cleanLines[-1]
|
|
|
|
|
|
|
|
return '\n'.join(cleanLines)
|
|
|
|
|
2021-11-18 22:40:18 +00:00
|
|
|
def _ParseSubmanifest(self, node):
|
|
|
|
"""Reads a <submanifest> element from the manifest file."""
|
|
|
|
name = self._reqatt(node, 'name')
|
|
|
|
remote = node.getAttribute('remote')
|
|
|
|
if remote == '':
|
|
|
|
remote = None
|
|
|
|
project = node.getAttribute('project')
|
|
|
|
if project == '':
|
|
|
|
project = None
|
|
|
|
revision = node.getAttribute('revision')
|
|
|
|
if revision == '':
|
|
|
|
revision = None
|
|
|
|
manifestName = node.getAttribute('manifest-name')
|
|
|
|
if manifestName == '':
|
|
|
|
manifestName = None
|
|
|
|
groups = ''
|
|
|
|
if node.hasAttribute('groups'):
|
|
|
|
groups = node.getAttribute('groups')
|
|
|
|
groups = self._ParseList(groups)
|
2022-04-20 16:42:32 +00:00
|
|
|
default_groups = self._ParseList(node.getAttribute('default-groups'))
|
2021-11-18 22:40:18 +00:00
|
|
|
path = node.getAttribute('path')
|
|
|
|
if path == '':
|
|
|
|
path = None
|
|
|
|
if revision:
|
|
|
|
msg = self._CheckLocalPath(revision.split('/')[-1])
|
|
|
|
if msg:
|
|
|
|
raise ManifestInvalidPathError(
|
|
|
|
'<submanifest> invalid "revision": %s: %s' % (revision, msg))
|
|
|
|
else:
|
|
|
|
msg = self._CheckLocalPath(name)
|
|
|
|
if msg:
|
|
|
|
raise ManifestInvalidPathError(
|
|
|
|
'<submanifest> invalid "name": %s: %s' % (name, msg))
|
|
|
|
else:
|
|
|
|
msg = self._CheckLocalPath(path)
|
|
|
|
if msg:
|
|
|
|
raise ManifestInvalidPathError(
|
|
|
|
'<submanifest> invalid "path": %s: %s' % (path, msg))
|
|
|
|
|
|
|
|
submanifest = _XmlSubmanifest(name, remote, project, revision, manifestName,
|
2022-04-20 16:42:32 +00:00
|
|
|
groups, default_groups, path, self)
|
2021-11-18 22:40:18 +00:00
|
|
|
|
|
|
|
for n in node.childNodes:
|
|
|
|
if n.nodeName == 'annotation':
|
|
|
|
self._ParseAnnotation(submanifest, n)
|
|
|
|
|
|
|
|
return submanifest
|
|
|
|
|
Represent git-submodule as nested projects, take 2
(Previous submission of this change broke Android buildbot due to
incorrect regular expression for parsing git-config output. During
investigation, we also found that Android, which pulls Chromium, has a
workaround for Chromium's submodules; its manifest includes Chromium's
submodules. This new change, in addition to fixing the regex, also
take this type of workarounds into consideration; it adds a new
attribute that makes repo not fetch submodules unless submodules have a
project element defined in the manifest, or this attribute is
overridden by a parent project element or by the default element.)
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I4b8344c1b9ccad2f58ad304573133e5d52e1faef
2012-01-11 03:28:42 +00:00
|
|
|
def _JoinName(self, parent_name, name):
|
|
|
|
return os.path.join(parent_name, name)
|
|
|
|
|
|
|
|
def _UnjoinName(self, parent_name, name):
|
|
|
|
return os.path.relpath(name, parent_name)
|
|
|
|
|
2020-02-12 04:56:59 +00:00
|
|
|
def _ParseProject(self, node, parent=None, **extra_proj_attrs):
|
2008-10-21 14:00:00 +00:00
|
|
|
"""
|
|
|
|
reads a <project> element from the manifest file
|
2010-04-06 17:40:01 +00:00
|
|
|
"""
|
2008-10-21 14:00:00 +00:00
|
|
|
name = self._reqatt(node, 'name')
|
2021-02-26 02:53:49 +00:00
|
|
|
msg = self._CheckLocalPath(name, dir_ok=True)
|
|
|
|
if msg:
|
|
|
|
raise ManifestInvalidPathError(
|
|
|
|
'<project> invalid "name": %s: %s' % (name, msg))
|
Represent git-submodule as nested projects, take 2
(Previous submission of this change broke Android buildbot due to
incorrect regular expression for parsing git-config output. During
investigation, we also found that Android, which pulls Chromium, has a
workaround for Chromium's submodules; its manifest includes Chromium's
submodules. This new change, in addition to fixing the regex, also
take this type of workarounds into consideration; it adds a new
attribute that makes repo not fetch submodules unless submodules have a
project element defined in the manifest, or this attribute is
overridden by a parent project element or by the default element.)
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I4b8344c1b9ccad2f58ad304573133e5d52e1faef
2012-01-11 03:28:42 +00:00
|
|
|
if parent:
|
|
|
|
name = self._JoinName(parent.name, name)
|
2008-10-21 14:00:00 +00:00
|
|
|
|
|
|
|
remote = self._get_remote(node)
|
|
|
|
if remote is None:
|
|
|
|
remote = self._default.remote
|
|
|
|
if remote is None:
|
2013-03-01 13:44:38 +00:00
|
|
|
raise ManifestParseError("no remote for project %s within %s" %
|
2020-02-12 05:58:39 +00:00
|
|
|
(name, self.manifestFile))
|
2008-10-21 14:00:00 +00:00
|
|
|
|
2014-05-06 10:54:01 +00:00
|
|
|
revisionExpr = node.getAttribute('revision') or remote.revision
|
2009-05-30 01:38:17 +00:00
|
|
|
if not revisionExpr:
|
|
|
|
revisionExpr = self._default.revisionExpr
|
|
|
|
if not revisionExpr:
|
2013-03-01 13:44:38 +00:00
|
|
|
raise ManifestParseError("no revision for project %s within %s" %
|
2020-02-12 05:58:39 +00:00
|
|
|
(name, self.manifestFile))
|
2008-10-21 14:00:00 +00:00
|
|
|
|
|
|
|
path = node.getAttribute('path')
|
|
|
|
if not path:
|
|
|
|
path = name
|
2021-02-26 02:53:49 +00:00
|
|
|
else:
|
2021-03-11 04:35:44 +00:00
|
|
|
# NB: The "." project is handled specially in Project.Sync_LocalHalf.
|
|
|
|
msg = self._CheckLocalPath(path, dir_ok=True, cwd_dot_ok=True)
|
2021-02-26 02:53:49 +00:00
|
|
|
if msg:
|
|
|
|
raise ManifestInvalidPathError(
|
|
|
|
'<project> invalid "path": %s: %s' % (path, msg))
|
2008-10-21 14:00:00 +00:00
|
|
|
|
2020-02-22 10:30:12 +00:00
|
|
|
rebase = XmlBool(node, 'rebase', True)
|
|
|
|
sync_c = XmlBool(node, 'sync-c', False)
|
|
|
|
sync_s = XmlBool(node, 'sync-s', self._default.sync_s)
|
|
|
|
sync_tags = XmlBool(node, 'sync-tags', self._default.sync_tags)
|
2018-02-14 07:57:31 +00:00
|
|
|
|
2020-02-22 10:30:12 +00:00
|
|
|
clone_depth = XmlInt(node, 'clone-depth')
|
|
|
|
if clone_depth is not None and clone_depth <= 0:
|
|
|
|
raise ManifestParseError('%s: clone-depth must be greater than 0, not "%s"' %
|
|
|
|
(self.manifestFile, clone_depth))
|
2012-11-27 13:25:30 +00:00
|
|
|
|
2013-05-06 17:36:24 +00:00
|
|
|
dest_branch = node.getAttribute('dest-branch') or self._default.destBranchExpr
|
|
|
|
|
2018-05-04 18:53:29 +00:00
|
|
|
upstream = node.getAttribute('upstream') or self._default.upstreamExpr
|
2012-09-29 03:21:57 +00:00
|
|
|
|
2012-04-16 17:36:08 +00:00
|
|
|
groups = ''
|
|
|
|
if node.hasAttribute('groups'):
|
|
|
|
groups = node.getAttribute('groups')
|
2020-12-04 10:32:06 +00:00
|
|
|
groups = self._ParseList(groups)
|
2012-06-15 09:24:20 +00:00
|
|
|
|
Represent git-submodule as nested projects, take 2
(Previous submission of this change broke Android buildbot due to
incorrect regular expression for parsing git-config output. During
investigation, we also found that Android, which pulls Chromium, has a
workaround for Chromium's submodules; its manifest includes Chromium's
submodules. This new change, in addition to fixing the regex, also
take this type of workarounds into consideration; it adds a new
attribute that makes repo not fetch submodules unless submodules have a
project element defined in the manifest, or this attribute is
overridden by a parent project element or by the default element.)
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I4b8344c1b9ccad2f58ad304573133e5d52e1faef
2012-01-11 03:28:42 +00:00
|
|
|
if parent is None:
|
2020-02-09 07:28:34 +00:00
|
|
|
relpath, worktree, gitdir, objdir, use_git_worktrees = \
|
2021-11-18 22:40:18 +00:00
|
|
|
self.GetProjectPaths(name, path, remote.name)
|
2012-10-26 19:18:00 +00:00
|
|
|
else:
|
2020-02-09 07:28:34 +00:00
|
|
|
use_git_worktrees = False
|
2013-10-12 00:03:19 +00:00
|
|
|
relpath, worktree, gitdir, objdir = \
|
|
|
|
self.GetSubprojectPaths(parent, name, path)
|
Represent git-submodule as nested projects, take 2
(Previous submission of this change broke Android buildbot due to
incorrect regular expression for parsing git-config output. During
investigation, we also found that Android, which pulls Chromium, has a
workaround for Chromium's submodules; its manifest includes Chromium's
submodules. This new change, in addition to fixing the regex, also
take this type of workarounds into consideration; it adds a new
attribute that makes repo not fetch submodules unless submodules have a
project element defined in the manifest, or this attribute is
overridden by a parent project element or by the default element.)
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I4b8344c1b9ccad2f58ad304573133e5d52e1faef
2012-01-11 03:28:42 +00:00
|
|
|
|
|
|
|
default_groups = ['all', 'name:%s' % name, 'path:%s' % relpath]
|
|
|
|
groups.extend(set(default_groups).difference(groups))
|
2012-10-26 19:18:00 +00:00
|
|
|
|
2013-02-28 01:34:14 +00:00
|
|
|
if self.IsMirror and node.hasAttribute('force-path'):
|
2020-02-22 10:30:12 +00:00
|
|
|
if XmlBool(node, 'force-path', False):
|
2013-02-28 01:34:14 +00:00
|
|
|
gitdir = os.path.join(self.topdir, '%s.git' % path)
|
|
|
|
|
2020-02-12 04:56:59 +00:00
|
|
|
project = Project(manifest=self,
|
|
|
|
name=name,
|
|
|
|
remote=remote.ToRemoteSpec(name),
|
|
|
|
gitdir=gitdir,
|
|
|
|
objdir=objdir,
|
|
|
|
worktree=worktree,
|
|
|
|
relpath=relpath,
|
|
|
|
revisionExpr=revisionExpr,
|
|
|
|
revisionId=None,
|
|
|
|
rebase=rebase,
|
|
|
|
groups=groups,
|
|
|
|
sync_c=sync_c,
|
|
|
|
sync_s=sync_s,
|
|
|
|
sync_tags=sync_tags,
|
|
|
|
clone_depth=clone_depth,
|
|
|
|
upstream=upstream,
|
|
|
|
parent=parent,
|
|
|
|
dest_branch=dest_branch,
|
2020-02-09 07:28:34 +00:00
|
|
|
use_git_worktrees=use_git_worktrees,
|
2015-08-20 19:19:28 +00:00
|
|
|
**extra_proj_attrs)
|
2008-10-21 14:00:00 +00:00
|
|
|
|
|
|
|
for n in node.childNodes:
|
2009-05-19 20:00:29 +00:00
|
|
|
if n.nodeName == 'copyfile':
|
2008-10-21 14:00:00 +00:00
|
|
|
self._ParseCopyFile(project, n)
|
2014-04-21 22:10:59 +00:00
|
|
|
if n.nodeName == 'linkfile':
|
|
|
|
self._ParseLinkFile(project, n)
|
2012-04-12 20:04:13 +00:00
|
|
|
if n.nodeName == 'annotation':
|
|
|
|
self._ParseAnnotation(project, n)
|
Represent git-submodule as nested projects, take 2
(Previous submission of this change broke Android buildbot due to
incorrect regular expression for parsing git-config output. During
investigation, we also found that Android, which pulls Chromium, has a
workaround for Chromium's submodules; its manifest includes Chromium's
submodules. This new change, in addition to fixing the regex, also
take this type of workarounds into consideration; it adds a new
attribute that makes repo not fetch submodules unless submodules have a
project element defined in the manifest, or this attribute is
overridden by a parent project element or by the default element.)
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I4b8344c1b9ccad2f58ad304573133e5d52e1faef
2012-01-11 03:28:42 +00:00
|
|
|
if n.nodeName == 'project':
|
2020-02-12 04:56:59 +00:00
|
|
|
project.subprojects.append(self._ParseProject(n, parent=project))
|
2008-10-21 14:00:00 +00:00
|
|
|
|
|
|
|
return project
|
|
|
|
|
2021-11-18 22:40:18 +00:00
|
|
|
def GetProjectPaths(self, name, path, remote):
|
|
|
|
"""Return the paths for a project.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: a string, the name of the project.
|
|
|
|
path: a string, the path of the project.
|
|
|
|
remote: a string, the remote.name of the project.
|
2022-06-01 21:03:34 +00:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
A tuple of (relpath, worktree, gitdir, objdir, use_git_worktrees) for the
|
|
|
|
project with |name| and |path|.
|
2021-11-18 22:40:18 +00:00
|
|
|
"""
|
2020-05-26 05:02:29 +00:00
|
|
|
# The manifest entries might have trailing slashes. Normalize them to avoid
|
|
|
|
# unexpected filesystem behavior since we do string concatenation below.
|
|
|
|
path = path.rstrip('/')
|
|
|
|
name = name.rstrip('/')
|
2021-11-18 22:40:18 +00:00
|
|
|
remote = remote.rstrip('/')
|
2020-02-09 07:28:34 +00:00
|
|
|
use_git_worktrees = False
|
2022-06-01 21:03:34 +00:00
|
|
|
use_remote_name = self.is_multimanifest
|
Represent git-submodule as nested projects, take 2
(Previous submission of this change broke Android buildbot due to
incorrect regular expression for parsing git-config output. During
investigation, we also found that Android, which pulls Chromium, has a
workaround for Chromium's submodules; its manifest includes Chromium's
submodules. This new change, in addition to fixing the regex, also
take this type of workarounds into consideration; it adds a new
attribute that makes repo not fetch submodules unless submodules have a
project element defined in the manifest, or this attribute is
overridden by a parent project element or by the default element.)
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I4b8344c1b9ccad2f58ad304573133e5d52e1faef
2012-01-11 03:28:42 +00:00
|
|
|
relpath = path
|
|
|
|
if self.IsMirror:
|
|
|
|
worktree = None
|
|
|
|
gitdir = os.path.join(self.topdir, '%s.git' % name)
|
2013-10-12 00:03:19 +00:00
|
|
|
objdir = gitdir
|
Represent git-submodule as nested projects, take 2
(Previous submission of this change broke Android buildbot due to
incorrect regular expression for parsing git-config output. During
investigation, we also found that Android, which pulls Chromium, has a
workaround for Chromium's submodules; its manifest includes Chromium's
submodules. This new change, in addition to fixing the regex, also
take this type of workarounds into consideration; it adds a new
attribute that makes repo not fetch submodules unless submodules have a
project element defined in the manifest, or this attribute is
overridden by a parent project element or by the default element.)
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I4b8344c1b9ccad2f58ad304573133e5d52e1faef
2012-01-11 03:28:42 +00:00
|
|
|
else:
|
2021-11-18 22:40:18 +00:00
|
|
|
if use_remote_name:
|
|
|
|
namepath = os.path.join(remote, f'{name}.git')
|
|
|
|
else:
|
|
|
|
namepath = f'{name}.git'
|
Represent git-submodule as nested projects, take 2
(Previous submission of this change broke Android buildbot due to
incorrect regular expression for parsing git-config output. During
investigation, we also found that Android, which pulls Chromium, has a
workaround for Chromium's submodules; its manifest includes Chromium's
submodules. This new change, in addition to fixing the regex, also
take this type of workarounds into consideration; it adds a new
attribute that makes repo not fetch submodules unless submodules have a
project element defined in the manifest, or this attribute is
overridden by a parent project element or by the default element.)
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I4b8344c1b9ccad2f58ad304573133e5d52e1faef
2012-01-11 03:28:42 +00:00
|
|
|
worktree = os.path.join(self.topdir, path).replace('\\', '/')
|
2021-11-18 22:40:18 +00:00
|
|
|
gitdir = os.path.join(self.subdir, 'projects', '%s.git' % path)
|
2020-02-09 07:28:34 +00:00
|
|
|
# We allow people to mix git worktrees & non-git worktrees for now.
|
|
|
|
# This allows for in situ migration of repo clients.
|
|
|
|
if os.path.exists(gitdir) or not self.UseGitWorktrees:
|
2021-12-21 05:40:31 +00:00
|
|
|
objdir = os.path.join(self.repodir, 'project-objects', namepath)
|
2020-02-09 07:28:34 +00:00
|
|
|
else:
|
|
|
|
use_git_worktrees = True
|
2021-11-18 22:40:18 +00:00
|
|
|
gitdir = os.path.join(self.repodir, 'worktrees', namepath)
|
2020-02-09 07:28:34 +00:00
|
|
|
objdir = gitdir
|
|
|
|
return relpath, worktree, gitdir, objdir, use_git_worktrees
|
2013-10-12 00:03:19 +00:00
|
|
|
|
2021-11-18 22:40:18 +00:00
|
|
|
def GetProjectsWithName(self, name, all_manifests=False):
|
|
|
|
"""All projects with |name|.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: a string, the name of the project.
|
|
|
|
all_manifests: a boolean, if True, then all manifests are searched. If
|
|
|
|
False, then only this manifest is searched.
|
2022-06-01 21:03:34 +00:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
A list of Project instances with name |name|.
|
2021-11-18 22:40:18 +00:00
|
|
|
"""
|
|
|
|
if all_manifests:
|
|
|
|
return list(itertools.chain.from_iterable(
|
|
|
|
x._projects.get(name, []) for x in self.all_manifests))
|
2013-10-12 00:03:19 +00:00
|
|
|
return self._projects.get(name, [])
|
Represent git-submodule as nested projects, take 2
(Previous submission of this change broke Android buildbot due to
incorrect regular expression for parsing git-config output. During
investigation, we also found that Android, which pulls Chromium, has a
workaround for Chromium's submodules; its manifest includes Chromium's
submodules. This new change, in addition to fixing the regex, also
take this type of workarounds into consideration; it adds a new
attribute that makes repo not fetch submodules unless submodules have a
project element defined in the manifest, or this attribute is
overridden by a parent project element or by the default element.)
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I4b8344c1b9ccad2f58ad304573133e5d52e1faef
2012-01-11 03:28:42 +00:00
|
|
|
|
|
|
|
def GetSubprojectName(self, parent, submodule_path):
|
|
|
|
return os.path.join(parent.name, submodule_path)
|
|
|
|
|
|
|
|
def _JoinRelpath(self, parent_relpath, relpath):
|
|
|
|
return os.path.join(parent_relpath, relpath)
|
|
|
|
|
|
|
|
def _UnjoinRelpath(self, parent_relpath, relpath):
|
|
|
|
return os.path.relpath(relpath, parent_relpath)
|
|
|
|
|
2013-10-12 00:03:19 +00:00
|
|
|
def GetSubprojectPaths(self, parent, name, path):
|
2020-05-26 05:02:29 +00:00
|
|
|
# The manifest entries might have trailing slashes. Normalize them to avoid
|
|
|
|
# unexpected filesystem behavior since we do string concatenation below.
|
|
|
|
path = path.rstrip('/')
|
|
|
|
name = name.rstrip('/')
|
Represent git-submodule as nested projects, take 2
(Previous submission of this change broke Android buildbot due to
incorrect regular expression for parsing git-config output. During
investigation, we also found that Android, which pulls Chromium, has a
workaround for Chromium's submodules; its manifest includes Chromium's
submodules. This new change, in addition to fixing the regex, also
take this type of workarounds into consideration; it adds a new
attribute that makes repo not fetch submodules unless submodules have a
project element defined in the manifest, or this attribute is
overridden by a parent project element or by the default element.)
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I4b8344c1b9ccad2f58ad304573133e5d52e1faef
2012-01-11 03:28:42 +00:00
|
|
|
relpath = self._JoinRelpath(parent.relpath, path)
|
|
|
|
gitdir = os.path.join(parent.gitdir, 'subprojects', '%s.git' % path)
|
2013-10-12 00:03:19 +00:00
|
|
|
objdir = os.path.join(parent.gitdir, 'subproject-objects', '%s.git' % name)
|
Represent git-submodule as nested projects, take 2
(Previous submission of this change broke Android buildbot due to
incorrect regular expression for parsing git-config output. During
investigation, we also found that Android, which pulls Chromium, has a
workaround for Chromium's submodules; its manifest includes Chromium's
submodules. This new change, in addition to fixing the regex, also
take this type of workarounds into consideration; it adds a new
attribute that makes repo not fetch submodules unless submodules have a
project element defined in the manifest, or this attribute is
overridden by a parent project element or by the default element.)
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I4b8344c1b9ccad2f58ad304573133e5d52e1faef
2012-01-11 03:28:42 +00:00
|
|
|
if self.IsMirror:
|
|
|
|
worktree = None
|
|
|
|
else:
|
|
|
|
worktree = os.path.join(parent.worktree, path).replace('\\', '/')
|
2013-10-12 00:03:19 +00:00
|
|
|
return relpath, worktree, gitdir, objdir
|
Represent git-submodule as nested projects, take 2
(Previous submission of this change broke Android buildbot due to
incorrect regular expression for parsing git-config output. During
investigation, we also found that Android, which pulls Chromium, has a
workaround for Chromium's submodules; its manifest includes Chromium's
submodules. This new change, in addition to fixing the regex, also
take this type of workarounds into consideration; it adds a new
attribute that makes repo not fetch submodules unless submodules have a
project element defined in the manifest, or this attribute is
overridden by a parent project element or by the default element.)
We need a representation of git-submodule in repo; otherwise repo will
not sync submodules, and leave workspace in a broken state. Of course
this will not be a problem if all projects are owned by the owner of the
manifest file, who may simply choose not to use git-submodule in all
projects. However, this is not possible in practice because manifest
file owner is unlikely to own all upstream projects.
As git submodules are simply git repositories, it is natural to treat
them as plain repo projects that live inside a repo project. That is,
we could use recursively declared projects to denote the is-submodule
relation of git repositories.
The behavior of repo remains the same to projects that do not have a
sub-project within. As for parent projects, repo fetches them and their
sub-projects as normal projects, and then checks out subprojects at the
commit specified in parent's commit object. The sub-project is fetched
at a path relative to parent project's working directory; so the path
specified in manifest file should match that of .gitmodules file.
If a submodule is not registered in repo manifest, repo will derive its
properties from itself and its parent project, which might not always be
correct. In such cases, the subproject is called a derived subproject.
To a user, a sub-project is merely a git-submodule; so all tips of
working with a git-submodule apply here, too. For example, you should
not run `repo sync` in a parent repository if its submodule is dirty.
Change-Id: I4b8344c1b9ccad2f58ad304573133e5d52e1faef
2012-01-11 03:28:42 +00:00
|
|
|
|
2019-08-01 03:32:58 +00:00
|
|
|
@staticmethod
|
2021-02-25 23:26:31 +00:00
|
|
|
def _CheckLocalPath(path, dir_ok=False, cwd_dot_ok=False):
|
|
|
|
"""Verify |path| is reasonable for use in filesystem paths.
|
|
|
|
|
2021-02-26 02:53:49 +00:00
|
|
|
Used with <copyfile> & <linkfile> & <project> elements.
|
2021-02-25 23:26:31 +00:00
|
|
|
|
|
|
|
This only validates the |path| in isolation: it does not check against the
|
|
|
|
current filesystem state. Thus it is suitable as a first-past in a parser.
|
|
|
|
|
|
|
|
It enforces a number of constraints:
|
|
|
|
* No empty paths.
|
|
|
|
* No "~" in paths.
|
|
|
|
* No Unicode codepoints that filesystems might elide when normalizing.
|
|
|
|
* No relative path components like "." or "..".
|
|
|
|
* No absolute paths.
|
|
|
|
* No ".git" or ".repo*" path components.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
path: The path name to validate.
|
|
|
|
dir_ok: Whether |path| may force a directory (e.g. end in a /).
|
|
|
|
cwd_dot_ok: Whether |path| may be just ".".
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
None if |path| is OK, a failure message otherwise.
|
|
|
|
"""
|
|
|
|
if not path:
|
|
|
|
return 'empty paths not allowed'
|
|
|
|
|
2019-08-01 03:32:58 +00:00
|
|
|
if '~' in path:
|
|
|
|
return '~ not allowed (due to 8.3 filenames on Windows filesystems)'
|
|
|
|
|
2021-04-30 03:15:31 +00:00
|
|
|
path_codepoints = set(path)
|
|
|
|
|
2019-08-01 03:32:58 +00:00
|
|
|
# Some filesystems (like Apple's HFS+) try to normalize Unicode codepoints
|
|
|
|
# which means there are alternative names for ".git". Reject paths with
|
|
|
|
# these in it as there shouldn't be any reasonable need for them here.
|
|
|
|
# The set of codepoints here was cribbed from jgit's implementation:
|
|
|
|
# https://eclipse.googlesource.com/jgit/jgit/+/9110037e3e9461ff4dac22fee84ef3694ed57648/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java#884
|
|
|
|
BAD_CODEPOINTS = {
|
|
|
|
u'\u200C', # ZERO WIDTH NON-JOINER
|
|
|
|
u'\u200D', # ZERO WIDTH JOINER
|
|
|
|
u'\u200E', # LEFT-TO-RIGHT MARK
|
|
|
|
u'\u200F', # RIGHT-TO-LEFT MARK
|
|
|
|
u'\u202A', # LEFT-TO-RIGHT EMBEDDING
|
|
|
|
u'\u202B', # RIGHT-TO-LEFT EMBEDDING
|
|
|
|
u'\u202C', # POP DIRECTIONAL FORMATTING
|
|
|
|
u'\u202D', # LEFT-TO-RIGHT OVERRIDE
|
|
|
|
u'\u202E', # RIGHT-TO-LEFT OVERRIDE
|
|
|
|
u'\u206A', # INHIBIT SYMMETRIC SWAPPING
|
|
|
|
u'\u206B', # ACTIVATE SYMMETRIC SWAPPING
|
|
|
|
u'\u206C', # INHIBIT ARABIC FORM SHAPING
|
|
|
|
u'\u206D', # ACTIVATE ARABIC FORM SHAPING
|
|
|
|
u'\u206E', # NATIONAL DIGIT SHAPES
|
|
|
|
u'\u206F', # NOMINAL DIGIT SHAPES
|
|
|
|
u'\uFEFF', # ZERO WIDTH NO-BREAK SPACE
|
|
|
|
}
|
2021-04-30 03:15:31 +00:00
|
|
|
if BAD_CODEPOINTS & path_codepoints:
|
2019-08-01 03:32:58 +00:00
|
|
|
# This message is more expansive than reality, but should be fine.
|
|
|
|
return 'Unicode combining characters not allowed'
|
|
|
|
|
2021-04-30 03:15:31 +00:00
|
|
|
# Reject newlines as there shouldn't be any legitmate use for them, they'll
|
|
|
|
# be confusing to users, and they can easily break tools that expect to be
|
|
|
|
# able to iterate over newline delimited lists. This even applies to our
|
|
|
|
# own code like .repo/project.list.
|
|
|
|
if {'\r', '\n'} & path_codepoints:
|
|
|
|
return 'Newlines not allowed'
|
|
|
|
|
2019-08-01 03:32:58 +00:00
|
|
|
# Assume paths might be used on case-insensitive filesystems.
|
|
|
|
path = path.lower()
|
|
|
|
|
2020-02-20 03:36:26 +00:00
|
|
|
# Split up the path by its components. We can't use os.path.sep exclusively
|
|
|
|
# as some platforms (like Windows) will convert / to \ and that bypasses all
|
|
|
|
# our constructed logic here. Especially since manifest authors only use
|
|
|
|
# / in their paths.
|
|
|
|
resep = re.compile(r'[/%s]' % re.escape(os.path.sep))
|
2021-03-11 04:35:44 +00:00
|
|
|
# Strip off trailing slashes as those only produce '' elements, and we use
|
|
|
|
# parts to look for individual bad components.
|
|
|
|
parts = resep.split(path.rstrip('/'))
|
2020-02-20 03:36:26 +00:00
|
|
|
|
2020-02-10 22:10:03 +00:00
|
|
|
# Some people use src="." to create stable links to projects. Lets allow
|
|
|
|
# that but reject all other uses of "." to keep things simple.
|
2021-02-25 23:26:31 +00:00
|
|
|
if not cwd_dot_ok or parts != ['.']:
|
2020-02-10 22:10:03 +00:00
|
|
|
for part in set(parts):
|
|
|
|
if part in {'.', '..', '.git'} or part.startswith('.repo'):
|
|
|
|
return 'bad component: %s' % (part,)
|
2019-08-01 03:32:58 +00:00
|
|
|
|
2021-02-25 23:26:31 +00:00
|
|
|
if not dir_ok and resep.match(path[-1]):
|
2019-08-01 03:32:58 +00:00
|
|
|
return 'dirs not allowed'
|
|
|
|
|
2020-02-20 03:36:26 +00:00
|
|
|
# NB: The two abspath checks here are to handle platforms with multiple
|
|
|
|
# filesystem path styles (e.g. Windows).
|
2019-08-01 03:32:58 +00:00
|
|
|
norm = os.path.normpath(path)
|
2020-02-20 03:36:26 +00:00
|
|
|
if (norm == '..' or
|
|
|
|
(len(norm) >= 3 and norm.startswith('..') and resep.match(norm[0])) or
|
|
|
|
os.path.isabs(norm) or
|
|
|
|
norm.startswith('/')):
|
2019-08-01 03:32:58 +00:00
|
|
|
return 'path cannot be outside'
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def _ValidateFilePaths(cls, element, src, dest):
|
|
|
|
"""Verify |src| & |dest| are reasonable for <copyfile> & <linkfile>.
|
|
|
|
|
|
|
|
We verify the path independent of any filesystem state as we won't have a
|
|
|
|
checkout available to compare to. i.e. This is for parsing validation
|
|
|
|
purposes only.
|
|
|
|
|
|
|
|
We'll do full/live sanity checking before we do the actual filesystem
|
|
|
|
modifications in _CopyFile/_LinkFile/etc...
|
|
|
|
"""
|
|
|
|
# |dest| is the file we write to or symlink we create.
|
|
|
|
# It is relative to the top of the repo client checkout.
|
|
|
|
msg = cls._CheckLocalPath(dest)
|
|
|
|
if msg:
|
|
|
|
raise ManifestInvalidPathError(
|
|
|
|
'<%s> invalid "dest": %s: %s' % (element, dest, msg))
|
|
|
|
|
|
|
|
# |src| is the file we read from or path we point to for symlinks.
|
|
|
|
# It is relative to the top of the git project checkout.
|
2021-02-25 23:26:31 +00:00
|
|
|
is_linkfile = element == 'linkfile'
|
|
|
|
msg = cls._CheckLocalPath(src, dir_ok=is_linkfile, cwd_dot_ok=is_linkfile)
|
2019-08-01 03:32:58 +00:00
|
|
|
if msg:
|
|
|
|
raise ManifestInvalidPathError(
|
|
|
|
'<%s> invalid "src": %s: %s' % (element, src, msg))
|
|
|
|
|
2008-10-21 14:00:00 +00:00
|
|
|
def _ParseCopyFile(self, project, node):
|
|
|
|
src = self._reqatt(node, 'src')
|
|
|
|
dest = self._reqatt(node, 'dest')
|
2008-11-04 15:37:10 +00:00
|
|
|
if not self.IsMirror:
|
|
|
|
# src is project relative;
|
2019-08-01 03:32:58 +00:00
|
|
|
# dest is relative to the top of the tree.
|
|
|
|
# We only validate paths if we actually plan to process them.
|
|
|
|
self._ValidateFilePaths('copyfile', src, dest)
|
2019-08-02 19:57:57 +00:00
|
|
|
project.AddCopyFile(src, dest, self.topdir)
|
2008-10-21 14:00:00 +00:00
|
|
|
|
2014-04-21 22:10:59 +00:00
|
|
|
def _ParseLinkFile(self, project, node):
|
|
|
|
src = self._reqatt(node, 'src')
|
|
|
|
dest = self._reqatt(node, 'dest')
|
|
|
|
if not self.IsMirror:
|
|
|
|
# src is project relative;
|
2019-08-01 03:32:58 +00:00
|
|
|
# dest is relative to the top of the tree.
|
|
|
|
# We only validate paths if we actually plan to process them.
|
|
|
|
self._ValidateFilePaths('linkfile', src, dest)
|
2019-08-02 19:57:57 +00:00
|
|
|
project.AddLinkFile(src, dest, self.topdir)
|
2014-04-21 22:10:59 +00:00
|
|
|
|
2021-07-20 20:52:33 +00:00
|
|
|
def _ParseAnnotation(self, element, node):
|
2012-04-12 20:04:13 +00:00
|
|
|
name = self._reqatt(node, 'name')
|
|
|
|
value = self._reqatt(node, 'value')
|
|
|
|
try:
|
|
|
|
keep = self._reqatt(node, 'keep').lower()
|
|
|
|
except ManifestParseError:
|
|
|
|
keep = "true"
|
|
|
|
if keep != "true" and keep != "false":
|
2013-03-01 13:44:38 +00:00
|
|
|
raise ManifestParseError('optional "keep" attribute must be '
|
2020-02-12 05:58:39 +00:00
|
|
|
'"true" or "false"')
|
2021-07-20 20:52:33 +00:00
|
|
|
element.AddAnnotation(name, value, keep)
|
2012-04-12 20:04:13 +00:00
|
|
|
|
2008-10-21 14:00:00 +00:00
|
|
|
def _get_remote(self, node):
|
|
|
|
name = node.getAttribute('remote')
|
|
|
|
if not name:
|
|
|
|
return None
|
|
|
|
|
|
|
|
v = self._remotes.get(name)
|
|
|
|
if not v:
|
2013-03-01 13:44:38 +00:00
|
|
|
raise ManifestParseError("remote %s not defined in %s" %
|
2020-02-12 05:58:39 +00:00
|
|
|
(name, self.manifestFile))
|
2008-10-21 14:00:00 +00:00
|
|
|
return v
|
|
|
|
|
|
|
|
def _reqatt(self, node, attname):
|
|
|
|
"""
|
|
|
|
reads a required attribute from the node.
|
|
|
|
"""
|
|
|
|
v = node.getAttribute(attname)
|
|
|
|
if not v:
|
2013-03-01 13:44:38 +00:00
|
|
|
raise ManifestParseError("no %s in <%s> within %s" %
|
2020-02-12 05:58:39 +00:00
|
|
|
(attname, node.nodeName, self.manifestFile))
|
2008-10-21 14:00:00 +00:00
|
|
|
return v
|
2014-01-09 15:21:37 +00:00
|
|
|
|
|
|
|
def projectsDiff(self, manifest):
|
|
|
|
"""return the projects differences between two manifests.
|
|
|
|
|
|
|
|
The diff will be from self to given manifest.
|
|
|
|
|
|
|
|
"""
|
|
|
|
fromProjects = self.paths
|
|
|
|
toProjects = manifest.paths
|
|
|
|
|
2014-05-06 08:19:39 +00:00
|
|
|
fromKeys = sorted(fromProjects.keys())
|
|
|
|
toKeys = sorted(toProjects.keys())
|
2014-01-09 15:21:37 +00:00
|
|
|
|
2022-09-05 06:35:47 +00:00
|
|
|
diff = {'added': [], 'removed': [], 'missing': [], 'changed': [], 'unreachable': []}
|
2014-01-09 15:21:37 +00:00
|
|
|
|
|
|
|
for proj in fromKeys:
|
2020-02-12 02:24:10 +00:00
|
|
|
if proj not in toKeys:
|
2014-01-09 15:21:37 +00:00
|
|
|
diff['removed'].append(fromProjects[proj])
|
2022-09-05 06:35:47 +00:00
|
|
|
elif not fromProjects[proj].Exists:
|
|
|
|
diff['missing'].append(toProjects[proj])
|
|
|
|
toKeys.remove(proj)
|
2014-01-09 15:21:37 +00:00
|
|
|
else:
|
|
|
|
fromProj = fromProjects[proj]
|
|
|
|
toProj = toProjects[proj]
|
|
|
|
try:
|
|
|
|
fromRevId = fromProj.GetCommitRevisionId()
|
|
|
|
toRevId = toProj.GetCommitRevisionId()
|
|
|
|
except ManifestInvalidRevisionError:
|
|
|
|
diff['unreachable'].append((fromProj, toProj))
|
|
|
|
else:
|
|
|
|
if fromRevId != toRevId:
|
|
|
|
diff['changed'].append((fromProj, toProj))
|
|
|
|
toKeys.remove(proj)
|
|
|
|
|
|
|
|
for proj in toKeys:
|
|
|
|
diff['added'].append(toProjects[proj])
|
|
|
|
|
|
|
|
return diff
|
2015-08-20 19:19:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
class GitcManifest(XmlManifest):
|
2020-09-06 18:53:18 +00:00
|
|
|
"""Parser for GitC (git-in-the-cloud) manifests."""
|
2015-08-20 19:19:28 +00:00
|
|
|
|
2020-02-12 04:56:59 +00:00
|
|
|
def _ParseProject(self, node, parent=None):
|
2015-08-20 19:19:28 +00:00
|
|
|
"""Override _ParseProject and add support for GITC specific attributes."""
|
2021-02-19 18:34:09 +00:00
|
|
|
return super()._ParseProject(
|
2015-08-20 19:19:28 +00:00
|
|
|
node, parent=parent, old_revision=node.getAttribute('old-revision'))
|
|
|
|
|
|
|
|
def _output_manifest_project_extras(self, p, e):
|
|
|
|
"""Output GITC Specific Project attributes"""
|
|
|
|
if p.old_revision:
|
2016-06-17 23:40:08 +00:00
|
|
|
e.setAttribute('old-revision', str(p.old_revision))
|
2020-09-06 18:53:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
class RepoClient(XmlManifest):
|
|
|
|
"""Manages a repo client checkout."""
|
|
|
|
|
2021-11-18 22:40:18 +00:00
|
|
|
def __init__(self, repodir, manifest_file=None, submanifest_path='', **kwargs):
|
2022-06-01 21:03:34 +00:00
|
|
|
"""Initialize.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
repodir: Path to the .repo/ dir for holding all internal checkout state.
|
|
|
|
It must be in the top directory of the repo client checkout.
|
|
|
|
manifest_file: Full path to the manifest file to parse. This will usually
|
|
|
|
be |repodir|/|MANIFEST_FILE_NAME|.
|
|
|
|
submanifest_path: The submanifest root relative to the repo root.
|
|
|
|
**kwargs: Additional keyword arguments, passed to XmlManifest.
|
|
|
|
"""
|
2020-09-06 18:53:18 +00:00
|
|
|
self.isGitcClient = False
|
2021-11-18 22:40:18 +00:00
|
|
|
submanifest_path = submanifest_path or ''
|
|
|
|
if submanifest_path:
|
|
|
|
self._CheckLocalPath(submanifest_path)
|
|
|
|
prefix = os.path.join(repodir, SUBMANIFEST_DIR, submanifest_path)
|
|
|
|
else:
|
|
|
|
prefix = repodir
|
2020-09-06 18:53:18 +00:00
|
|
|
|
2021-11-18 22:40:18 +00:00
|
|
|
if os.path.exists(os.path.join(prefix, LOCAL_MANIFEST_NAME)):
|
2020-09-06 18:53:18 +00:00
|
|
|
print('error: %s is not supported; put local manifests in `%s` instead' %
|
2021-11-18 22:40:18 +00:00
|
|
|
(LOCAL_MANIFEST_NAME, os.path.join(prefix, LOCAL_MANIFESTS_DIR_NAME)),
|
2020-09-06 18:53:18 +00:00
|
|
|
file=sys.stderr)
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
if manifest_file is None:
|
2021-11-18 22:40:18 +00:00
|
|
|
manifest_file = os.path.join(prefix, MANIFEST_FILE_NAME)
|
|
|
|
local_manifests = os.path.abspath(os.path.join(prefix, LOCAL_MANIFESTS_DIR_NAME))
|
|
|
|
super().__init__(repodir, manifest_file, local_manifests,
|
|
|
|
submanifest_path=submanifest_path, **kwargs)
|
2020-09-06 18:53:18 +00:00
|
|
|
|
|
|
|
# TODO: Completely separate manifest logic out of the client.
|
|
|
|
self.manifest = self
|
|
|
|
|
|
|
|
|
|
|
|
class GitcClient(RepoClient, GitcManifest):
|
|
|
|
"""Manages a GitC client checkout."""
|
|
|
|
|
|
|
|
def __init__(self, repodir, gitc_client_name):
|
|
|
|
"""Initialize the GitcManifest object."""
|
|
|
|
self.gitc_client_name = gitc_client_name
|
|
|
|
self.gitc_client_dir = os.path.join(gitc_utils.get_gitc_manifest_dir(),
|
|
|
|
gitc_client_name)
|
|
|
|
|
2021-02-19 18:34:09 +00:00
|
|
|
super().__init__(repodir, os.path.join(self.gitc_client_dir, '.manifest'))
|
2020-09-06 18:53:18 +00:00
|
|
|
self.isGitcClient = True
|