From aae6725ff0466e1f12555bf21a87b070b068ed27 Mon Sep 17 00:00:00 2001 From: Aravind Vasudevan Date: Wed, 5 Jan 2022 00:41:38 +0000 Subject: [PATCH] Fix recursedeps to be overridden using custom_deps in windows R=gavinmak@google.com Change-Id: Ibae42b9533b0da526c3a534cd327806611216327 Bug: 1215885 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3335580 Reviewed-by: Gavin Mak Commit-Queue: Aravind Vasudevan --- gclient.py | 4 +++- tests/gclient_test.py | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/gclient.py b/gclient.py index 2470c7560d..446be28d1f 100755 --- a/gclient.py +++ b/gclient.py @@ -467,7 +467,9 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): def _OverrideUrl(self): """Resolves the parsed url from the parent hierarchy.""" - parsed_url = self.get_custom_deps(self._name, self.url) + parsed_url = self.get_custom_deps( + self._name.replace(os.sep, posixpath.sep) \ + if self._name else self._name, self.url) if parsed_url != self.url: logging.info('Dependency(%s)._OverrideUrl(%s) -> %s', self._name, self.url, parsed_url) diff --git a/tests/gclient_test.py b/tests/gclient_test.py index a4ab9fcb66..c123234dde 100755 --- a/tests/gclient_test.py +++ b/tests/gclient_test.py @@ -840,6 +840,43 @@ class GclientTest(trial_dir.TestCase): ], self._get_processed()) + def testRecursedepsCustomdepsOverride(self): + """Verifies gclient overrides deps within recursedeps using custom deps""" + + write( + '.gclient', + 'solutions = [\n' + ' { "name": "foo",\n' + ' "url": "svn://example.com/foo",\n' + ' "custom_deps": {\n' + ' "foo/bar": "svn://example.com/override",\n' + ' },\n' + ' },]\n') + write( + os.path.join('foo', 'DEPS'), + 'use_relative_paths = True\n' + 'deps = {\n' + ' "bar": "/bar",\n' + '}\n' + 'recursedeps = ["bar"]') + write( + os.path.join('foo', 'bar', 'DEPS'), + 'deps = {\n' + ' "baz": "/baz",\n' + '}') + + options, _ = gclient.OptionParser().parse_args([]) + obj = gclient.GClient.LoadCurrentConfig(options) + obj.RunOnDeps('None', []) + self.assertEqual( + [ + ('foo', 'svn://example.com/foo'), + (os.path.join('foo', 'bar'), 'svn://example.com/override'), + (os.path.join('foo', 'foo', 'bar'), 'svn://example.com/override'), + (os.path.join('foo', 'baz'), 'svn://example.com/baz'), + ], + self._get_processed()) + def testRelativeRecursion(self): """Verifies that nested use_relative_paths is always respected.""" write(