| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 """Recipe module to ensure a checkout is consistant on a bot.""" | 6 """Recipe module to ensure a checkout is consistant on a bot.""" |
| 7 | 7 |
| 8 from recipe_engine import recipe_api | 8 from recipe_engine import recipe_api |
| 9 | 9 |
| 10 | 10 |
| 11 class BotUpdateApi(recipe_api.RecipeApi): | 11 class BotUpdateApi(recipe_api.RecipeApi): |
| 12 | 12 |
| 13 def __init__(self, mastername, buildername, slavename, issue, patchset, | 13 def __init__(self, issue, patchset, repository, gerrit_ref, rietveld, |
| 14 repository, gerrit_ref, rietveld, revision, parent_got_revision, | 14 revision, parent_got_revision, deps_revision_overrides, |
| 15 deps_revision_overrides, fail_patch, *args, **kwargs): | 15 fail_patch, *args, **kwargs): |
| 16 self._mastername = mastername | |
| 17 self._buildername = buildername | |
| 18 self._slavename = slavename | |
| 19 self._issue = issue | 16 self._issue = issue |
| 20 self._patchset = patchset | 17 self._patchset = patchset |
| 21 self._repository = repository | 18 self._repository = repository |
| 22 self._gerrit_ref = gerrit_ref | 19 self._gerrit_ref = gerrit_ref |
| 23 self._rietveld = rietveld | 20 self._rietveld = rietveld |
| 24 self._revision = revision | 21 self._revision = revision |
| 25 self._parent_got_revision = parent_got_revision | 22 self._parent_got_revision = parent_got_revision |
| 26 self._deps_revision_overrides = deps_revision_overrides | 23 self._deps_revision_overrides = deps_revision_overrides |
| 27 self._fail_patch = fail_patch | 24 self._fail_patch = fail_patch |
| 28 | 25 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 patchset: The rietveld issue patchset to use. If omitted, will infer from | 84 patchset: The rietveld issue patchset to use. If omitted, will infer from |
| 88 the 'patchset' property. | 85 the 'patchset' property. |
| 89 """ | 86 """ |
| 90 refs = refs or [] | 87 refs = refs or [] |
| 91 # We can re-use the gclient spec from the gclient module, since all the | 88 # We can re-use the gclient spec from the gclient module, since all the |
| 92 # data bot_update needs is already configured into the gclient spec. | 89 # data bot_update needs is already configured into the gclient spec. |
| 93 cfg = gclient_config or self.m.gclient.c | 90 cfg = gclient_config or self.m.gclient.c |
| 94 assert cfg is not None, ( | 91 assert cfg is not None, ( |
| 95 'missing gclient_config or forgot api.gclient.set_config(...) before?') | 92 'missing gclient_config or forgot api.gclient.set_config(...) before?') |
| 96 | 93 |
| 97 # Used by bot_update to determine if we want to run or not. | |
| 98 master = self._mastername | |
| 99 builder = self._buildername | |
| 100 slave = self._slavename | |
| 101 | |
| 102 # Construct our bot_update command. This basically be inclusive of | 94 # Construct our bot_update command. This basically be inclusive of |
| 103 # everything required for bot_update to know: | 95 # everything required for bot_update to know: |
| 104 root = patch_root | 96 root = patch_root |
| 105 if root is None: | 97 if root is None: |
| 106 root = self.m.gclient.calculate_patch_root( | 98 root = self.m.gclient.calculate_patch_root( |
| 107 self.m.properties.get('patch_project'), cfg) | 99 self.m.properties.get('patch_project'), cfg) |
| 108 | 100 |
| 109 if patch: | 101 if patch: |
| 110 issue = issue or self._issue | 102 issue = issue or self._issue |
| 111 patchset = patchset or self._patchset | 103 patchset = patchset or self._patchset |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 139 |
| 148 # Allow patch_project's revision if necessary. | 140 # Allow patch_project's revision if necessary. |
| 149 # This is important for projects which are checked out as DEPS of the | 141 # This is important for projects which are checked out as DEPS of the |
| 150 # gclient solution. | 142 # gclient solution. |
| 151 self.m.gclient.set_patch_project_revision( | 143 self.m.gclient.set_patch_project_revision( |
| 152 self.m.properties.get('patch_project'), cfg) | 144 self.m.properties.get('patch_project'), cfg) |
| 153 | 145 |
| 154 rev_map = cfg.got_revision_mapping.as_jsonish() | 146 rev_map = cfg.got_revision_mapping.as_jsonish() |
| 155 | 147 |
| 156 flags = [ | 148 flags = [ |
| 157 # 1. Do we want to run? (master/builder/slave). | 149 # What do we want to check out (spec/root/rev/rev_map). |
| 158 ['--master', master], | |
| 159 ['--builder', builder], | |
| 160 ['--slave', slave], | |
| 161 | |
| 162 # 2. What do we want to check out (spec/root/rev/rev_map). | |
| 163 ['--spec', self.m.gclient.config_to_pythonish(cfg)], | 150 ['--spec', self.m.gclient.config_to_pythonish(cfg)], |
| 164 ['--root', root], | 151 ['--root', root], |
| 165 ['--revision_mapping_file', self.m.json.input(rev_map)], | 152 ['--revision_mapping_file', self.m.json.input(rev_map)], |
| 166 ['--git-cache-dir', cfg.cache_dir], | 153 ['--git-cache-dir', cfg.cache_dir], |
| 167 | 154 |
| 168 # 3. How to find the patch, if any (issue/patchset). | 155 # How to find the patch, if any (issue/patchset). |
| 169 ['--issue', issue], | 156 ['--issue', issue], |
| 170 ['--patchset', patchset], | 157 ['--patchset', patchset], |
| 171 ['--rietveld_server', rietveld or self._rietveld], | 158 ['--rietveld_server', rietveld or self._rietveld], |
| 172 ['--gerrit_repo', gerrit_repo], | 159 ['--gerrit_repo', gerrit_repo], |
| 173 ['--gerrit_ref', gerrit_ref], | 160 ['--gerrit_ref', gerrit_ref], |
| 174 ['--apply_issue_email_file', email_file], | 161 ['--apply_issue_email_file', email_file], |
| 175 ['--apply_issue_key_file', key_file], | 162 ['--apply_issue_key_file', key_file], |
| 176 | 163 |
| 177 # 4. Hookups to JSON output back into recipes. | 164 # Hookups to JSON output back into recipes. |
| 178 ['--output_json', self.m.json.output()],] | 165 ['--output_json', self.m.json.output()],] |
| 179 | 166 |
| 180 | 167 |
| 181 # Collect all fixed revisions to simulate them in the json output. | 168 # Collect all fixed revisions to simulate them in the json output. |
| 182 # Fixed revision are the explicit input revisions of bot_update.py, i.e. | 169 # Fixed revision are the explicit input revisions of bot_update.py, i.e. |
| 183 # every command line parameter "--revision name@value". | 170 # every command line parameter "--revision name@value". |
| 184 fixed_revisions = {} | 171 fixed_revisions = {} |
| 185 | 172 |
| 186 revisions = {} | 173 revisions = {} |
| 187 for solution in cfg.solutions: | 174 for solution in cfg.solutions: |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 if with_branch_heads or cfg.with_branch_heads: | 208 if with_branch_heads or cfg.with_branch_heads: |
| 222 cmd.append('--with_branch_heads') | 209 cmd.append('--with_branch_heads') |
| 223 if gerrit_no_reset: | 210 if gerrit_no_reset: |
| 224 cmd.append('--gerrit_no_reset') | 211 cmd.append('--gerrit_no_reset') |
| 225 if gerrit_no_rebase_patch_ref: | 212 if gerrit_no_rebase_patch_ref: |
| 226 cmd.append('--gerrit_no_rebase_patch_ref') | 213 cmd.append('--gerrit_no_rebase_patch_ref') |
| 227 | 214 |
| 228 # Inject Json output for testing. | 215 # Inject Json output for testing. |
| 229 first_sln = cfg.solutions[0].name | 216 first_sln = cfg.solutions[0].name |
| 230 step_test_data = lambda: self.test_api.output_json( | 217 step_test_data = lambda: self.test_api.output_json( |
| 231 master, builder, slave, root, first_sln, rev_map, self._fail_patch, | 218 root, first_sln, rev_map, self._fail_patch, |
| 232 output_manifest=output_manifest, fixed_revisions=fixed_revisions) | 219 output_manifest=output_manifest, fixed_revisions=fixed_revisions) |
| 233 | 220 |
| 234 # Add suffixes to the step name, if specified. | 221 # Add suffixes to the step name, if specified. |
| 235 name = 'bot_update' | 222 name = 'bot_update' |
| 236 if not patch: | 223 if not patch: |
| 237 name += ' (without patch)' | 224 name += ' (without patch)' |
| 238 if suffix: | 225 if suffix: |
| 239 name += ' - %s' % suffix | 226 name += ' - %s' % suffix |
| 240 | 227 |
| 241 # Ah hah! Now that everything is in place, lets run bot_update! | 228 # Ah hah! Now that everything is in place, lets run bot_update! |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 | 283 |
| 297 # bot_update actually just sets root to be the folder name of the | 284 # bot_update actually just sets root to be the folder name of the |
| 298 # first solution. | 285 # first solution. |
| 299 if step_result.json.output['did_run']: | 286 if step_result.json.output['did_run']: |
| 300 co_root = step_result.json.output['root'] | 287 co_root = step_result.json.output['root'] |
| 301 cwd = kwargs.get('cwd', self.m.path['slave_build']) | 288 cwd = kwargs.get('cwd', self.m.path['slave_build']) |
| 302 if 'checkout' not in self.m.path: | 289 if 'checkout' not in self.m.path: |
| 303 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep)) | 290 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep)) |
| 304 | 291 |
| 305 return step_result | 292 return step_result |
| OLD | NEW |