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 4b870a4b7eef2d5e2fb47b8df480a9459b1a27f2..9660353057b21ffa9933ccb5926cf8a255aff468 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._properties = {} |
|
iannucci
2016/03/01 22:36:22
can we rename this? like _last_returned_properties
martiniss
2016/03/02 01:19:55
Done. Might have to rename callers though, I'll se
|
| + super(BotUpdateApi, self).__init__(*args, **kwargs) |
| def __call__(self, name, cmd, **kwargs): |
| """Wrapper for easy calling of bot_update.""" |
| @@ -73,7 +90,19 @@ class BotUpdateApi(recipe_api.RecipeApi): |
| with_branch_heads=False, refs=None, |
| patch_project_roots=None, patch_oauth2=False, |
| output_manifest=True, clobber=False, |
| - root_solution_revision=None, **kwargs): |
| + root_solution_revision=None, rietveld=None, issue=None, |
| + patchset=None, **kwargs): |
| + """ |
| + Args: |
| + 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 |
| + properties. |
|
iannucci
2016/03/01 22:36:22
mention which property for these. document the for
martiniss
2016/03/02 01:19:55
I mentioned which property these refer to. What do
|
| + issue: The rietveld issue number to use. If omitted, will infer from |
| + properties. |
| + patchset: The rietveld issue patchset to use. If omitted, will infer from |
| + properties. |
| + """ |
| 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 +110,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 +124,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. |
| @@ -151,7 +180,7 @@ class BotUpdateApi(recipe_api.RecipeApi): |
| ['--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], |
| @@ -172,15 +201,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: |
| @@ -207,11 +236,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. |