Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: recipe_modules/bot_update/api.py

Issue 1741983002: bot_update: Rewrite to use properties, and add override options for patches. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Rebase. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 @property 83 @property
84 def last_returned_properties(self): 84 def last_returned_properties(self):
85 return self._last_returned_properties 85 return self._last_returned_properties
86 86
87 def ensure_checkout(self, gclient_config=None, suffix=None, 87 def ensure_checkout(self, gclient_config=None, suffix=None,
88 patch=True, update_presentation=True, 88 patch=True, update_presentation=True,
89 force=False, patch_root=None, no_shallow=False, 89 force=False, patch_root=None, no_shallow=False,
90 with_branch_heads=False, refs=None, 90 with_branch_heads=False, refs=None,
91 patch_project_roots=None, patch_oauth2=False, 91 patch_project_roots=None, patch_oauth2=False,
92 output_manifest=True, clobber=False, 92 output_manifest=True, clobber=False,
93 root_solution_revision=None, **kwargs): 93 root_solution_revision=None, rietveld=None, issue=None,
94 patchset=None, **kwargs):
95 """
96 Args:
97 gclient_config: The gclient configuration to use when running bot_update.
98 If omitted, the current gclient configuration is used.
99 rietveld: The rietveld server to use. If omitted, will infer from
100 the 'rietveld' property.
101 issue: The rietveld issue number to use. If omitted, will infer from
102 the 'issue' property.
103 patchset: The rietveld issue patchset to use. If omitted, will infer from
104 the 'patchset' property.
105 """
94 refs = refs or [] 106 refs = refs or []
95 # We can re-use the gclient spec from the gclient module, since all the 107 # We can re-use the gclient spec from the gclient module, since all the
96 # data bot_update needs is already configured into the gclient spec. 108 # data bot_update needs is already configured into the gclient spec.
97 cfg = gclient_config or self.m.gclient.c 109 cfg = gclient_config or self.m.gclient.c
98 spec_string = jsonish_to_python(cfg.as_jsonish(), True) 110 spec_string = jsonish_to_python(cfg.as_jsonish(), True)
99 111
100 # Used by bot_update to determine if we want to run or not. 112 # Used by bot_update to determine if we want to run or not.
101 master = self._mastername 113 master = self._mastername
102 builder = self._buildername 114 builder = self._buildername
103 slave = self._slavename 115 slave = self._slavename
104 116
105 # Construct our bot_update command. This basically be inclusive of 117 # Construct our bot_update command. This basically be inclusive of
106 # everything required for bot_update to know: 118 # everything required for bot_update to know:
107 root = patch_root 119 root = patch_root
108 if root is None: 120 if root is None:
109 root = cfg.solutions[0].name 121 root = cfg.solutions[0].name
110 additional = self.m.rietveld.calculate_issue_root(patch_project_roots) 122 additional = self.m.rietveld.calculate_issue_root(patch_project_roots)
111 if additional: 123 if additional:
112 root = self.m.path.join(root, additional) 124 root = self.m.path.join(root, additional)
113 125
114 if patch: 126 if patch:
115 issue = self._issue 127 issue = issue or self._issue
116 patchset = self._patchset 128 patchset = patchset or self._patchset
117 patch_url = self._patch_url 129 patch_url = self._patch_url
118 gerrit_repo = self._repository 130 gerrit_repo = self._repository
119 gerrit_ref = self._gerrit_ref 131 gerrit_ref = self._gerrit_ref
120 else: 132 else:
121 # The trybot recipe sometimes wants to de-apply the patch. In which case 133 # The trybot recipe sometimes wants to de-apply the patch. In which case
122 # we pretend the issue/patchset/patch_url never existed. 134 # we pretend the issue/patchset/patch_url never existed.
123 issue = patchset = patch_url = email_file = key_file = None 135 issue = patchset = patch_url = email_file = key_file = None
124 gerrit_repo = gerrit_ref = None 136 gerrit_repo = gerrit_ref = None
125 137
126 # Issue and patchset must come together. 138 # Issue and patchset must come together.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 # 2. What do we want to check out (spec/root/rev/rev_map). 171 # 2. What do we want to check out (spec/root/rev/rev_map).
160 ['--spec', spec_string], 172 ['--spec', spec_string],
161 ['--root', root], 173 ['--root', root],
162 ['--revision_mapping_file', self.m.json.input(rev_map)], 174 ['--revision_mapping_file', self.m.json.input(rev_map)],
163 ['--git-cache-dir', cfg.cache_dir], 175 ['--git-cache-dir', cfg.cache_dir],
164 176
165 # 3. How to find the patch, if any (issue/patchset/patch_url). 177 # 3. How to find the patch, if any (issue/patchset/patch_url).
166 ['--issue', issue], 178 ['--issue', issue],
167 ['--patchset', patchset], 179 ['--patchset', patchset],
168 ['--patch_url', patch_url], 180 ['--patch_url', patch_url],
169 ['--rietveld_server', self._rietveld], 181 ['--rietveld_server', rietveld or self._rietveld],
170 ['--gerrit_repo', gerrit_repo], 182 ['--gerrit_repo', gerrit_repo],
171 ['--gerrit_ref', gerrit_ref], 183 ['--gerrit_ref', gerrit_ref],
172 ['--apply_issue_email_file', email_file], 184 ['--apply_issue_email_file', email_file],
173 ['--apply_issue_key_file', key_file], 185 ['--apply_issue_key_file', key_file],
174 186
175 # 4. Hookups to JSON output back into recipes. 187 # 4. Hookups to JSON output back into recipes.
176 ['--output_json', self.m.json.output()],] 188 ['--output_json', self.m.json.output()],]
177 189
178 190
179 # Collect all fixed revisions to simulate them in the json output. 191 # Collect all fixed revisions to simulate them in the json output.
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 300
289 # bot_update actually just sets root to be the folder name of the 301 # bot_update actually just sets root to be the folder name of the
290 # first solution. 302 # first solution.
291 if step_result.json.output['did_run']: 303 if step_result.json.output['did_run']:
292 co_root = step_result.json.output['root'] 304 co_root = step_result.json.output['root']
293 cwd = kwargs.get('cwd', self.m.path['slave_build']) 305 cwd = kwargs.get('cwd', self.m.path['slave_build'])
294 if 'checkout' not in self.m.path: 306 if 'checkout' not in self.m.path:
295 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep)) 307 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep))
296 308
297 return step_result 309 return step_result
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698