Chromium Code Reviews| 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 import collections | 5 import collections |
| 6 import contextlib | 6 import contextlib |
| 7 import hashlib | 7 import hashlib |
| 8 import os | |
| 9 import sys | |
| 10 import uuid | |
| 8 | 11 |
| 9 from recipe_engine import recipe_api | 12 from recipe_engine import recipe_api |
| 10 | 13 |
| 11 | 14 |
| 12 PATCH_STORAGE_RIETVELD = 'rietveld' | 15 PATCH_STORAGE_RIETVELD = 'rietveld' |
| 16 PATCH_STORAGE_GERRIT = 'gerrit' | |
| 13 PATCH_STORAGE_GIT = 'git' | 17 PATCH_STORAGE_GIT = 'git' |
| 14 PATCH_STORAGE_SVN = 'svn' | 18 PATCH_STORAGE_SVN = 'svn' |
| 15 | 19 |
| 16 | 20 |
| 17 class TryserverApi(recipe_api.RecipeApi): | 21 class TryserverApi(recipe_api.RecipeApi): |
| 18 def __init__(self, *args, **kwargs): | 22 def __init__(self, *args, **kwargs): |
| 19 super(TryserverApi, self).__init__(*args, **kwargs) | 23 super(TryserverApi, self).__init__(*args, **kwargs) |
| 20 self._failure_reasons = [] | 24 self._failure_reasons = [] |
| 21 | 25 |
| 22 @property | 26 @property |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 def maybe_apply_issue(self, cwd=None, authentication=None): | 133 def maybe_apply_issue(self, cwd=None, authentication=None): |
| 130 """If we're a trybot, apply a codereview issue. | 134 """If we're a trybot, apply a codereview issue. |
| 131 | 135 |
| 132 Args: | 136 Args: |
| 133 cwd: If specified, apply the patch from the specified directory. | 137 cwd: If specified, apply the patch from the specified directory. |
| 134 authentication: authentication scheme whenever apply_issue.py is called. | 138 authentication: authentication scheme whenever apply_issue.py is called. |
| 135 This is only used if the patch comes from Rietveld. Possible values: | 139 This is only used if the patch comes from Rietveld. Possible values: |
| 136 None, 'oauth2' (see also api.rietveld.apply_issue.) | 140 None, 'oauth2' (see also api.rietveld.apply_issue.) |
| 137 """ | 141 """ |
| 138 storage = self.determine_patch_storage() | 142 storage = self.determine_patch_storage() |
| 139 | |
| 140 if storage == PATCH_STORAGE_RIETVELD: | 143 if storage == PATCH_STORAGE_RIETVELD: |
| 141 return self.m.rietveld.apply_issue( | 144 return self.m.rietveld.apply_issue( |
| 142 self.m.rietveld.calculate_issue_root(), | 145 self.m.rietveld.calculate_issue_root(), |
| 143 authentication=authentication) | 146 authentication=authentication) |
| 147 elif storage == PATCH_STORAGE_GERRIT: | |
|
tandrii(chromium)
2016/08/19 14:00:04
Hm, can you move this condition instead to skia re
rmistry
2016/08/19 14:36:08
That makes sense. Will do.
| |
| 148 patch_project = (self.m.properties.get('patch_project') or | |
| 149 self.m.properties.get('project')) | |
| 150 return self.m.bot_update.apply_gerrit_ref( | |
| 151 gerrit_repo=self.m.properties.get('repository') or 'origin', | |
| 152 gerrit_ref=self.m.properties.get('event.patchSet.ref'), | |
| 153 root=str(self.m.path['slave_build'].join(patch_project))) | |
| 144 elif storage == PATCH_STORAGE_SVN: | 154 elif storage == PATCH_STORAGE_SVN: |
| 145 return self.apply_from_svn(cwd) | 155 return self.apply_from_svn(cwd) |
| 146 elif storage == PATCH_STORAGE_GIT: | 156 elif storage == PATCH_STORAGE_GIT: |
| 147 return self.apply_from_git(cwd) | 157 return self.apply_from_git(cwd) |
| 148 else: | 158 else: |
| 149 # Since this method is "maybe", we don't raise an Exception. | 159 # Since this method is "maybe", we don't raise an Exception. |
| 150 pass | 160 pass |
| 151 | 161 |
| 152 def get_files_affected_by_patch(self, patch_root=None, **kwargs): | 162 def get_files_affected_by_patch(self, patch_root=None, **kwargs): |
| 153 """Returns list of paths to files affected by the patch. | 163 """Returns list of paths to files affected by the patch. |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 result = self.m.python( | 314 result = self.m.python( |
| 305 'parse description', self.package_repo_resource('git_footers.py'), | 315 'parse description', self.package_repo_resource('git_footers.py'), |
| 306 args=['--json', self.m.json.output()], | 316 args=['--json', self.m.json.output()], |
| 307 stdin=self.m.raw_io.input(data=patch_text)) | 317 stdin=self.m.raw_io.input(data=patch_text)) |
| 308 return result.json.output | 318 return result.json.output |
| 309 | 319 |
| 310 def get_footer(self, tag, patch_text=None): | 320 def get_footer(self, tag, patch_text=None): |
| 311 """Gets a specific tag from a CL description""" | 321 """Gets a specific tag from a CL description""" |
| 312 return self.get_footers(patch_text).get(tag, []) | 322 return self.get_footers(patch_text).get(tag, []) |
| 313 | 323 |
| OLD | NEW |