Add git_dependencies flag to DEPS

This change adds `git_dependencies` flag to the DEPS. This will be used to track the submodule migration state.

Design Doc: go/depot-tools-on-submodules
Change-Id: I547ad8ebbce2535960d4b6e00c0b14c00118f544
Bug: 1429149
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4591777
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
changes/77/4591777/17
Aravind Vasudevan 2 years ago committed by LUCI CQ
parent 72339f4250
commit b6eaed26fc

@ -401,9 +401,21 @@ class DependencySettings(object):
class Dependency(gclient_utils.WorkItem, DependencySettings): class Dependency(gclient_utils.WorkItem, DependencySettings):
"""Object that represents a dependency checkout.""" """Object that represents a dependency checkout."""
def __init__(self, parent, name, url, managed, custom_deps, def __init__(self,
custom_vars, custom_hooks, deps_file, should_process, parent,
should_recurse, relative, condition, protocol='https', name,
url,
managed,
custom_deps,
custom_vars,
custom_hooks,
deps_file,
should_process,
should_recurse,
relative,
condition,
protocol='https',
git_dependencies_state=gclient_eval.DEPS,
print_outbuf=False): print_outbuf=False):
gclient_utils.WorkItem.__init__(self, name) gclient_utils.WorkItem.__init__(self, name)
DependencySettings.__init__( DependencySettings.__init__(
@ -479,6 +491,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
self.print_outbuf = print_outbuf self.print_outbuf = print_outbuf
self.protocol = protocol self.protocol = protocol
self.git_dependencies_state = git_dependencies_state
if not self.name and self.parent: if not self.name and self.parent:
raise gclient_utils.Error('Dependency without name') raise gclient_utils.Error('Dependency without name')
@ -747,7 +760,8 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
should_recurse=name in self.recursedeps, should_recurse=name in self.recursedeps,
relative=use_relative_paths, relative=use_relative_paths,
condition=condition, condition=condition,
protocol=self.protocol)) protocol=self.protocol,
git_dependencies_state=self.git_dependencies_state))
# TODO(crbug.com/1341285): Understand why we need this and remove # TODO(crbug.com/1341285): Understand why we need this and remove
# it if we don't. # it if we don't.
@ -790,6 +804,9 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
except SyntaxError as e: except SyntaxError as e:
gclient_utils.SyntaxErrorToError(filepath, e) gclient_utils.SyntaxErrorToError(filepath, e)
if 'git_dependencies' in local_scope:
self.git_dependencies_state = local_scope['git_dependencies']
if 'allowed_hosts' in local_scope: if 'allowed_hosts' in local_scope:
try: try:
self._allowed_hosts = frozenset(local_scope.get('allowed_hosts')) self._allowed_hosts = frozenset(local_scope.get('allowed_hosts'))
@ -1615,24 +1632,26 @@ it or fix the checkout.
deps_to_add = [] deps_to_add = []
for s in config_dict.get('solutions', []): for s in config_dict.get('solutions', []):
try: try:
deps_to_add.append(GitDependency( deps_to_add.append(
parent=self, GitDependency(
name=s['name'], parent=self,
# Update URL with scheme in protocol_override name=s['name'],
url=GitDependency.updateProtocol( # Update URL with scheme in protocol_override
s['url'], s.get('protocol_override', None)), url=GitDependency.updateProtocol(
managed=s.get('managed', True), s['url'], s.get('protocol_override', None)),
custom_deps=s.get('custom_deps', {}), managed=s.get('managed', True),
custom_vars=s.get('custom_vars', {}), custom_deps=s.get('custom_deps', {}),
custom_hooks=s.get('custom_hooks', []), custom_vars=s.get('custom_vars', {}),
deps_file=s.get('deps_file', 'DEPS'), custom_hooks=s.get('custom_hooks', []),
should_process=True, deps_file=s.get('deps_file', 'DEPS'),
should_recurse=True, should_process=True,
relative=None, should_recurse=True,
condition=None, relative=None,
print_outbuf=True, condition=None,
# Pass protocol_override down the tree for child deps to use. print_outbuf=True,
protocol=s.get('protocol_override', None))) # Pass protocol_override down the tree for child deps to use.
protocol=s.get('protocol_override', None),
git_dependencies_state=self.git_dependencies_state))
except KeyError: except KeyError:
raise gclient_utils.Error('Invalid .gclient file. Solution is ' raise gclient_utils.Error('Invalid .gclient file. Solution is '
'incomplete: %s' % s) 'incomplete: %s' % s)
@ -1966,7 +1985,8 @@ it or fix the checkout.
should_recurse=False, should_recurse=False,
relative=None, relative=None,
condition=None, condition=None,
protocol=self.protocol)) protocol=self.protocol,
git_dependencies_state=self.git_dependencies_state))
if modified_files and self._options.delete_unversioned_trees: if modified_files and self._options.delete_unversioned_trees:
print('\nWARNING: \'%s\' is no longer part of this client.\n' print('\nWARNING: \'%s\' is no longer part of this client.\n'
'Despite running \'gclient sync -D\' no action was taken ' 'Despite running \'gclient sync -D\' no action was taken '

@ -24,6 +24,13 @@ else:
basestring = str basestring = str
# git_dependencies migration states. Used within the DEPS file to indicate
# the current migration state.
DEPS = 'DEPS'
SYNC = 'SYNC'
SUBMODULES = 'SUBMODULES'
class ConstantString(object): class ConstantString(object):
def __init__(self, value): def __init__(self, value):
self.value = value self.value = value
@ -156,6 +163,11 @@ _GCLIENT_HOOKS_SCHEMA = [
_GCLIENT_SCHEMA = schema.Schema( _GCLIENT_SCHEMA = schema.Schema(
_NodeDictSchema({ _NodeDictSchema({
# Current state of the git submodule migration.
# git_dependencies = [DEPS (default) | SUBMODULES | SYNC]
schema.Optional('git_dependencies'):
schema.Or(DEPS, SYNC, SUBMODULES),
# List of host names from which dependencies are allowed (allowlist). # List of host names from which dependencies are allowed (allowlist).
# NOTE: when not present, all hosts are allowed. # NOTE: when not present, all hosts are allowed.
# NOTE: scoped to current DEPS file, not recursive. # NOTE: scoped to current DEPS file, not recursive.
@ -169,21 +181,25 @@ _GCLIENT_SCHEMA = schema.Schema(
# #
# Var(): allows variable substitution (either from 'vars' dict below, # Var(): allows variable substitution (either from 'vars' dict below,
# or command-line override) # or command-line override)
schema.Optional('deps'): _GCLIENT_DEPS_SCHEMA, schema.Optional('deps'):
_GCLIENT_DEPS_SCHEMA,
# Similar to 'deps' (see above) - also keyed by OS (e.g. 'linux'). # Similar to 'deps' (see above) - also keyed by OS (e.g. 'linux').
# Also see 'target_os'. # Also see 'target_os'.
schema.Optional('deps_os'): _NodeDictSchema({ schema.Optional('deps_os'):
_NodeDictSchema({
schema.Optional(basestring): _GCLIENT_DEPS_SCHEMA, schema.Optional(basestring): _GCLIENT_DEPS_SCHEMA,
}), }),
# Dependency to get gclient_gn_args* settings from. This allows these # Dependency to get gclient_gn_args* settings from. This allows these
# values to be set in a recursedeps file, rather than requiring that # values to be set in a recursedeps file, rather than requiring that
# they exist in the top-level solution. # they exist in the top-level solution.
schema.Optional('gclient_gn_args_from'): basestring, schema.Optional('gclient_gn_args_from'):
basestring,
# Path to GN args file to write selected variables. # Path to GN args file to write selected variables.
schema.Optional('gclient_gn_args_file'): basestring, schema.Optional('gclient_gn_args_file'):
basestring,
# Subset of variables to write to the GN args file (see above). # Subset of variables to write to the GN args file (see above).
schema.Optional('gclient_gn_args'): [schema.Optional(basestring)], schema.Optional('gclient_gn_args'): [schema.Optional(basestring)],
@ -191,12 +207,12 @@ _GCLIENT_SCHEMA = schema.Schema(
# Hooks executed after gclient sync (unless suppressed), or explicitly # Hooks executed after gclient sync (unless suppressed), or explicitly
# on gclient hooks. See _GCLIENT_HOOKS_SCHEMA for details. # on gclient hooks. See _GCLIENT_HOOKS_SCHEMA for details.
# Also see 'pre_deps_hooks'. # Also see 'pre_deps_hooks'.
schema.Optional('hooks'): _GCLIENT_HOOKS_SCHEMA, schema.Optional('hooks'):
_GCLIENT_HOOKS_SCHEMA,
# Similar to 'hooks', also keyed by OS. # Similar to 'hooks', also keyed by OS.
schema.Optional('hooks_os'): _NodeDictSchema({ schema.Optional('hooks_os'):
schema.Optional(basestring): _GCLIENT_HOOKS_SCHEMA _NodeDictSchema({schema.Optional(basestring): _GCLIENT_HOOKS_SCHEMA}),
}),
# Rules which #includes are allowed in the directory. # Rules which #includes are allowed in the directory.
# Also see 'skip_child_includes' and 'specific_include_rules'. # Also see 'skip_child_includes' and 'specific_include_rules'.
@ -208,21 +224,22 @@ _GCLIENT_SCHEMA = schema.Schema(
# will not inherit rules from //base/DEPS and //base/allocator/DEPS, # will not inherit rules from //base/DEPS and //base/allocator/DEPS,
# forcing each //base/allocator/partition_allocator/{foo,bar,...} to # forcing each //base/allocator/partition_allocator/{foo,bar,...} to
# declare all its dependencies. # declare all its dependencies.
schema.Optional('noparent'): bool, schema.Optional('noparent'):
bool,
# Hooks executed before processing DEPS. See 'hooks' for more details. # Hooks executed before processing DEPS. See 'hooks' for more details.
schema.Optional('pre_deps_hooks'): _GCLIENT_HOOKS_SCHEMA, schema.Optional('pre_deps_hooks'):
_GCLIENT_HOOKS_SCHEMA,
# Recursion limit for nested DEPS. # Recursion limit for nested DEPS.
schema.Optional('recursion'): int, schema.Optional('recursion'):
int,
# Allowlists deps for which recursion should be enabled. # Allowlists deps for which recursion should be enabled.
schema.Optional('recursedeps'): [ schema.Optional('recursedeps'): [
schema.Optional(schema.Or( schema.Optional(
basestring, schema.Or(basestring, (basestring, basestring),
(basestring, basestring), [basestring, basestring])),
[basestring, basestring]
)),
], ],
# Blocklists directories for checking 'include_rules'. # Blocklists directories for checking 'include_rules'.
@ -230,9 +247,8 @@ _GCLIENT_SCHEMA = schema.Schema(
# Mapping from paths to include rules specific for that path. # Mapping from paths to include rules specific for that path.
# See 'include_rules' for more details. # See 'include_rules' for more details.
schema.Optional('specific_include_rules'): _NodeDictSchema({ schema.Optional('specific_include_rules'):
schema.Optional(basestring): [basestring] _NodeDictSchema({schema.Optional(basestring): [basestring]}),
}),
# List of additional OS names to consider when selecting dependencies # List of additional OS names to consider when selecting dependencies
# from deps_os. # from deps_os.
@ -241,17 +257,19 @@ _GCLIENT_SCHEMA = schema.Schema(
# For recursed-upon sub-dependencies, check out their own dependencies # For recursed-upon sub-dependencies, check out their own dependencies
# relative to the parent's path, rather than relative to the .gclient # relative to the parent's path, rather than relative to the .gclient
# file. # file.
schema.Optional('use_relative_paths'): bool, schema.Optional('use_relative_paths'):
bool,
# For recursed-upon sub-dependencies, run their hooks relative to the # For recursed-upon sub-dependencies, run their hooks relative to the
# parent's path instead of relative to the .gclient file. # parent's path instead of relative to the .gclient file.
schema.Optional('use_relative_hooks'): bool, schema.Optional('use_relative_hooks'):
bool,
# Variables that can be referenced using Var() - see 'deps'. # Variables that can be referenced using Var() - see 'deps'.
schema.Optional('vars'): _NodeDictSchema({ schema.Optional('vars'):
schema.Optional(basestring): schema.Or(ConstantString, _NodeDictSchema({
basestring, schema.Optional(basestring):
bool), schema.Or(ConstantString, basestring, bool),
}), }),
})) }))

Loading…
Cancel
Save