From 012013ee5940f01731ff2553828fcb9b3fb71c44 Mon Sep 17 00:00:00 2001 From: Michael Moss Date: Fri, 30 Mar 2018 17:03:19 -0700 Subject: [PATCH] Add tests and fixes for |None| url values in deps entries. This is useful for processing purely "local" DEPS files, with a command-line like: gclient revinfo --output-json /tmp/out \ --spec 'solutions=[{"name": ".", "deps_file": "myDEPS", "url": None}]' This is specifically to fix the "revinfo --output-json" case, but it also cleans up some errors in the 'flattening' test cases. Note that None values already work when using 'revinfo' with stdout output, it's just the json output that complains. BUG=825063 Change-Id: If5f69ba51cb9d0aa0f2b48a2f9b4ed8706b4c738 Reviewed-on: https://chromium-review.googlesource.com/989022 Commit-Queue: Michael Moss Reviewed-by: Edward Lesmes Reviewed-by: Aaron Gable --- gclient.py | 6 +++--- gclient_eval.py | 2 +- recipes/trigger_recipe_roller.txt | 2 +- testing_support/fake_repos.py | 9 +++++++++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/gclient.py b/gclient.py index b5ee7ba9c..92c477f1d 100755 --- a/gclient.py +++ b/gclient.py @@ -726,7 +726,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): deps_file, should_process, use_relative_paths, condition, condition_value)) else: - url = raw_url.format(**self.get_vars()) + url = raw_url.format(**self.get_vars()) if raw_url else None deps_to_add.append( Dependency( self, name, raw_url, url, None, None, self.custom_vars, None, @@ -1883,8 +1883,8 @@ it or fix the checkout. if self._options.output_json: json_output = { name: { - 'url': rev.split('@')[0], - 'rev': rev.split('@')[1] if '@' in rev else None, + 'url': rev.split('@')[0] if rev else None, + 'rev': rev.split('@')[1] if rev and '@' in rev else None, } for name, rev in entries.iteritems() } diff --git a/gclient_eval.py b/gclient_eval.py index 17651a672..92a165ff6 100644 --- a/gclient_eval.py +++ b/gclient_eval.py @@ -57,7 +57,7 @@ _GCLIENT_DEPS_SCHEMA = _NodeDictSchema({ _NodeDictSchema({ # Repo and revision to check out under the path # (same as if no dict was used). - 'url': basestring, + 'url': schema.Or(None, basestring), # Optional condition string. The dep will only be processed # if the condition evaluates to True. diff --git a/recipes/trigger_recipe_roller.txt b/recipes/trigger_recipe_roller.txt index 32525cb6a..2ef8659ef 100644 --- a/recipes/trigger_recipe_roller.txt +++ b/recipes/trigger_recipe_roller.txt @@ -1,3 +1,3 @@ -No-op file. Edit this to kick recipes. Yep. +No-op file. Edit this to kick recipes. Yep. Ack. This is a beginning of a story in this silly file. diff --git a/testing_support/fake_repos.py b/testing_support/fake_repos.py index f0e574856..9a476a220 100755 --- a/testing_support/fake_repos.py +++ b/testing_support/fake_repos.py @@ -518,6 +518,15 @@ deps = { 'url': '/repo_4', 'condition': 'False', }, + # Entries can have a None repository, which has the effect of either: + # - disabling a dep checkout (e.g. in a .gclient solution to prevent checking + # out optional large repos, or in deps_os where some repos aren't used on some + # platforms) + # - allowing a completely local directory to be processed by gclient (handy + # for dealing with "custom" DEPS, like buildspecs). + '/repoLocal': { + 'url': None, + }, 'src/repo8': '/repo_8', } deps_os ={