From da8a67b497f55971f6fa68b9436eaa0c667ec5cc Mon Sep 17 00:00:00 2001 From: Edward Lesmes Date: Fri, 21 May 2021 16:50:36 +0000 Subject: [PATCH] bot_update: Remove unused arguments/code. Change-Id: I4a6811f4dd3c5330eed821acd2dc4855aabcf483 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2911202 Reviewed-by: Gavin Mak Commit-Queue: Edward Lesmes --- .../bot_update/resources/bot_update.py | 74 ++----------------- tests/bot_update_coverage_test.py | 48 ------------ 2 files changed, 7 insertions(+), 115 deletions(-) diff --git a/recipes/recipe_modules/bot_update/resources/bot_update.py b/recipes/recipe_modules/bot_update/resources/bot_update.py index 058dcaf719..99788c60cf 100755 --- a/recipes/recipe_modules/bot_update/resources/bot_update.py +++ b/recipes/recipe_modules/bot_update/resources/bot_update.py @@ -381,8 +381,8 @@ def git_config_if_not_set(key, value): def gclient_sync( - with_branch_heads, with_tags, revisions, break_repo_locks, - disable_syntax_validation, patch_refs, gerrit_reset, + with_branch_heads, with_tags, revisions, + patch_refs, gerrit_reset, gerrit_rebase_patch_ref): # We just need to allocate a filename. fd, gclient_output_file = tempfile.mkstemp(suffix='.json') @@ -395,10 +395,6 @@ def gclient_sync( args += ['--with_branch_heads'] if with_tags: args += ['--with_tags'] - if break_repo_locks: - args += ['--break_repo_locks'] - if disable_syntax_validation: - args += ['--disable-syntax-validation'] for name, revision in sorted(revisions.items()): if revision.upper() == 'HEAD': revision = 'refs/remotes/origin/master' @@ -456,8 +452,7 @@ def normalize_git_url(url): return 'https://%s%s' % (p.netloc, upath) -# TODO(hinoka): Remove this once all downstream recipes stop using this format. -def create_manifest_old(): +def create_manifest(): manifest = {} output = gclient_revinfo() for line in output.strip().splitlines(): @@ -472,49 +467,6 @@ def create_manifest_old(): return manifest -# TODO(hinoka): Include patch revision. -def create_manifest(gclient_output, patch_root): - """Return the JSONPB equivalent of the source manifest proto. - - The source manifest proto is defined here: - https://chromium.googlesource.com/infra/luci/recipes-py/+/master/recipe_engine/source_manifest.proto - - This is based off of: - * The gclient_output (from calling gclient.py --output-json) which contains - the directory -> repo:revision mapping. - * Gerrit Patch info which contains info about patched revisions. - - We normalize the URLs using the normalize_git_url function. - """ - manifest = { - 'version': 0, # Currently the only valid version is 0. - } - dirs = {} - if patch_root: - patch_root = patch_root.strip('/') # Normalize directory names. - for directory, info in gclient_output.get('solutions', {}).items(): - directory = directory.strip('/') # Normalize the directory name. - # The format of the url is "https://repo.url/blah.git@abcdefabcdef" or - # just "https://repo.url/blah.git" - url = info.get('url') or '' - repo, _, url_revision = url.partition('@') - repo = normalize_git_url(repo) - # There are two places to get the revision from, we do it in this order: - # 1. In the "revision" field - # 2. At the end of the URL, after @ - revision = info.get('revision') or url_revision - if repo and revision: - dirs[directory] = { - 'git_checkout': { - 'repo_url': repo, - 'revision': revision, - } - } - - manifest['directories'] = dirs - return manifest - - def get_commit_message_footer_map(message): """Returns: (dict) A dictionary of commit message footer entries. """ @@ -851,10 +803,9 @@ def parse_got_revision(gclient_output, got_revision_mapping): return properties -def emit_json(out_file, did_run, gclient_output=None, **kwargs): +def emit_json(out_file, did_run, **kwargs): """Write run information into a JSON file.""" output = {} - output.update(gclient_output if gclient_output else {}) output.update({'did_run': did_run}) output.update(kwargs) with open(out_file, 'wb') as f: @@ -865,7 +816,7 @@ def emit_json(out_file, did_run, gclient_output=None, **kwargs): def ensure_checkout(solutions, revisions, first_sln, target_os, target_os_only, target_cpu, patch_root, patch_refs, gerrit_rebase_patch_ref, no_fetch_tags, refs, git_cache_dir, cleanup_dir, - gerrit_reset, disable_syntax_validation, enforce_fetch): + gerrit_reset, enforce_fetch): # Get a checkout of each solution, without DEPS or hooks. # Calling git directly because there is no way to run Gclient without # invoking DEPS. @@ -878,9 +829,6 @@ def ensure_checkout(solutions, revisions, first_sln, target_os, target_os_only, gclient_configure(solutions, target_os, target_os_only, target_cpu, git_cache_dir) - # Windows sometimes has trouble deleting files. This can make git commands - # that rely on locks fail. - break_repo_locks = True if sys.platform.startswith('win') else False # We want to pass all non-solution revisions into the gclient sync call. solution_dirs = {sln['name'] for sln in solutions} gc_revisions = { @@ -899,8 +847,6 @@ def ensure_checkout(solutions, revisions, first_sln, target_os, target_os_only, BRANCH_HEADS_REFSPEC in refs, TAGS_REFSPEC in refs, gc_revisions, - break_repo_locks, - disable_syntax_validation, patch_refs, gerrit_reset, gerrit_rebase_patch_ref) @@ -1013,9 +959,6 @@ def parse_args(): parse.add_option('--cleanup-dir', help='Path to a cleanup directory that can be used for ' 'deferred file cleanup.') - parse.add_option( - '--disable-syntax-validation', action='store_true', - help='Disable validation of .gclient and DEPS syntax.') options, args = parse.parse_args() @@ -1142,8 +1085,7 @@ def checkout(options, git_slns, specs, revisions, step_text): refs=options.refs, git_cache_dir=options.git_cache_dir, cleanup_dir=options.cleanup_dir, - gerrit_reset=not options.gerrit_no_reset, - disable_syntax_validation=options.disable_syntax_validation) + gerrit_reset=not options.gerrit_no_reset) gclient_output = ensure_checkout(**checkout_parameters) should_delete_dirty_file = True except GclientSyncFailed: @@ -1200,9 +1142,7 @@ def checkout(options, git_slns, specs, revisions, step_text): step_text=step_text, fixed_revisions=revisions, properties=got_revisions, - manifest=create_manifest_old(), - source_manifest=create_manifest( - gclient_output, options.patch_root)) + manifest=create_manifest()) def print_debug_info(): diff --git a/tests/bot_update_coverage_test.py b/tests/bot_update_coverage_test.py index e3afee7c70..811a7c2ead 100755 --- a/tests/bot_update_coverage_test.py +++ b/tests/bot_update_coverage_test.py @@ -156,7 +156,6 @@ class BotUpdateUnittests(unittest.TestCase): 'git_cache_dir': '', 'cleanup_dir': None, 'gerrit_reset': None, - 'disable_syntax_validation': False, 'enforce_fetch': False, } @@ -267,16 +266,6 @@ class BotUpdateUnittests(unittest.TestCase): self.assertIn(self.params['patch_refs'][0], patch_refs) self.assertIn(self.params['patch_refs'][1], patch_refs) - def testBreakLocks(self): - self.overrideSetupForWindows() - bot_update.ensure_checkout(**self.params) - gclient_sync_cmd = None - for record in self.call.records: - args = record[0] - if args[:4] == (sys.executable, '-u', bot_update.GCLIENT_PATH, 'sync'): - gclient_sync_cmd = args - self.assertTrue('--break_repo_locks' in gclient_sync_cmd) - def testGitCheckoutBreaksLocks(self): self.overrideSetupForWindows() path = '/b/build/foo/build/.git' @@ -291,43 +280,6 @@ class BotUpdateUnittests(unittest.TestCase): setattr(os, 'remove', old_os_remove) self.assertTrue(os.path.join(path, lockfile) in removed) - def testGenerateManifestsBasic(self): - gclient_output = { - 'solutions': { - 'breakpad/': { - 'revision': None, - 'scm': None, - 'url': ('https://chromium.googlesource.com/breakpad.git' + - '@5f638d532312685548d5033618c8a36f73302d0a') - }, - "src/": { - 'revision': 'f671d3baeb64d9dba628ad582e867cf1aebc0207', - 'scm': None, - 'url': 'https://chromium.googlesource.com/a/chromium/src.git' - }, - 'src/overriden': { - 'revision': None, - 'scm': 'git', - 'url': None, - }, - } - } - out = bot_update.create_manifest(gclient_output, None) - self.assertEqual(len(out['directories']), 2) - self.assertEqual( - out['directories']['src']['git_checkout']['revision'], - 'f671d3baeb64d9dba628ad582e867cf1aebc0207') - self.assertEqual( - out['directories']['src']['git_checkout']['repo_url'], - 'https://chromium.googlesource.com/chromium/src') - self.assertEqual( - out['directories']['breakpad']['git_checkout']['revision'], - '5f638d532312685548d5033618c8a36f73302d0a') - self.assertEqual( - out['directories']['breakpad']['git_checkout']['repo_url'], - 'https://chromium.googlesource.com/breakpad') - self.assertNotIn('src/overridden', out['directories']) - def testParsesRevisions(self): revisions = [ 'f671d3baeb64d9dba628ad582e867cf1aebc0207',