Chromium Code Reviews| Index: recipe_modules/bot_update/api.py |
| diff --git a/recipe_modules/bot_update/api.py b/recipe_modules/bot_update/api.py |
| index ccd725efce2ca9b07bad69dd155b8421779cab9b..1bb27ee2dedfd36be11c613bb7687f75538ae3c5 100644 |
| --- a/recipe_modules/bot_update/api.py |
| +++ b/recipe_modules/bot_update/api.py |
| @@ -48,9 +48,26 @@ def jsonish_to_python(spec, is_top=False): |
| class BotUpdateApi(recipe_api.RecipeApi): |
| - def __init__(self, *args, **kwargs): |
| - self._properties = {} |
| - super(BotUpdateApi, self).__init__(*args, **kwargs) |
| + def __init__(self, mastername, buildername, slavename, issue, patchset, |
| + patch_url, repository, gerrit_ref, rietveld, revision, |
| + parent_got_revision, deps_revision_overrides, fail_patch, |
| + *args, **kwargs): |
| + self._mastername = mastername |
| + self._buildername = buildername |
| + self._slavename = slavename |
| + self._issue = issue |
| + self._patchset = patchset |
| + self._patch_url = patch_url |
| + self._repository = repository |
| + self._gerrit_ref = gerrit_ref |
| + self._rietveld = rietveld |
| + self._revision = revision |
| + self._parent_got_revision = parent_got_revision |
| + self._deps_revision_overrides = deps_revision_overrides |
| + self._fail_patch = fail_patch |
| + |
| + self._last_returned_properties = {} |
| + super(BotUpdateApi, self).__init__(*args, **kwargs) |
| def __call__(self, name, cmd, **kwargs): |
| """Wrapper for easy calling of bot_update.""" |
| @@ -64,16 +81,32 @@ class BotUpdateApi(recipe_api.RecipeApi): |
| return self.m.python(name, bot_update_path, cmd, **kwargs) |
| @property |
| - def properties(self): |
| - return self._properties |
| + def last_returned_properties(self): |
| + return self._last_returned_properties |
| def ensure_checkout(self, gclient_config=None, suffix=None, |
| patch=True, update_presentation=True, |
| force=False, patch_root=None, no_shallow=False, |
| with_branch_heads=False, refs=None, |
| patch_project_roots=None, patch_oauth2=False, |
| - output_manifest=True, clobber=False, |
| - root_solution_revision=None, **kwargs): |
| + output_manifest=True, clobber=False, run_hooks=True, |
| + root_solution_revision=None, rietveld=None, issue=None, |
| + patchset=None, git_cache_dir=None, **kwargs): |
| + """ |
| + Args: |
| + run_hooks: Whether or not to run `gclient runhooks` after we checkout the |
|
Ryan Tseng
2016/03/02 02:09:34
Is this used anywhere?
|
| + code. Defaults to true. |
| + gclient_config: The gclient configuration to use when running bot_update. |
| + If omitted, the current gclient configuration is used. |
| + rietveld: The rietveld server to use. If omitted, will infer from |
| + the 'rietveld' property. |
| + issue: The rietveld issue number to use. If omitted, will infer from |
| + the 'issue' property. |
| + patchset: The rietveld issue patchset to use. If omitted, will infer from |
| + the 'patchset' property. |
| + git_cache_dir: The directory to use as the git cache. If omitted, will use |
| + the 'cache_dir' path in the path api module. |
| + """ |
| refs = refs or [] |
| # We can re-use the gclient spec from the gclient module, since all the |
| # data bot_update needs is already configured into the gclient spec. |
| @@ -81,9 +114,9 @@ class BotUpdateApi(recipe_api.RecipeApi): |
| spec_string = jsonish_to_python(cfg.as_jsonish(), True) |
| # Used by bot_update to determine if we want to run or not. |
| - master = self.m.properties['mastername'] |
| - builder = self.m.properties['buildername'] |
| - slave = self.m.properties['slavename'] |
| + master = self._mastername |
| + builder = self._buildername |
| + slave = self._slavename |
| # Construct our bot_update command. This basically be inclusive of |
| # everything required for bot_update to know: |
| @@ -95,11 +128,11 @@ class BotUpdateApi(recipe_api.RecipeApi): |
| root = self.m.path.join(root, additional) |
| if patch: |
| - issue = self.m.properties.get('issue') |
| - patchset = self.m.properties.get('patchset') |
| - patch_url = self.m.properties.get('patch_url') |
| - gerrit_repo = self.m.properties.get('repository') |
| - gerrit_ref = self.m.properties.get('event.patchSet.ref') |
| + issue = issue or self._issue |
| + patchset = patchset or self._patchset |
| + patch_url = self._patch_url |
| + gerrit_repo = self._repository |
| + gerrit_ref = self._gerrit_ref |
| else: |
| # The trybot recipe sometimes wants to de-apply the patch. In which case |
| # we pretend the issue/patchset/patch_url never existed. |
| @@ -143,13 +176,13 @@ class BotUpdateApi(recipe_api.RecipeApi): |
| ['--spec', spec_string], |
| ['--root', root], |
| ['--revision_mapping_file', self.m.json.input(rev_map)], |
| - ['--git-cache-dir', self.m.path['git_cache']], |
| + ['--git-cache-dir', git_cache_dir or self.m.path['git_cache']], |
| # 3. How to find the patch, if any (issue/patchset/patch_url). |
| ['--issue', issue], |
| ['--patchset', patchset], |
| ['--patch_url', patch_url], |
| - ['--rietveld_server', self.m.properties.get('rietveld')], |
| + ['--rietveld_server', rietveld or self._rietveld], |
| ['--gerrit_repo', gerrit_repo], |
| ['--gerrit_ref', gerrit_ref], |
| ['--apply_issue_email_file', email_file], |
| @@ -170,15 +203,15 @@ class BotUpdateApi(recipe_api.RecipeApi): |
| revisions[solution.name] = solution.revision |
| elif solution == cfg.solutions[0]: |
| revisions[solution.name] = ( |
| - self.m.properties.get('parent_got_revision') or |
| - self.m.properties.get('revision') or |
| + self._parent_got_revision or |
| + self._revision or |
| 'HEAD') |
| if self.m.gclient.c and self.m.gclient.c.revisions: |
| revisions.update(self.m.gclient.c.revisions) |
| if cfg.solutions and root_solution_revision: |
| revisions[cfg.solutions[0].name] = root_solution_revision |
| # Allow for overrides required to bisect into rolls. |
| - revisions.update(self.m.properties.get('deps_revision_overrides', {})) |
| + revisions.update(self._deps_revision_overrides) |
| for name, revision in sorted(revisions.items()): |
| fixed_revision = self.m.gclient.resolve_revision(revision) |
| if fixed_revision: |
| @@ -205,11 +238,11 @@ class BotUpdateApi(recipe_api.RecipeApi): |
| cmd.append('--with_branch_heads') |
| # Inject Json output for testing. |
| - git_mode = self.m.properties.get('mastername') not in SVN_MASTERS |
| + git_mode = self._mastername not in SVN_MASTERS |
| first_sln = cfg.solutions[0].name |
| step_test_data = lambda: self.test_api.output_json( |
| master, builder, slave, root, first_sln, rev_map, git_mode, force, |
| - self.m.properties.get('fail_patch', False), |
| + self._fail_patch, |
| output_manifest=output_manifest, fixed_revisions=fixed_revisions) |
| # Add suffixes to the step name, if specified. |
| @@ -228,7 +261,7 @@ class BotUpdateApi(recipe_api.RecipeApi): |
| ok_ret=(0, 87, 88), **kwargs) |
| finally: |
| step_result = self.m.step.active_result |
| - self._properties = step_result.json.output.get('properties', {}) |
| + self._last_returned__properties = step_result.json.output.get('properties', {}) |
| if update_presentation: |
| # Set properties such as got_revision. |