diff --git a/recipe_modules/bot_update/api.py b/recipe_modules/bot_update/api.py index 375da9835a..f1f31bd1c3 100644 --- a/recipe_modules/bot_update/api.py +++ b/recipe_modules/bot_update/api.py @@ -148,7 +148,7 @@ class BotUpdateApi(recipe_api.RecipeApi): flags = [ # What do we want to check out (spec/root/rev/rev_map). ['--spec', self.m.gclient.config_to_pythonish(cfg)], - ['--root', root], + ['--patch_root', root], ['--revision_mapping_file', self.m.json.input(rev_map)], ['--git-cache-dir', cfg.cache_dir], diff --git a/recipe_modules/bot_update/example.expected/basic.json b/recipe_modules/bot_update/example.expected/basic.json index 4ab80d928c..75efd0a846 100644 --- a/recipe_modules/bot_update/example.expected/basic.json +++ b/recipe_modules/bot_update/example.expected/basic.json @@ -6,7 +6,7 @@ "RECIPE_MODULE[depot_tools::bot_update]/resources/bot_update.py", "--spec", "cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'https://chromium.googlesource.com/chromium/src.git'}]", - "--root", + "--patch_root", "src", "--revision_mapping_file", "{\"src\": \"got_cr_revision\"}", diff --git a/recipe_modules/bot_update/example.expected/basic_output_manifest.json b/recipe_modules/bot_update/example.expected/basic_output_manifest.json index dfe1e8e73d..f333cf6062 100644 --- a/recipe_modules/bot_update/example.expected/basic_output_manifest.json +++ b/recipe_modules/bot_update/example.expected/basic_output_manifest.json @@ -6,7 +6,7 @@ "RECIPE_MODULE[depot_tools::bot_update]/resources/bot_update.py", "--spec", "cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'https://chromium.googlesource.com/chromium/src.git'}]", - "--root", + "--patch_root", "src", "--revision_mapping_file", "{\"src\": \"got_cr_revision\"}", diff --git a/recipe_modules/bot_update/example.expected/basic_with_branch_heads.json b/recipe_modules/bot_update/example.expected/basic_with_branch_heads.json index 60819286b1..b3c34c0abd 100644 --- a/recipe_modules/bot_update/example.expected/basic_with_branch_heads.json +++ b/recipe_modules/bot_update/example.expected/basic_with_branch_heads.json @@ -6,7 +6,7 @@ "RECIPE_MODULE[depot_tools::bot_update]/resources/bot_update.py", "--spec", "cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'https://chromium.googlesource.com/chromium/src.git'}]", - "--root", + "--patch_root", "src", "--revision_mapping_file", "{\"src\": \"got_cr_revision\"}", diff --git a/recipe_modules/bot_update/example.expected/clobber.json b/recipe_modules/bot_update/example.expected/clobber.json index 88a88bd097..0f511633e6 100644 --- a/recipe_modules/bot_update/example.expected/clobber.json +++ b/recipe_modules/bot_update/example.expected/clobber.json @@ -6,7 +6,7 @@ "RECIPE_MODULE[depot_tools::bot_update]/resources/bot_update.py", "--spec", "cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'https://chromium.googlesource.com/chromium/src.git'}]", - "--root", + "--patch_root", "src", "--revision_mapping_file", "{\"src\": \"got_cr_revision\"}", diff --git a/recipe_modules/bot_update/example.expected/gerrit_no_rebase_patch_ref.json b/recipe_modules/bot_update/example.expected/gerrit_no_rebase_patch_ref.json index 1e0a058cf4..cbaab11c6f 100644 --- a/recipe_modules/bot_update/example.expected/gerrit_no_rebase_patch_ref.json +++ b/recipe_modules/bot_update/example.expected/gerrit_no_rebase_patch_ref.json @@ -6,7 +6,7 @@ "RECIPE_MODULE[depot_tools::bot_update]/resources/bot_update.py", "--spec", "cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'https://chromium.googlesource.com/chromium/src.git'}]", - "--root", + "--patch_root", "src", "--revision_mapping_file", "{\"src\": \"got_cr_revision\"}", diff --git a/recipe_modules/bot_update/example.expected/gerrit_no_reset.json b/recipe_modules/bot_update/example.expected/gerrit_no_reset.json index 38e5cabeaf..118998391a 100644 --- a/recipe_modules/bot_update/example.expected/gerrit_no_reset.json +++ b/recipe_modules/bot_update/example.expected/gerrit_no_reset.json @@ -6,7 +6,7 @@ "RECIPE_MODULE[depot_tools::bot_update]/resources/bot_update.py", "--spec", "cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'https://chromium.googlesource.com/chromium/src.git'}]", - "--root", + "--patch_root", "src", "--revision_mapping_file", "{\"src\": \"got_cr_revision\"}", diff --git a/recipe_modules/bot_update/example.expected/no_shallow.json b/recipe_modules/bot_update/example.expected/no_shallow.json index 3e7deaf30a..0c5ffe3e08 100644 --- a/recipe_modules/bot_update/example.expected/no_shallow.json +++ b/recipe_modules/bot_update/example.expected/no_shallow.json @@ -6,7 +6,7 @@ "RECIPE_MODULE[depot_tools::bot_update]/resources/bot_update.py", "--spec", "cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'https://chromium.googlesource.com/chromium/src.git'}]", - "--root", + "--patch_root", "src", "--revision_mapping_file", "{\"src\": \"got_cr_revision\"}", diff --git a/recipe_modules/bot_update/example.expected/reset_root_solution_revision.json b/recipe_modules/bot_update/example.expected/reset_root_solution_revision.json index dd65997bf4..0d9fb489ba 100644 --- a/recipe_modules/bot_update/example.expected/reset_root_solution_revision.json +++ b/recipe_modules/bot_update/example.expected/reset_root_solution_revision.json @@ -6,7 +6,7 @@ "RECIPE_MODULE[depot_tools::bot_update]/resources/bot_update.py", "--spec", "cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'https://chromium.googlesource.com/chromium/src.git'}]", - "--root", + "--patch_root", "src", "--revision_mapping_file", "{\"src\": \"got_cr_revision\"}", diff --git a/recipe_modules/bot_update/example.expected/trychange.json b/recipe_modules/bot_update/example.expected/trychange.json index 0ca4b235d6..2a6e0ac393 100644 --- a/recipe_modules/bot_update/example.expected/trychange.json +++ b/recipe_modules/bot_update/example.expected/trychange.json @@ -6,7 +6,7 @@ "RECIPE_MODULE[depot_tools::bot_update]/resources/bot_update.py", "--spec", "cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'https://chromium.googlesource.com/chromium/src.git'}]", - "--root", + "--patch_root", "src", "--revision_mapping_file", "{\"src\": \"got_cr_revision\"}", diff --git a/recipe_modules/bot_update/example.expected/trychange_oauth2.json b/recipe_modules/bot_update/example.expected/trychange_oauth2.json index 31014bdd99..b0917d4bf4 100644 --- a/recipe_modules/bot_update/example.expected/trychange_oauth2.json +++ b/recipe_modules/bot_update/example.expected/trychange_oauth2.json @@ -6,7 +6,7 @@ "RECIPE_MODULE[depot_tools::bot_update]/resources/bot_update.py", "--spec", "cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'https://chromium.googlesource.com/chromium/src.git'}]", - "--root", + "--patch_root", "src", "--revision_mapping_file", "{\"src\": \"got_cr_revision\"}", diff --git a/recipe_modules/bot_update/example.expected/tryjob.json b/recipe_modules/bot_update/example.expected/tryjob.json index 96f2e6c42f..ee56bb1995 100644 --- a/recipe_modules/bot_update/example.expected/tryjob.json +++ b/recipe_modules/bot_update/example.expected/tryjob.json @@ -6,7 +6,7 @@ "RECIPE_MODULE[depot_tools::bot_update]/resources/bot_update.py", "--spec", "cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'https://chromium.googlesource.com/chromium/src.git'}]", - "--root", + "--patch_root", "src", "--revision_mapping_file", "{\"src\": \"got_cr_revision\"}", diff --git a/recipe_modules/bot_update/example.expected/tryjob_fail.json b/recipe_modules/bot_update/example.expected/tryjob_fail.json index 2164069305..7f720ab359 100644 --- a/recipe_modules/bot_update/example.expected/tryjob_fail.json +++ b/recipe_modules/bot_update/example.expected/tryjob_fail.json @@ -6,7 +6,7 @@ "RECIPE_MODULE[depot_tools::bot_update]/resources/bot_update.py", "--spec", "cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'https://chromium.googlesource.com/chromium/src.git'}]", - "--root", + "--patch_root", "src", "--revision_mapping_file", "{\"src\": \"got_cr_revision\"}", diff --git a/recipe_modules/bot_update/example.expected/tryjob_fail_patch.json b/recipe_modules/bot_update/example.expected/tryjob_fail_patch.json index e791d75613..ed3caebc54 100644 --- a/recipe_modules/bot_update/example.expected/tryjob_fail_patch.json +++ b/recipe_modules/bot_update/example.expected/tryjob_fail_patch.json @@ -6,7 +6,7 @@ "RECIPE_MODULE[depot_tools::bot_update]/resources/bot_update.py", "--spec", "cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'https://chromium.googlesource.com/chromium/src.git'}]", - "--root", + "--patch_root", "src", "--revision_mapping_file", "{\"src\": \"got_cr_revision\"}", diff --git a/recipe_modules/bot_update/example.expected/tryjob_fail_patch_download.json b/recipe_modules/bot_update/example.expected/tryjob_fail_patch_download.json index 37a6dbb5d4..4328d4b907 100644 --- a/recipe_modules/bot_update/example.expected/tryjob_fail_patch_download.json +++ b/recipe_modules/bot_update/example.expected/tryjob_fail_patch_download.json @@ -6,7 +6,7 @@ "RECIPE_MODULE[depot_tools::bot_update]/resources/bot_update.py", "--spec", "cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'https://chromium.googlesource.com/chromium/src.git'}]", - "--root", + "--patch_root", "src", "--revision_mapping_file", "{\"src\": \"got_cr_revision\"}", diff --git a/recipe_modules/bot_update/example.expected/tryjob_gerrit_angle.json b/recipe_modules/bot_update/example.expected/tryjob_gerrit_angle.json index e94ec08f7c..4d1d7b89a0 100644 --- a/recipe_modules/bot_update/example.expected/tryjob_gerrit_angle.json +++ b/recipe_modules/bot_update/example.expected/tryjob_gerrit_angle.json @@ -6,7 +6,7 @@ "RECIPE_MODULE[depot_tools::bot_update]/resources/bot_update.py", "--spec", "cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'https://chromium.googlesource.com/chromium/src.git'}]", - "--root", + "--patch_root", "src/third_party/angle", "--revision_mapping_file", "{\"src\": \"got_cr_revision\"}", diff --git a/recipe_modules/bot_update/example.expected/tryjob_v8.json b/recipe_modules/bot_update/example.expected/tryjob_v8.json index 01bc4f27a4..105604bc79 100644 --- a/recipe_modules/bot_update/example.expected/tryjob_v8.json +++ b/recipe_modules/bot_update/example.expected/tryjob_v8.json @@ -6,7 +6,7 @@ "RECIPE_MODULE[depot_tools::bot_update]/resources/bot_update.py", "--spec", "cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'https://chromium.googlesource.com/chromium/src.git'}]", - "--root", + "--patch_root", "src/v8", "--revision_mapping_file", "{\"src\": \"got_cr_revision\"}", diff --git a/recipe_modules/bot_update/example.expected/tryjob_v8_head_by_default.json b/recipe_modules/bot_update/example.expected/tryjob_v8_head_by_default.json index 4cabfbf18f..ed4352e213 100644 --- a/recipe_modules/bot_update/example.expected/tryjob_v8_head_by_default.json +++ b/recipe_modules/bot_update/example.expected/tryjob_v8_head_by_default.json @@ -6,7 +6,7 @@ "RECIPE_MODULE[depot_tools::bot_update]/resources/bot_update.py", "--spec", "cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'https://chromium.googlesource.com/chromium/src.git'}]", - "--root", + "--patch_root", "src/v8", "--revision_mapping_file", "{\"src\": \"got_cr_revision\"}", diff --git a/recipe_modules/bot_update/resources/bot_update.py b/recipe_modules/bot_update/resources/bot_update.py index 08851020dd..044f0838f2 100755 --- a/recipe_modules/bot_update/resources/bot_update.py +++ b/recipe_modules/bot_update/resources/bot_update.py @@ -622,23 +622,6 @@ def apply_gerrit_ref(gerrit_repo, gerrit_ref, root, gerrit_reset, except SubprocessFailed as e: raise PatchFailed(e.message, e.code, e.output) -def check_flag(flag_file): - """Returns True if the flag file is present.""" - return os.path.isfile(flag_file) - - -def delete_flag(flag_file): - """Remove bot update flag.""" - if os.path.isfile(flag_file): - os.remove(flag_file) - - -def emit_flag(flag_file): - """Deposit a bot update flag on the system to tell gclient not to run.""" - print 'Emitting flag file at %s' % flag_file - with open(flag_file, 'wb') as f: - f.write('Success!') - def get_commit_position(git_path, revision='HEAD'): """Dumps the 'git' log for a specific revision and parses out the commit @@ -850,14 +833,9 @@ def parse_args(): parse.add_option('--gerrit_no_reset', action='store_true', help='Bypass calling reset after applying a gerrit ref.') parse.add_option('--specs', help='Gcilent spec.') - parse.add_option('-f', '--force', action='store_true', - help='Bypass check to see if we want to be run. ' - 'Should ONLY be used locally or by smart recipes.') - parse.add_option('--revision_mapping', - help='{"path/to/repo/": "property_name"}') parse.add_option('--revision_mapping_file', - help=('Same as revision_mapping, except its a path to a json' - ' file containing that format.')) + help=('Path to a json file of the form ' + '{"path/to/repo/": "property_name"}')) parse.add_option('--revision', action='append', default=[], help='Revision to check out. Can be any form of git ref. ' 'Can prepend root@ to specify which repository, ' @@ -865,19 +843,9 @@ def parse_args(): 'url. To specify Tip of Tree, set rev to HEAD. ') parse.add_option('--output_manifest', action='store_true', help=('Add manifest json to the json output.')) - parse.add_option('--slave_name', default=socket.getfqdn().split('.')[0], - help='Hostname of the current machine, ' - 'used for determining whether or not to activate.') - parse.add_option('--build_dir', default=os.getcwd()) - parse.add_option('--flag_file', default=path.join(os.getcwd(), - 'update.flag')) - parse.add_option('--shallow', action='store_true', - help='Use shallow clones for cache repositories.') parse.add_option('--clobber', action='store_true', help='Delete checkout first, always') - parse.add_option('--bot_update_clobber', action='store_true', dest='clobber', - help='(synonym for --clobber)') - parse.add_option('-o', '--output_json', + parse.add_option('--output_json', help='Output JSON information into a specified file') parse.add_option('--no_shallow', action='store_true', help='Bypass disk detection and never shallow clone. ' @@ -904,14 +872,11 @@ def parse_args(): del options.with_branch_heads try: - if options.revision_mapping_file: - if options.revision_mapping: - print ('WARNING: Ignoring --revision_mapping: --revision_mapping_file ' - 'was set at the same time as --revision_mapping?') - with open(options.revision_mapping_file, 'r') as f: - options.revision_mapping = json.load(f) - elif options.revision_mapping: - options.revision_mapping = json.loads(options.revision_mapping) + if not options.revision_mapping_file: + parse.error('--revision_mapping_file is required') + + with open(options.revision_mapping_file, 'r') as f: + options.revision_mapping = json.load(f) except Exception as e: print ( 'WARNING: Caught execption while parsing revision_mapping*: %s' @@ -930,14 +895,10 @@ def parse_args(): def prepare(options, git_slns, active): """Prepares the target folder before we checkout.""" dir_names = [sln.get('name') for sln in git_slns if 'name' in sln] - # If we're active now, but the flag file doesn't exist (we weren't active - # last run) or vice versa, blow away all checkouts. - if options.clobber or (bool(active) != bool(check_flag(options.flag_file))): + if options.clobber: ensure_no_checkout(dir_names) - if options.output_json: - # Make sure we tell recipes that we didn't run if the script exits here. - emit_json(options.output_json, did_run=active) - emit_flag(options.flag_file) + # Make sure we tell recipes that we didn't run if the script exits here. + emit_json(options.output_json, did_run=active) # Do a shallow checkout if the disk is less than 100GB. total_disk_space, free_disk_space = get_total_disk_space() @@ -950,9 +911,8 @@ def prepare(options, git_slns, active): percent_used) if not options.output_json: print '@@@STEP_TEXT@%s@@@' % step_text - if not options.shallow: - options.shallow = (total_disk_space < SHALLOW_CLONE_THRESHOLD - and not options.no_shallow) + shallow = (total_disk_space < SHALLOW_CLONE_THRESHOLD + and not options.no_shallow) # The first solution is where the primary DEPS file resides. first_sln = dir_names[0] @@ -961,10 +921,10 @@ def prepare(options, git_slns, active): print 'Revisions: %s' % options.revision revisions = parse_revisions(options.revision, first_sln) print 'Fetching Git checkout at %s@%s' % (first_sln, revisions[first_sln]) - return revisions, step_text + return revisions, step_text, shallow -def checkout(options, git_slns, specs, revisions, step_text): +def checkout(options, git_slns, specs, revisions, step_text, shallow): first_sln = git_slns[0]['name'] dir_names = [sln.get('name') for sln in git_slns if 'name' in sln] try: @@ -994,7 +954,7 @@ def checkout(options, git_slns, specs, revisions, step_text): apply_issue_key_file=options.apply_issue_key_file, # Finally, extra configurations such as shallowness of the clone. - shallow=options.shallow, + shallow=shallow, refs=options.refs, git_cache_dir=options.git_cache_dir, gerrit_reset=not options.gerrit_no_reset) @@ -1073,10 +1033,6 @@ def main(): # Get inputs. options, _ = parse_args() - # Always run. This option will be removed in a later CL, but for now make sure - # that bot_update is ALWAYS set to run, no matter what. - options.force = True - # Check if this script should activate or not. active = True @@ -1093,11 +1049,10 @@ def main(): try: # Dun dun dun, the main part of bot_update. - revisions, step_text = prepare(options, git_slns, active) - checkout(options, git_slns, specs, revisions, step_text) + revisions, step_text, shallow = prepare(options, git_slns, active) + checkout(options, git_slns, specs, revisions, step_text, shallow) except PatchFailed as e: - emit_flag(options.flag_file) # Return a specific non-zero exit code for patch failure (because it is # a failure), but make it different than other failures to distinguish # between infra failures (independent from patch author), and patch @@ -1108,12 +1063,6 @@ def main(): return 87 # Genuine patch problem. return 88 - except Exception: - # Unexpected failure. - emit_flag(options.flag_file) - raise - else: - emit_flag(options.flag_file) if __name__ == '__main__':