From 4b21db06e48e90335a0a1ae5d5b911b960ea0e5a Mon Sep 17 00:00:00 2001 From: agable Date: Wed, 24 Aug 2016 20:18:02 -0700 Subject: [PATCH] Default gclient's GIT_MODE to True Also contains some other changes (to the example, and to safesync url) in order for test coverage to remain complete. Will be followed shortly by a wholesale removal of svn support from the gclient module. R=iannucci@chromium.org BUG=640251 Review-Url: https://codereview.chromium.org/2270083004 --- recipe_modules/gclient/api.py | 6 +- recipe_modules/gclient/config.py | 24 ++++---- .../gclient/example.expected/basic.json | 50 +++++++++++++-- .../gclient/example.expected/revision.json | 50 +++++++++++++-- .../gclient/example.expected/tryserver.json | 61 +++++++++++++------ recipe_modules/gclient/test_api.py | 2 +- 6 files changed, 148 insertions(+), 45 deletions(-) diff --git a/recipe_modules/gclient/api.py b/recipe_modules/gclient/api.py index 595939ace..7462e22c6 100644 --- a/recipe_modules/gclient/api.py +++ b/recipe_modules/gclient/api.py @@ -153,7 +153,7 @@ class GclientApi(recipe_api.RecipeApi): step_test_data = lambda: ( self.test_api.output_json(test_data_paths, cfg.GIT_MODE)) try: - if not cfg.GIT_MODE: + if not cfg.GIT_MODE: # pragma: no cover args = ['sync', '--nohooks', '--force', '--verbose'] if cfg.delete_unversioned_trees: args.append('--delete_unversioned_trees') @@ -239,7 +239,7 @@ class GclientApi(recipe_api.RecipeApi): sync_step = None try: - if not cfg.GIT_MODE: + if not cfg.GIT_MODE: # pragma: no cover try: if revert: self.revert(**kwargs) @@ -266,7 +266,7 @@ class GclientApi(recipe_api.RecipeApi): return sync_step - def revert(self, **kwargs): + def revert(self, **kwargs): # pragma: no cover """Return a gclient_safe_revert step.""" # Not directly calling gclient, so don't use self(). alias = self.spec_alias diff --git a/recipe_modules/gclient/config.py b/recipe_modules/gclient/config.py index c4566689e..31d0a4d22 100644 --- a/recipe_modules/gclient/config.py +++ b/recipe_modules/gclient/config.py @@ -10,7 +10,7 @@ from recipe_engine.config import ConfigList, Dict, Single, Static, Set, List from . import api as gclient_api -def BaseConfig(USE_MIRROR=True, GIT_MODE=False, CACHE_DIR=None, +def BaseConfig(USE_MIRROR=True, GIT_MODE=True, CACHE_DIR=None, PATCH_PROJECT=None, BUILDSPEC_VERSION=None, **_kwargs): deps = '.DEPS.git' if GIT_MODE else 'DEPS' @@ -96,7 +96,7 @@ def BaseConfig(USE_MIRROR=True, GIT_MODE=False, CACHE_DIR=None, config_ctx = config_item_context(BaseConfig) -def ChromiumSvnSubURL(c, *pieces): +def ChromiumSvnSubURL(c, *pieces): # pragma: no cover BASES = ('https://src.chromium.org', 'svn://svn-mirror.golo.chromium.org') return '/'.join((BASES[c.USE_MIRROR],) + pieces) @@ -106,19 +106,19 @@ def ChromiumGitURL(_c, *pieces): def ChromiumSrcURL(c): # TODO(phajdan.jr): Move to proper repo and add coverage. - if c.GIT_MODE: # pragma: no cover + if c.GIT_MODE: return ChromiumGitURL(c, 'chromium', 'src.git') - else: + else: # pragma: no cover return ChromiumSvnSubURL(c, 'chrome', 'trunk', 'src') def BlinkURL(c): # TODO(phajdan.jr): Move to proper repo and add coverage. - if c.GIT_MODE: # pragma: no cover + if c.GIT_MODE: return ChromiumGitURL(c, 'chromium', 'blink.git') - else: + else: # pragma: no cover return ChromiumSvnSubURL(c, 'blink', 'trunk') -def ChromeSvnSubURL(c, *pieces): +def ChromeSvnSubURL(c, *pieces): # pragma: no cover BASES = ('svn://svn.chromium.org', 'svn://svn-mirror.golo.chromium.org') return '/'.join((BASES[c.USE_MIRROR],) + pieces) @@ -129,9 +129,9 @@ def ChromeInternalGitURL(_c, *pieces): # pragma: no cover def ChromeInternalSrcURL(c): # TODO(phajdan.jr): Move to proper repo and add coverage. - if c.GIT_MODE: # pragma: no cover + if c.GIT_MODE: return ChromeInternalGitURL(c, 'chrome', 'src-internal.git') - else: + else: # pragma: no cover return ChromeSvnSubURL(c, 'chrome-internal', 'trunk', 'src-internal') def mirror_only(c, obj, default=None): @@ -350,8 +350,8 @@ def gyp(c): m['gyp'] = 'got_revision' @config_ctx(config_vars={'GIT_MODE': True}) -def build(c): # pragma: no cover - if not c.GIT_MODE: +def build(c): + if not c.GIT_MODE: # pragma: no cover raise BadConf('build only supports git') s = c.solutions.add() s.name = 'build' @@ -380,7 +380,7 @@ def skia(c): # pragma: no cover m['skia'] = 'got_revision' @config_ctx(config_vars={'GIT_MODE': True}) -def chrome_golo(c): # pragma: no cover +def chrome_golo(c): # pragma: no cover if not c.GIT_MODE: raise BadConf('chrome_golo only supports git') s = c.solutions.add() diff --git a/recipe_modules/gclient/example.expected/basic.json b/recipe_modules/gclient/example.expected/basic.json index 256e35ca6..c52cde02c 100644 --- a/recipe_modules/gclient/example.expected/basic.json +++ b/recipe_modules/gclient/example.expected/basic.json @@ -85,7 +85,7 @@ "RECIPE_PACKAGE_REPO[depot_tools]/gclient.py", "config", "--spec", - "cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': 'DEPS', 'managed': True, 'name': 'WebKit', 'safesync_url': 'https://blink-status.appspot.com/lkgr', 'url': 'svn://svn.chromium.org/blink/trunk'}]" + "cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': '.DEPS.git', 'managed': True, 'name': 'WebKit', 'safesync_url': 'https://blink-status.appspot.com/lkgr', 'url': 'svn://svn.chromium.org/blink/trunk'}]" ], "cwd": "[SLAVE_BUILD]/src/third_party", "env": { @@ -99,11 +99,15 @@ "-u", "RECIPE_PACKAGE_REPO[depot_tools]/gclient.py", "sync", + "--verbose", + "--with_branch_heads", "--nohooks", + "-j8", + "--reset", "--force", - "--verbose", + "--upstream", + "--no-nag-max", "--delete_unversioned_trees", - "--with_branch_heads", "--revision", "third_party/WebKit@123", "--output-json", @@ -118,17 +122,51 @@ "@@@STEP_LOG_LINE@json.output@{@@@", "@@@STEP_LOG_LINE@json.output@ \"solutions\": {@@@", "@@@STEP_LOG_LINE@json.output@ \"WebKit/\": {@@@", - "@@@STEP_LOG_LINE@json.output@ \"revision\": 241198@@@", + "@@@STEP_LOG_LINE@json.output@ \"revision\": \"3eebce6ea96f9e6c03e9252a4f8ef2ea9fe141c2\"@@@", "@@@STEP_LOG_LINE@json.output@ }, @@@", "@@@STEP_LOG_LINE@json.output@ \"src/blatley/\": {@@@", - "@@@STEP_LOG_LINE@json.output@ \"revision\": 248087@@@", + "@@@STEP_LOG_LINE@json.output@ \"revision\": \"5e800497199d615131a76cd10651e74d7c8a0962\"@@@", "@@@STEP_LOG_LINE@json.output@ }@@@", "@@@STEP_LOG_LINE@json.output@ }@@@", "@@@STEP_LOG_LINE@json.output@}@@@", "@@@STEP_LOG_END@json.output@@@", - "@@@SET_BUILD_PROPERTY@got_blatley_revision@248087@@@" + "@@@SET_BUILD_PROPERTY@got_blatley_revision@\"5e800497199d615131a76cd10651e74d7c8a0962\"@@@" ] }, + { + "cmd": [ + "python", + "-u", + "RECIPE_PACKAGE_REPO[depot_tools]/gclient.py", + "recurse", + "git", + "config", + "user.name", + "local_bot" + ], + "cwd": "[SLAVE_BUILD]/src/third_party", + "env": { + "PATH": "%(PATH)s:RECIPE_PACKAGE_REPO[depot_tools]" + }, + "name": "[spec: WebKit] gclient recurse (git config user.name)" + }, + { + "cmd": [ + "python", + "-u", + "RECIPE_PACKAGE_REPO[depot_tools]/gclient.py", + "recurse", + "git", + "config", + "user.email", + "local_bot@example.com" + ], + "cwd": "[SLAVE_BUILD]/src/third_party", + "env": { + "PATH": "%(PATH)s:RECIPE_PACKAGE_REPO[depot_tools]" + }, + "name": "[spec: WebKit] gclient recurse (git config user.email)" + }, { "cmd": [ "python", diff --git a/recipe_modules/gclient/example.expected/revision.json b/recipe_modules/gclient/example.expected/revision.json index e2e6c91fc..1b1882802 100644 --- a/recipe_modules/gclient/example.expected/revision.json +++ b/recipe_modules/gclient/example.expected/revision.json @@ -87,7 +87,7 @@ "RECIPE_PACKAGE_REPO[depot_tools]/gclient.py", "config", "--spec", - "cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': 'DEPS', 'managed': True, 'name': 'WebKit', 'safesync_url': 'https://blink-status.appspot.com/lkgr', 'url': 'svn://svn.chromium.org/blink/trunk'}]" + "cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': '.DEPS.git', 'managed': True, 'name': 'WebKit', 'safesync_url': 'https://blink-status.appspot.com/lkgr', 'url': 'svn://svn.chromium.org/blink/trunk'}]" ], "cwd": "[SLAVE_BUILD]/src/third_party", "env": { @@ -101,11 +101,15 @@ "-u", "RECIPE_PACKAGE_REPO[depot_tools]/gclient.py", "sync", + "--verbose", + "--with_branch_heads", "--nohooks", + "-j8", + "--reset", "--force", - "--verbose", + "--upstream", + "--no-nag-max", "--delete_unversioned_trees", - "--with_branch_heads", "--revision", "third_party/WebKit@123", "--output-json", @@ -120,17 +124,51 @@ "@@@STEP_LOG_LINE@json.output@{@@@", "@@@STEP_LOG_LINE@json.output@ \"solutions\": {@@@", "@@@STEP_LOG_LINE@json.output@ \"WebKit/\": {@@@", - "@@@STEP_LOG_LINE@json.output@ \"revision\": 241198@@@", + "@@@STEP_LOG_LINE@json.output@ \"revision\": \"3eebce6ea96f9e6c03e9252a4f8ef2ea9fe141c2\"@@@", "@@@STEP_LOG_LINE@json.output@ }, @@@", "@@@STEP_LOG_LINE@json.output@ \"src/blatley/\": {@@@", - "@@@STEP_LOG_LINE@json.output@ \"revision\": 248087@@@", + "@@@STEP_LOG_LINE@json.output@ \"revision\": \"5e800497199d615131a76cd10651e74d7c8a0962\"@@@", "@@@STEP_LOG_LINE@json.output@ }@@@", "@@@STEP_LOG_LINE@json.output@ }@@@", "@@@STEP_LOG_LINE@json.output@}@@@", "@@@STEP_LOG_END@json.output@@@", - "@@@SET_BUILD_PROPERTY@got_blatley_revision@248087@@@" + "@@@SET_BUILD_PROPERTY@got_blatley_revision@\"5e800497199d615131a76cd10651e74d7c8a0962\"@@@" ] }, + { + "cmd": [ + "python", + "-u", + "RECIPE_PACKAGE_REPO[depot_tools]/gclient.py", + "recurse", + "git", + "config", + "user.name", + "local_bot" + ], + "cwd": "[SLAVE_BUILD]/src/third_party", + "env": { + "PATH": "%(PATH)s:RECIPE_PACKAGE_REPO[depot_tools]" + }, + "name": "[spec: WebKit] gclient recurse (git config user.name)" + }, + { + "cmd": [ + "python", + "-u", + "RECIPE_PACKAGE_REPO[depot_tools]/gclient.py", + "recurse", + "git", + "config", + "user.email", + "local_bot@example.com" + ], + "cwd": "[SLAVE_BUILD]/src/third_party", + "env": { + "PATH": "%(PATH)s:RECIPE_PACKAGE_REPO[depot_tools]" + }, + "name": "[spec: WebKit] gclient recurse (git config user.email)" + }, { "cmd": [ "python", diff --git a/recipe_modules/gclient/example.expected/tryserver.json b/recipe_modules/gclient/example.expected/tryserver.json index 8b17594c0..13889c24e 100644 --- a/recipe_modules/gclient/example.expected/tryserver.json +++ b/recipe_modules/gclient/example.expected/tryserver.json @@ -87,7 +87,7 @@ "RECIPE_PACKAGE_REPO[depot_tools]/gclient.py", "config", "--spec", - "cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': 'DEPS', 'managed': True, 'name': 'WebKit', 'safesync_url': 'https://blink-status.appspot.com/lkgr', 'url': 'svn://svn.chromium.org/blink/trunk'}]" + "cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': '.DEPS.git', 'managed': True, 'name': 'WebKit', 'safesync_url': 'https://blink-status.appspot.com/lkgr', 'url': 'svn://svn.chromium.org/blink/trunk'}]" ], "cwd": "[SLAVE_BUILD]/src/third_party", "env": { @@ -95,28 +95,21 @@ }, "name": "[spec: WebKit] gclient setup" }, - { - "cmd": [ - "python", - "-u", - "[BUILD]/scripts/slave/gclient_safe_revert.py", - ".", - "[DEPOT_TOOLS]/gclient" - ], - "cwd": "[SLAVE_BUILD]/src/third_party", - "name": "[spec: WebKit] gclient revert" - }, { "cmd": [ "python", "-u", "RECIPE_PACKAGE_REPO[depot_tools]/gclient.py", "sync", + "--verbose", + "--with_branch_heads", "--nohooks", + "-j8", + "--reset", "--force", - "--verbose", + "--upstream", + "--no-nag-max", "--delete_unversioned_trees", - "--with_branch_heads", "--revision", "third_party/WebKit@123", "--output-json", @@ -131,17 +124,51 @@ "@@@STEP_LOG_LINE@json.output@{@@@", "@@@STEP_LOG_LINE@json.output@ \"solutions\": {@@@", "@@@STEP_LOG_LINE@json.output@ \"WebKit/\": {@@@", - "@@@STEP_LOG_LINE@json.output@ \"revision\": 241198@@@", + "@@@STEP_LOG_LINE@json.output@ \"revision\": \"3eebce6ea96f9e6c03e9252a4f8ef2ea9fe141c2\"@@@", "@@@STEP_LOG_LINE@json.output@ }, @@@", "@@@STEP_LOG_LINE@json.output@ \"src/blatley/\": {@@@", - "@@@STEP_LOG_LINE@json.output@ \"revision\": 248087@@@", + "@@@STEP_LOG_LINE@json.output@ \"revision\": \"5e800497199d615131a76cd10651e74d7c8a0962\"@@@", "@@@STEP_LOG_LINE@json.output@ }@@@", "@@@STEP_LOG_LINE@json.output@ }@@@", "@@@STEP_LOG_LINE@json.output@}@@@", "@@@STEP_LOG_END@json.output@@@", - "@@@SET_BUILD_PROPERTY@got_blatley_revision@248087@@@" + "@@@SET_BUILD_PROPERTY@got_blatley_revision@\"5e800497199d615131a76cd10651e74d7c8a0962\"@@@" ] }, + { + "cmd": [ + "python", + "-u", + "RECIPE_PACKAGE_REPO[depot_tools]/gclient.py", + "recurse", + "git", + "config", + "user.name", + "local_bot" + ], + "cwd": "[SLAVE_BUILD]/src/third_party", + "env": { + "PATH": "%(PATH)s:RECIPE_PACKAGE_REPO[depot_tools]" + }, + "name": "[spec: WebKit] gclient recurse (git config user.name)" + }, + { + "cmd": [ + "python", + "-u", + "RECIPE_PACKAGE_REPO[depot_tools]/gclient.py", + "recurse", + "git", + "config", + "user.email", + "local_bot@example.com" + ], + "cwd": "[SLAVE_BUILD]/src/third_party", + "env": { + "PATH": "%(PATH)s:RECIPE_PACKAGE_REPO[depot_tools]" + }, + "name": "[spec: WebKit] gclient recurse (git config user.email)" + }, { "cmd": [ "python", diff --git a/recipe_modules/gclient/test_api.py b/recipe_modules/gclient/test_api.py index be9338de8..499651bbc 100644 --- a/recipe_modules/gclient/test_api.py +++ b/recipe_modules/gclient/test_api.py @@ -32,6 +32,6 @@ class GclientTestApi(recipe_test_api.RecipeTestApi): h = hashlib.sha1(project) if GIT_MODE: return h.hexdigest() - else: + else: # pragma: no cover import struct return struct.unpack('!I', h.digest()[:4])[0] % 300000