mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-01-02 16:14:25 +00:00
Move manifest config logic into ManifestProject
Use ManifestProject properties for config values. Change-Id: Ib4ad90b0d9a089916e35615b8058942e6d01dc04 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/334519 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
parent
9b03f15e8e
commit
d82be3e672
@ -406,7 +406,7 @@ def UseSuperproject(opt, manifest):
|
|||||||
if opt.use_superproject is not None:
|
if opt.use_superproject is not None:
|
||||||
return opt.use_superproject
|
return opt.use_superproject
|
||||||
else:
|
else:
|
||||||
client_value = manifest.manifestProject.config.GetBoolean('repo.superproject')
|
client_value = manifest.manifestProject.use_superproject
|
||||||
if client_value is not None:
|
if client_value is not None:
|
||||||
return client_value
|
return client_value
|
||||||
else:
|
else:
|
||||||
|
@ -372,7 +372,7 @@ class XmlManifest(object):
|
|||||||
# normal repo settings live in the manifestProject which we just setup
|
# normal repo settings live in the manifestProject which we just setup
|
||||||
# above, so we couldn't easily query before that. We assume Project()
|
# above, so we couldn't easily query before that. We assume Project()
|
||||||
# init doesn't care if this changes afterwards.
|
# init doesn't care if this changes afterwards.
|
||||||
if os.path.exists(mp.gitdir) and mp.config.GetBoolean('repo.worktree'):
|
if os.path.exists(mp.gitdir) and mp.use_worktree:
|
||||||
mp.use_git_worktrees = True
|
mp.use_git_worktrees = True
|
||||||
|
|
||||||
self._Unload()
|
self._Unload()
|
||||||
@ -487,7 +487,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
|
|||||||
mp = self.manifestProject
|
mp = self.manifestProject
|
||||||
|
|
||||||
if groups is None:
|
if groups is None:
|
||||||
groups = mp.config.GetString('manifest.groups')
|
groups = mp.manifest_groups
|
||||||
if groups:
|
if groups:
|
||||||
groups = self._ParseList(groups)
|
groups = self._ParseList(groups)
|
||||||
|
|
||||||
@ -861,22 +861,21 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def CloneBundle(self):
|
def CloneBundle(self):
|
||||||
clone_bundle = self.manifestProject.config.GetBoolean('repo.clonebundle')
|
clone_bundle = self.manifestProject.clone_bundle
|
||||||
if clone_bundle is None:
|
if clone_bundle is None:
|
||||||
return False if self.manifestProject.config.GetBoolean('repo.partialclone') else True
|
return False if self.manifestProject.partial_clone else True
|
||||||
else:
|
else:
|
||||||
return clone_bundle
|
return clone_bundle
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def CloneFilter(self):
|
def CloneFilter(self):
|
||||||
if self.manifestProject.config.GetBoolean('repo.partialclone'):
|
if self.manifestProject.partial_clone:
|
||||||
return self.manifestProject.config.GetString('repo.clonefilter')
|
return self.manifestProject.clone_filter
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def PartialCloneExclude(self):
|
def PartialCloneExclude(self):
|
||||||
exclude = self.manifest.manifestProject.config.GetString(
|
exclude = self.manifest.manifestProject.partial_clone_exclude or ''
|
||||||
'repo.partialcloneexclude') or ''
|
|
||||||
return set(x.strip() for x in exclude.split(','))
|
return set(x.strip() for x in exclude.split(','))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -897,23 +896,23 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def IsMirror(self):
|
def IsMirror(self):
|
||||||
return self.manifestProject.config.GetBoolean('repo.mirror')
|
return self.manifestProject.mirror
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def UseGitWorktrees(self):
|
def UseGitWorktrees(self):
|
||||||
return self.manifestProject.config.GetBoolean('repo.worktree')
|
return self.manifestProject.use_worktree
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def IsArchive(self):
|
def IsArchive(self):
|
||||||
return self.manifestProject.config.GetBoolean('repo.archive')
|
return self.manifestProject.archive
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def HasSubmodules(self):
|
def HasSubmodules(self):
|
||||||
return self.manifestProject.config.GetBoolean('repo.submodules')
|
return self.manifestProject.submodules
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def EnableGitLfs(self):
|
def EnableGitLfs(self):
|
||||||
return self.manifestProject.config.GetBoolean('repo.git-lfs')
|
return self.manifestProject.git_lfs
|
||||||
|
|
||||||
def FindManifestByPath(self, path):
|
def FindManifestByPath(self, path):
|
||||||
"""Returns the manifest containing path."""
|
"""Returns the manifest containing path."""
|
||||||
@ -965,7 +964,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
|
|||||||
|
|
||||||
def GetGroupsStr(self):
|
def GetGroupsStr(self):
|
||||||
"""Returns the manifest group string that should be synced."""
|
"""Returns the manifest group string that should be synced."""
|
||||||
groups = self.manifestProject.config.GetString('manifest.groups')
|
groups = self.manifestProject.manifest_groups
|
||||||
if not groups:
|
if not groups:
|
||||||
groups = self.GetDefaultGroupsStr()
|
groups = self.GetDefaultGroupsStr()
|
||||||
return groups
|
return groups
|
||||||
|
108
project.py
108
project.py
@ -16,6 +16,7 @@ import errno
|
|||||||
import filecmp
|
import filecmp
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
|
import platform
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
@ -1162,7 +1163,7 @@ class Project(object):
|
|||||||
if self.clone_depth:
|
if self.clone_depth:
|
||||||
depth = self.clone_depth
|
depth = self.clone_depth
|
||||||
else:
|
else:
|
||||||
depth = self.manifest.manifestProject.config.GetString('repo.depth')
|
depth = self.manifest.manifestProject.depth
|
||||||
|
|
||||||
# See if we can skip the network fetch entirely.
|
# See if we can skip the network fetch entirely.
|
||||||
if not (optimized_fetch and
|
if not (optimized_fetch and
|
||||||
@ -1179,7 +1180,7 @@ class Project(object):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
mp = self.manifest.manifestProject
|
mp = self.manifest.manifestProject
|
||||||
dissociate = mp.config.GetBoolean('repo.dissociate')
|
dissociate = mp.dissociate
|
||||||
if dissociate:
|
if dissociate:
|
||||||
alternates_file = os.path.join(self.objdir, 'objects/info/alternates')
|
alternates_file = os.path.join(self.objdir, 'objects/info/alternates')
|
||||||
if os.path.exists(alternates_file):
|
if os.path.exists(alternates_file):
|
||||||
@ -2282,9 +2283,7 @@ class Project(object):
|
|||||||
return ok
|
return ok
|
||||||
|
|
||||||
def _ApplyCloneBundle(self, initial=False, quiet=False, verbose=False):
|
def _ApplyCloneBundle(self, initial=False, quiet=False, verbose=False):
|
||||||
if initial and \
|
if initial and (self.manifest.manifestProject.depth or self.clone_depth):
|
||||||
(self.manifest.manifestProject.config.GetString('repo.depth') or
|
|
||||||
self.clone_depth):
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
remote = self.GetRemote(self.remote.name)
|
remote = self.GetRemote(self.remote.name)
|
||||||
@ -2513,7 +2512,7 @@ class Project(object):
|
|||||||
|
|
||||||
if init_git_dir:
|
if init_git_dir:
|
||||||
mp = self.manifest.manifestProject
|
mp = self.manifest.manifestProject
|
||||||
ref_dir = mp.config.GetString('repo.reference') or ''
|
ref_dir = mp.reference or ''
|
||||||
|
|
||||||
def _expanded_ref_dirs():
|
def _expanded_ref_dirs():
|
||||||
"""Iterate through the possible git reference directory paths."""
|
"""Iterate through the possible git reference directory paths."""
|
||||||
@ -3358,18 +3357,93 @@ class ManifestProject(MetaProject):
|
|||||||
capture_stdout=True,
|
capture_stdout=True,
|
||||||
capture_stderr=True).Wait() == 0
|
capture_stderr=True).Wait() == 0
|
||||||
|
|
||||||
|
@property
|
||||||
|
def standalone_manifest_url(self):
|
||||||
|
"""The URL of the standalone manifest, or None."""
|
||||||
|
return self.config.getString('manifest.standalone')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def manifest_groups(self):
|
||||||
|
"""The manifest groups string."""
|
||||||
|
return self.config.GetString('manifest.groups')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def reference(self):
|
||||||
|
"""The --reference for this manifest."""
|
||||||
|
self.config.GetString('repo.reference')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def dissociate(self):
|
||||||
|
"""Whether to dissociate."""
|
||||||
|
self.config.GetBoolean('repo.dissociate')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def archive(self):
|
||||||
|
"""Whether we use archive."""
|
||||||
|
self.config.GetBoolean('repo.archive')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def mirror(self):
|
||||||
|
"""Whether we use mirror."""
|
||||||
|
self.config.GetBoolean('repo.mirror')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def use_worktree(self):
|
||||||
|
"""Whether we use worktree."""
|
||||||
|
self.config.GetBoolean('repo.worktree')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def clone_bundle(self):
|
||||||
|
"""Whether we use clone_bundle."""
|
||||||
|
self.config.GetBoolean('repo.clonebundle')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def submodules(self):
|
||||||
|
"""Whether we use submodules."""
|
||||||
|
self.config.GetBoolean('repo.submodules')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def git_lfs(self):
|
||||||
|
"""Whether we use git_lfs."""
|
||||||
|
self.config.GetBoolean('repo.git-lfs')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def use_superproject(self):
|
||||||
|
"""Whether we use superproject."""
|
||||||
|
self.config.GetBoolean('repo.superproject')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def partial_clone(self):
|
||||||
|
"""Whether this is a partial clone."""
|
||||||
|
self.config.GetBoolean('repo.partialclone')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def depth(self):
|
||||||
|
"""Partial clone depth."""
|
||||||
|
self.config.GetString('repo.depth')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def clone_filter(self):
|
||||||
|
"""The clone filter."""
|
||||||
|
self.config.GetString('repo.clonefilter')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def partial_clone_exclude(self):
|
||||||
|
"""Partial clone exclude string"""
|
||||||
|
self.config.GetBoolean('repo.partialcloneexclude')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _platform_name(self):
|
def _platform_name(self):
|
||||||
"""Return the name of the platform."""
|
"""Return the name of the platform."""
|
||||||
return platform.system().lower()
|
return platform.system().lower()
|
||||||
|
|
||||||
def Sync(self, _kwargs_only=(), manifest_url='', manifest_branch=None,
|
def Sync(self, _kwargs_only=(), manifest_url='', manifest_branch=None,
|
||||||
standalone_manifest=False, groups='', platform='', mirror=False,
|
standalone_manifest=False, groups='', mirror=False, reference='',
|
||||||
dissociate=False, reference='', worktree=False, submodules=False,
|
dissociate=False, worktree=False, submodules=False, archive=False,
|
||||||
archive=False, partial_clone=None, clone_filter='blob:none',
|
partial_clone=None, depth=None, clone_filter='blob:none',
|
||||||
partial_clone_exclude=None, clone_bundle=None, git_lfs=None,
|
partial_clone_exclude=None, clone_bundle=None, git_lfs=None,
|
||||||
use_superproject=None, verbose=False, current_branch_only=False,
|
use_superproject=None, verbose=False, current_branch_only=False,
|
||||||
tags='', depth=None):
|
platform='', tags=''):
|
||||||
"""Sync the manifest and all submanifests.
|
"""Sync the manifest and all submanifests.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -3379,8 +3453,6 @@ class ManifestProject(MetaProject):
|
|||||||
file.
|
file.
|
||||||
groups: a string, restricts the checkout to projects with the specified
|
groups: a string, restricts the checkout to projects with the specified
|
||||||
groups.
|
groups.
|
||||||
platform: a string, restrict the checkout to projects with the specified
|
|
||||||
platform group.
|
|
||||||
mirror: a boolean, whether to create a mirror of the remote repository.
|
mirror: a boolean, whether to create a mirror of the remote repository.
|
||||||
reference: a string, location of a repo instance to use as a reference.
|
reference: a string, location of a repo instance to use as a reference.
|
||||||
dissociate: a boolean, whether to dissociate from reference mirrors after
|
dissociate: a boolean, whether to dissociate from reference mirrors after
|
||||||
@ -3391,6 +3463,7 @@ class ManifestProject(MetaProject):
|
|||||||
archive: a boolean, whether to checkout each project as an archive. See
|
archive: a boolean, whether to checkout each project as an archive. See
|
||||||
git-archive.
|
git-archive.
|
||||||
partial_clone: a boolean, whether to perform a partial clone.
|
partial_clone: a boolean, whether to perform a partial clone.
|
||||||
|
depth: an int, how deep of a shallow clone to create.
|
||||||
clone_filter: a string, filter to use with partial_clone.
|
clone_filter: a string, filter to use with partial_clone.
|
||||||
partial_clone_exclude : a string, comma-delimeted list of project namess
|
partial_clone_exclude : a string, comma-delimeted list of project namess
|
||||||
to exclude from partial clone.
|
to exclude from partial clone.
|
||||||
@ -3401,8 +3474,9 @@ class ManifestProject(MetaProject):
|
|||||||
verbose: a boolean, whether to show all output, rather than only errors.
|
verbose: a boolean, whether to show all output, rather than only errors.
|
||||||
current_branch_only: a boolean, whether to only fetch the current manifest
|
current_branch_only: a boolean, whether to only fetch the current manifest
|
||||||
branch from the server.
|
branch from the server.
|
||||||
|
platform: a string, restrict the checkout to projects with the specified
|
||||||
|
platform group.
|
||||||
tags: a boolean, whether to fetch tags.,
|
tags: a boolean, whether to fetch tags.,
|
||||||
depth: an int, how deep of a shallow clone to create.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
a boolean, whether the sync was successful.
|
a boolean, whether the sync was successful.
|
||||||
@ -3493,11 +3567,11 @@ class ManifestProject(MetaProject):
|
|||||||
else:
|
else:
|
||||||
self.PreSync()
|
self.PreSync()
|
||||||
|
|
||||||
groups = re.split(r'[,\s]+', groups)
|
groups = re.split(r'[,\s]+', groups or '')
|
||||||
all_platforms = ['linux', 'darwin', 'windows']
|
all_platforms = ['linux', 'darwin', 'windows']
|
||||||
platformize = lambda x: 'platform-' + x
|
platformize = lambda x: 'platform-' + x
|
||||||
if platform == 'auto':
|
if platform == 'auto':
|
||||||
if (not mirror and not self.config.GetString('repo.mirror') == 'true'):
|
if not mirror and not self.mirror:
|
||||||
groups.append(platformize(self._platform_name))
|
groups.append(platformize(self._platform_name))
|
||||||
elif platform == 'all':
|
elif platform == 'all':
|
||||||
groups.extend(map(platformize, all_platforms))
|
groups.extend(map(platformize, all_platforms))
|
||||||
@ -3561,8 +3635,8 @@ class ManifestProject(MetaProject):
|
|||||||
self.config.SetBoolean('repo.partialclone', partial_clone)
|
self.config.SetBoolean('repo.partialclone', partial_clone)
|
||||||
if clone_filter:
|
if clone_filter:
|
||||||
self.config.SetString('repo.clonefilter', clone_filter)
|
self.config.SetString('repo.clonefilter', clone_filter)
|
||||||
elif self.config.GetBoolean('repo.partialclone'):
|
elif self.partialclone:
|
||||||
clone_filter = self.config.GetString('repo.clonefilter')
|
clone_filter = self.clone_filter
|
||||||
else:
|
else:
|
||||||
clone_filter = None
|
clone_filter = None
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ to update the working directory files.
|
|||||||
self._SyncManifest(opt)
|
self._SyncManifest(opt)
|
||||||
self._LinkManifest(opt.manifest_name)
|
self._LinkManifest(opt.manifest_name)
|
||||||
|
|
||||||
if self.manifest.manifestProject.config.GetBoolean('repo.superproject'):
|
if self.manifest.manifestProject.use_superproject:
|
||||||
self._CloneSuperproject(opt)
|
self._CloneSuperproject(opt)
|
||||||
|
|
||||||
if os.isatty(0) and os.isatty(1) and not self.manifest.IsMirror:
|
if os.isatty(0) and os.isatty(1) and not self.manifest.IsMirror:
|
||||||
|
@ -976,7 +976,7 @@ later is required to fix a server side protocol bug.
|
|||||||
file=sys.stderr)
|
file=sys.stderr)
|
||||||
|
|
||||||
mp = self.manifest.manifestProject
|
mp = self.manifest.manifestProject
|
||||||
is_standalone_manifest = mp.config.GetString('manifest.standalone')
|
is_standalone_manifest = bool(mp.standalone_manifest_url)
|
||||||
if not is_standalone_manifest:
|
if not is_standalone_manifest:
|
||||||
mp.PreSync()
|
mp.PreSync()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user