From 5d6cde39410156c522995cfa192fcde7087d66cc Mon Sep 17 00:00:00 2001 From: Edward Lesmes Date: Thu, 12 Apr 2018 18:32:46 -0400 Subject: [PATCH] gclient: Don't parse DEPS files that we won't recurse into. Bug: 830306 Change-Id: I419f16583dc2bf4bd2a66a41eb73fff4802686a8 Reviewed-on: https://chromium-review.googlesource.com/1011391 Commit-Queue: Edward Lesmes Reviewed-by: Aaron Gable --- gclient.py | 9 +++++---- tests/gclient_smoketest.py | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/gclient.py b/gclient.py index 437190a7c..88319b670 100755 --- a/gclient.py +++ b/gclient.py @@ -1014,13 +1014,14 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): while file_list[i].startswith(('\\', '/')): file_list[i] = file_list[i][1:] - # Always parse the DEPS file. - self.ParseDepsFile(expand_vars=(command != 'flatten')) + if self.recursion_limit: + self.ParseDepsFile(expand_vars=(command != 'flatten')) + self._run_is_done(file_list or [], parsed_url) - if command in ('update', 'revert') and not options.noprehooks: - self.RunPreDepsHooks() if self.recursion_limit: + if command in ('update', 'revert') and not options.noprehooks: + self.RunPreDepsHooks() # Parse the dependencies of this dependency. for s in self.dependencies: if s.should_process: diff --git a/tests/gclient_smoketest.py b/tests/gclient_smoketest.py index a7233a298..fd42c3d40 100755 --- a/tests/gclient_smoketest.py +++ b/tests/gclient_smoketest.py @@ -362,6 +362,35 @@ class GClientSmokeGIT(GClientSmokeBase): ]) self.assertTree(tree) + def testSyncJsonOutput(self): + self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) + output_json = os.path.join(self.root_dir, 'output.json') + self.gclient(['sync', '--deps', 'mac', '--output-json', output_json]) + with open(output_json) as f: + output_json = json.load(f) + + out = { + 'solutions': { + 'src/': { + 'scm': 'git', + 'url': self.git_base + 'repo_1', + 'revision': self.githash('repo_1', 2), + }, + 'src/repo2/': { + 'scm': 'git', + 'url': + self.git_base + 'repo_2@' + self.githash('repo_2', 1)[:7], + 'revision': self.githash('repo_2', 1), + }, + 'src/repo2/repo_renamed/': { + 'scm': 'git', + 'url': '/repo_3', + 'revision': self.githash('repo_3', 2), + }, + }, + } + self.assertEqual(out, output_json) + def testSyncIgnoredSolutionName(self): """TODO(maruel): This will become an error soon.""" if not self.enabled: @@ -786,10 +815,9 @@ class GClientSmokeGIT(GClientSmokeBase): 'name': 'src', 'deps_file': 'DEPS', 'custom_deps': { - 'foo/bar': None, 'src/repo2': '%srepo_2@%s' % ( self.git_base, self.githash('repo_2', 1)), - u'src/repo2/repo_renamed': '%srepo_3@%s' % ( + 'src/repo2/repo_renamed': '%srepo_3@%s' % ( self.git_base, self.githash('repo_3', 2)), }, }]