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, mastername, buildername, slavename, issue, patchset, |
14 patch_url, repository, gerrit_ref, rietveld, revision, | 14 repository, gerrit_ref, rietveld, revision, parent_got_revision, |
15 parent_got_revision, deps_revision_overrides, fail_patch, | 15 deps_revision_overrides, fail_patch, *args, **kwargs): |
16 *args, **kwargs): | |
17 self._mastername = mastername | 16 self._mastername = mastername |
18 self._buildername = buildername | 17 self._buildername = buildername |
19 self._slavename = slavename | 18 self._slavename = slavename |
20 self._issue = issue | 19 self._issue = issue |
21 self._patchset = patchset | 20 self._patchset = patchset |
22 self._patch_url = patch_url | |
23 self._repository = repository | 21 self._repository = repository |
24 self._gerrit_ref = gerrit_ref | 22 self._gerrit_ref = gerrit_ref |
25 self._rietveld = rietveld | 23 self._rietveld = rietveld |
26 self._revision = revision | 24 self._revision = revision |
27 self._parent_got_revision = parent_got_revision | 25 self._parent_got_revision = parent_got_revision |
28 self._deps_revision_overrides = deps_revision_overrides | 26 self._deps_revision_overrides = deps_revision_overrides |
29 self._fail_patch = fail_patch | 27 self._fail_patch = fail_patch |
30 | 28 |
31 self._last_returned_properties = {} | 29 self._last_returned_properties = {} |
32 super(BotUpdateApi, self).__init__(*args, **kwargs) | 30 super(BotUpdateApi, self).__init__(*args, **kwargs) |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 # Construct our bot_update command. This basically be inclusive of | 104 # Construct our bot_update command. This basically be inclusive of |
107 # everything required for bot_update to know: | 105 # everything required for bot_update to know: |
108 root = patch_root | 106 root = patch_root |
109 if root is None: | 107 if root is None: |
110 root = self.m.gclient.calculate_patch_root( | 108 root = self.m.gclient.calculate_patch_root( |
111 self.m.properties.get('patch_project'), cfg) | 109 self.m.properties.get('patch_project'), cfg) |
112 | 110 |
113 if patch: | 111 if patch: |
114 issue = issue or self._issue | 112 issue = issue or self._issue |
115 patchset = patchset or self._patchset | 113 patchset = patchset or self._patchset |
116 patch_url = self._patch_url | |
117 gerrit_repo = self._repository | 114 gerrit_repo = self._repository |
118 gerrit_ref = self._gerrit_ref | 115 gerrit_ref = self._gerrit_ref |
119 else: | 116 else: |
120 # The trybot recipe sometimes wants to de-apply the patch. In which case | 117 # The trybot recipe sometimes wants to de-apply the patch. In which case |
121 # we pretend the issue/patchset/patch_url never existed. | 118 # we pretend the issue/patchset never existed. |
122 issue = patchset = patch_url = email_file = key_file = None | 119 issue = patchset = email_file = key_file = None |
123 gerrit_repo = gerrit_ref = None | 120 gerrit_repo = gerrit_ref = None |
124 | 121 |
125 # Issue and patchset must come together. | 122 # Issue and patchset must come together. |
126 if issue: | 123 if issue: |
127 assert patchset | 124 assert patchset |
128 if patchset: | 125 if patchset: |
129 assert issue | 126 assert issue |
130 if patch_url: | |
131 # If patch_url is present, bot_update will actually ignore issue/ps. | |
132 issue = patchset = None | |
133 | 127 |
134 # The gerrit_ref and gerrit_repo must be together or not at all. If one is | 128 # The gerrit_ref and gerrit_repo must be together or not at all. If one is |
135 # missing, clear both of them. | 129 # missing, clear both of them. |
136 if not gerrit_ref or not gerrit_repo: | 130 if not gerrit_ref or not gerrit_repo: |
137 gerrit_repo = gerrit_ref = None | 131 gerrit_repo = gerrit_ref = None |
138 assert (gerrit_ref != None) == (gerrit_repo != None) | 132 assert (gerrit_ref != None) == (gerrit_repo != None) |
139 | 133 |
140 # Point to the oauth2 auth files if specified. | 134 # Point to the oauth2 auth files if specified. |
141 # These paths are where the bots put their credential files. | 135 # These paths are where the bots put their credential files. |
142 if patch_oauth2: | 136 if patch_oauth2: |
(...skipping 23 matching lines...) Expand all Loading... |
166 ['--master', master], | 160 ['--master', master], |
167 ['--builder', builder], | 161 ['--builder', builder], |
168 ['--slave', slave], | 162 ['--slave', slave], |
169 | 163 |
170 # 2. What do we want to check out (spec/root/rev/rev_map). | 164 # 2. What do we want to check out (spec/root/rev/rev_map). |
171 ['--spec', self.m.gclient.config_to_pythonish(cfg)], | 165 ['--spec', self.m.gclient.config_to_pythonish(cfg)], |
172 ['--root', root], | 166 ['--root', root], |
173 ['--revision_mapping_file', self.m.json.input(rev_map)], | 167 ['--revision_mapping_file', self.m.json.input(rev_map)], |
174 ['--git-cache-dir', cfg.cache_dir], | 168 ['--git-cache-dir', cfg.cache_dir], |
175 | 169 |
176 # 3. How to find the patch, if any (issue/patchset/patch_url). | 170 # 3. How to find the patch, if any (issue/patchset). |
177 ['--issue', issue], | 171 ['--issue', issue], |
178 ['--patchset', patchset], | 172 ['--patchset', patchset], |
179 ['--patch_url', patch_url], | |
180 ['--rietveld_server', rietveld or self._rietveld], | 173 ['--rietveld_server', rietveld or self._rietveld], |
181 ['--gerrit_repo', gerrit_repo], | 174 ['--gerrit_repo', gerrit_repo], |
182 ['--gerrit_ref', gerrit_ref], | 175 ['--gerrit_ref', gerrit_ref], |
183 ['--apply_issue_email_file', email_file], | 176 ['--apply_issue_email_file', email_file], |
184 ['--apply_issue_key_file', key_file], | 177 ['--apply_issue_key_file', key_file], |
185 | 178 |
186 # 4. Hookups to JSON output back into recipes. | 179 # 4. Hookups to JSON output back into recipes. |
187 ['--output_json', self.m.json.output()],] | 180 ['--output_json', self.m.json.output()],] |
188 | 181 |
189 | 182 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 | 301 |
309 # bot_update actually just sets root to be the folder name of the | 302 # bot_update actually just sets root to be the folder name of the |
310 # first solution. | 303 # first solution. |
311 if step_result.json.output['did_run']: | 304 if step_result.json.output['did_run']: |
312 co_root = step_result.json.output['root'] | 305 co_root = step_result.json.output['root'] |
313 cwd = kwargs.get('cwd', self.m.path['slave_build']) | 306 cwd = kwargs.get('cwd', self.m.path['slave_build']) |
314 if 'checkout' not in self.m.path: | 307 if 'checkout' not in self.m.path: |
315 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep)) | 308 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep)) |
316 | 309 |
317 return step_result | 310 return step_result |
OLD | NEW |