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>
diff --git a/gclient.py b/gclient.py
index 6034617..5e326df 100755
--- a/gclient.py
+++ b/gclient.py
@@ -401,9 +401,21 @@
 class Dependency(gclient_utils.WorkItem, DependencySettings):
   """Object that represents a dependency checkout."""
 
-  def __init__(self, parent, name, url, managed, custom_deps,
-               custom_vars, custom_hooks, deps_file, should_process,
-               should_recurse, relative, condition, protocol='https',
+  def __init__(self,
+               parent,
+               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):
     gclient_utils.WorkItem.__init__(self, name)
     DependencySettings.__init__(
@@ -479,6 +491,7 @@
     self.print_outbuf = print_outbuf
 
     self.protocol = protocol
+    self.git_dependencies_state = git_dependencies_state
 
     if not self.name and self.parent:
       raise gclient_utils.Error('Dependency without name')
@@ -747,7 +760,8 @@
                 should_recurse=name in self.recursedeps,
                 relative=use_relative_paths,
                 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
     # it if we don't.
@@ -790,6 +804,9 @@
       except SyntaxError as 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:
       try:
         self._allowed_hosts = frozenset(local_scope.get('allowed_hosts'))
@@ -1615,24 +1632,26 @@
     deps_to_add = []
     for s in config_dict.get('solutions', []):
       try:
-        deps_to_add.append(GitDependency(
-            parent=self,
-            name=s['name'],
-            # Update URL with scheme in protocol_override
-            url=GitDependency.updateProtocol(
-              s['url'], s.get('protocol_override', None)),
-            managed=s.get('managed', True),
-            custom_deps=s.get('custom_deps', {}),
-            custom_vars=s.get('custom_vars', {}),
-            custom_hooks=s.get('custom_hooks', []),
-            deps_file=s.get('deps_file', 'DEPS'),
-            should_process=True,
-            should_recurse=True,
-            relative=None,
-            condition=None,
-            print_outbuf=True,
-            # Pass protocol_override down the tree for child deps to use.
-            protocol=s.get('protocol_override', None)))
+        deps_to_add.append(
+            GitDependency(
+                parent=self,
+                name=s['name'],
+                # Update URL with scheme in protocol_override
+                url=GitDependency.updateProtocol(
+                    s['url'], s.get('protocol_override', None)),
+                managed=s.get('managed', True),
+                custom_deps=s.get('custom_deps', {}),
+                custom_vars=s.get('custom_vars', {}),
+                custom_hooks=s.get('custom_hooks', []),
+                deps_file=s.get('deps_file', 'DEPS'),
+                should_process=True,
+                should_recurse=True,
+                relative=None,
+                condition=None,
+                print_outbuf=True,
+                # 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:
         raise gclient_utils.Error('Invalid .gclient file. Solution is '
                                   'incomplete: %s' % s)
@@ -1966,7 +1985,8 @@
                   should_recurse=False,
                   relative=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:
             print('\nWARNING: \'%s\' is no longer part of this client.\n'
                   'Despite running \'gclient sync -D\' no action was taken '