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 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 cfg = gclient_config or self.m.gclient.c | 78 cfg = gclient_config or self.m.gclient.c |
79 | 79 |
80 # Used by bot_update to determine if we want to run or not. | 80 # Used by bot_update to determine if we want to run or not. |
81 master = self._mastername | 81 master = self._mastername |
82 builder = self._buildername | 82 builder = self._buildername |
83 slave = self._slavename | 83 slave = self._slavename |
84 | 84 |
85 # Construct our bot_update command. This basically be inclusive of | 85 # Construct our bot_update command. This basically be inclusive of |
86 # everything required for bot_update to know: | 86 # everything required for bot_update to know: |
87 root = patch_root | 87 root = patch_root |
| 88 if root == 'TODO(TANDRII): REMOVE THIS TRANSITION TO patch_projects': |
| 89 # This special condition is here for initial rollout of this code, |
| 90 # because it's hard to test this change without rolling into build |
| 91 # repository. |
| 92 # After the switch to new code is complete, this special TODOstring will |
| 93 # be removed in favor of "root is None" |
| 94 assert patch_project_roots is None |
| 95 root = self.m.gclient.calculate_patch_root( |
| 96 self.m.properties.get('patch_project'), cfg) |
| 97 # TODO(tandrii): get rid the condition below after transition. |
| 98 |
88 if root is None: | 99 if root is None: |
89 root = cfg.solutions[0].name | 100 root = cfg.solutions[0].name |
90 additional = self.m.rietveld.calculate_issue_root(patch_project_roots) | 101 additional = self.m.rietveld.calculate_issue_root(patch_project_roots) |
91 if additional: | 102 if additional: |
92 root = self.m.path.join(root, additional) | 103 root = self.m.path.join(root, additional) |
93 | 104 |
94 if patch: | 105 if patch: |
95 issue = issue or self._issue | 106 issue = issue or self._issue |
96 patchset = patchset or self._patchset | 107 patchset = patchset or self._patchset |
97 patch_url = self._patch_url | 108 patch_url = self._patch_url |
(...skipping 23 matching lines...) Expand all Loading... |
121 # Point to the oauth2 auth files if specified. | 132 # Point to the oauth2 auth files if specified. |
122 # These paths are where the bots put their credential files. | 133 # These paths are where the bots put their credential files. |
123 if patch_oauth2: | 134 if patch_oauth2: |
124 email_file = self.m.path['build'].join( | 135 email_file = self.m.path['build'].join( |
125 'site_config', '.rietveld_client_email') | 136 'site_config', '.rietveld_client_email') |
126 key_file = self.m.path['build'].join( | 137 key_file = self.m.path['build'].join( |
127 'site_config', '.rietveld_secret_key') | 138 'site_config', '.rietveld_secret_key') |
128 else: | 139 else: |
129 email_file = key_file = None | 140 email_file = key_file = None |
130 | 141 |
| 142 # Allow patch_project's revision if necessary. |
| 143 # This is important for projects which are checked out as DEPS of the |
| 144 # gclient solution. |
| 145 self.m.gclient.set_patch_project_revision( |
| 146 self.m.properties.get('patch_project'), cfg) |
| 147 |
131 rev_map = cfg.got_revision_mapping.as_jsonish() | 148 rev_map = cfg.got_revision_mapping.as_jsonish() |
132 | 149 |
133 flags = [ | 150 flags = [ |
134 # 1. Do we want to run? (master/builder/slave). | 151 # 1. Do we want to run? (master/builder/slave). |
135 ['--master', master], | 152 ['--master', master], |
136 ['--builder', builder], | 153 ['--builder', builder], |
137 ['--slave', slave], | 154 ['--slave', slave], |
138 | 155 |
139 # 2. What do we want to check out (spec/root/rev/rev_map). | 156 # 2. What do we want to check out (spec/root/rev/rev_map). |
140 ['--spec', self.m.gclient.config_to_pythonish(cfg)], | 157 ['--spec', self.m.gclient.config_to_pythonish(cfg)], |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 | 287 |
271 # bot_update actually just sets root to be the folder name of the | 288 # bot_update actually just sets root to be the folder name of the |
272 # first solution. | 289 # first solution. |
273 if step_result.json.output['did_run']: | 290 if step_result.json.output['did_run']: |
274 co_root = step_result.json.output['root'] | 291 co_root = step_result.json.output['root'] |
275 cwd = kwargs.get('cwd', self.m.path['slave_build']) | 292 cwd = kwargs.get('cwd', self.m.path['slave_build']) |
276 if 'checkout' not in self.m.path: | 293 if 'checkout' not in self.m.path: |
277 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep)) | 294 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep)) |
278 | 295 |
279 return step_result | 296 return step_result |
OLD | NEW |