Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 | 6 |
| 7 """Automates creation and management of DEPS roll CLs. | 7 """Automates creation and management of DEPS roll CLs. |
| 8 | 8 |
| 9 This script is designed to be run in a loop (eg. with auto_roll_wrapper.sh) or | 9 This script is designed to be run in a loop (eg. with auto_roll_wrapper.sh) or |
| 10 on a timer. It may take one of several actions, depending on the state of | 10 on a timer. It may take one of several actions, depending on the state of |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 ROLL_DESCRIPTION_STR = '%(project)s roll %(from_revision)s:%(to_revision)s' | 140 ROLL_DESCRIPTION_STR = '%(project)s roll %(from_revision)s:%(to_revision)s' |
| 141 ROLL_DESCRIPTION_REGEXP = ROLL_DESCRIPTION_STR % { | 141 ROLL_DESCRIPTION_REGEXP = ROLL_DESCRIPTION_STR % { |
| 142 'project': '%(project)s', | 142 'project': '%(project)s', |
| 143 'from_revision': r'(?P<from_revision>[0-9a-fA-F]{2,40})', | 143 'from_revision': r'(?P<from_revision>[0-9a-fA-F]{2,40})', |
| 144 'to_revision': r'(?P<to_revision>[0-9a-fA-F]{2,40})' | 144 'to_revision': r'(?P<to_revision>[0-9a-fA-F]{2,40})' |
| 145 } | 145 } |
| 146 | 146 |
| 147 # FIXME: These are taken from gardeningserver.py and should be shared. | 147 # FIXME: These are taken from gardeningserver.py and should be shared. |
| 148 CHROMIUM_SVN_DEPS_URL = 'http://src.chromium.org/chrome/trunk/src/DEPS' | 148 CHROMIUM_SVN_DEPS_URL = 'http://src.chromium.org/chrome/trunk/src/DEPS' |
| 149 # 'webkit_revision': '149598', | 149 # 'webkit_revision': '149598', |
| 150 REVISION_REGEXP = r'^ "%s_revision": "(?P<revision>[0-9a-fA-F]{2,40})",$' | 150 REVISION_REGEXP = ( |
| 151 r'^ [\'"]%s_revision[\'"]: [\'"](?P<revision>[0-9a-fA-F]{2,40})[\'"],$') | |
| 151 | 152 |
| 152 ROLL_BOT_INSTRUCTIONS = textwrap.dedent( | 153 ROLL_BOT_INSTRUCTIONS = textwrap.dedent( |
| 153 '''This roll was created by the Blink AutoRollBot. | 154 '''This roll was created by the Blink AutoRollBot. |
| 154 http://www.chromium.org/blink/blinkrollbot''') | 155 http://www.chromium.org/blink/blinkrollbot''') |
| 155 | 156 |
| 156 PLEASE_RESUME_NAG = textwrap.dedent(''' | 157 PLEASE_RESUME_NAG = textwrap.dedent(''' |
| 157 Rollbot was stopped by the presence of 'STOP' in an earlier comment. | 158 Rollbot was stopped by the presence of 'STOP' in an earlier comment. |
| 158 The last update to this issue was over %(stop_nag_timeout)s hours ago. | 159 The last update to this issue was over %(stop_nag_timeout)s hours ago. |
| 159 Please close this issue as soon as possible to allow the bot to continue. | 160 Please close this issue as soon as possible to allow the bot to continue. |
| 160 | 161 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 git_log, re.MULTILINE) | 263 git_log, re.MULTILINE) |
| 263 if match: | 264 if match: |
| 264 return match.group('svn_revision') | 265 return match.group('svn_revision') |
| 265 else: | 266 else: |
| 266 raise AutoRollException('Could not determine the current SVN revision.') | 267 raise AutoRollException('Could not determine the current SVN revision.') |
| 267 | 268 |
| 268 def _emails_to_cc_on_rolls(self): | 269 def _emails_to_cc_on_rolls(self): |
| 269 return _filter_emails(self._get_extra_emails()) | 270 return _filter_emails(self._get_extra_emails()) |
| 270 | 271 |
| 271 def _start_roll(self, new_roll_revision, commit_msg): | 272 def _start_roll(self, new_roll_revision, commit_msg): |
| 272 safely_roll_path = ( | 273 roll_branch = '%s_roll' % self._project |
| 273 self._path_from_chromium_root('tools', 'safely-roll-deps.py')) | 274 subprocess2.check_call(['git', 'clean', '-d', '-f']) |
| 274 safely_roll_args = [safely_roll_path, self._project_alias, | 275 subprocess2.call(['git', 'rebase', '--abort']) |
| 275 new_roll_revision, '--message', commit_msg, '--force'] | 276 subprocess2.call(['git', 'branch', '-D', roll_branch]) |
| 277 subprocess2.check_call(['git', 'checkout', 'master', '-f']) | |
| 278 subprocess2.check_call(['git', 'checkout', '-b', roll_branch, | |
| 279 '-t', 'origin/master', '-f']) | |
| 280 try: | |
| 281 subprocess2.check_call(['roll-dep', self._path_to_project, | |
|
eseidel
2014/08/25 18:09:01
This assumes depot_tools is in the path. Unsure if
borenet
2014/08/25 18:20:21
I think it's okay since we import find_depot_tools
szager1
2014/08/25 18:28:00
It's in depot_tools, which is always in PATH. But
borenet
2014/08/25 18:40:23
I think I'd rather leave it as-is, since the auto_
| |
| 282 new_roll_revision]) | |
| 283 subprocess2.check_call(['git', 'add', 'DEPS']) | |
| 276 | 284 |
| 277 emails = self._emails_to_cc_on_rolls() | 285 upload_cmd = ['git', 'cl', 'upload', '--bypass-hooks', |
| 278 if emails: | 286 '--use-commit-queue'] |
| 279 safely_roll_args.extend(['--reviewers', ','.join(emails)]) | 287 tbr = '\nTBR=' |
| 280 subprocess2.check_call(map(str, safely_roll_args)) | 288 emails = self._emails_to_cc_on_rolls() |
| 289 if emails: | |
| 290 emails_str = ','.join(emails) | |
| 291 tbr += emails_str | |
| 292 upload_cmd.extend(['--cc', emails_str, '--send-mail']) | |
| 293 commit_msg += tbr | |
| 294 subprocess2.check_call(['git', 'commit', '-m', commit_msg]) | |
| 295 subprocess2.check_call(upload_cmd) | |
| 296 finally: | |
| 297 subprocess2.check_call(['git', 'checkout', 'master', '-f']) | |
| 298 subprocess2.check_call(['git', 'branch', '-D', roll_branch]) | |
| 281 | 299 |
| 282 # FIXME: It's easier to pull the issue id from rietveld rather than | 300 # FIXME: It's easier to pull the issue id from rietveld rather than |
| 283 # parse it from the safely-roll-deps output. Once we inline | 301 # parse it from the safely-roll-deps output. Once we inline |
| 284 # safely-roll-deps into this script this can go away. | 302 # safely-roll-deps into this script this can go away. |
| 285 search_result = self._search_for_active_roll() | 303 search_result = self._search_for_active_roll() |
| 286 if search_result: | 304 if search_result: |
| 287 self._rietveld.add_comment(search_result['issue'], | 305 self._rietveld.add_comment(search_result['issue'], |
| 288 self.ROLL_BOT_INSTRUCTIONS) | 306 self.ROLL_BOT_INSTRUCTIONS) |
| 289 | 307 |
| 290 def _maybe_close_active_roll(self, issue): | 308 def _maybe_close_active_roll(self, issue): |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 412 _, args = parser.parse_args() | 430 _, args = parser.parse_args() |
| 413 if len(args) != 3: | 431 if len(args) != 3: |
| 414 parser.print_usage() | 432 parser.print_usage() |
| 415 return 1 | 433 return 1 |
| 416 | 434 |
| 417 AutoRoller(*args).main() | 435 AutoRoller(*args).main() |
| 418 | 436 |
| 419 | 437 |
| 420 if __name__ == '__main__': | 438 if __name__ == '__main__': |
| 421 sys.exit(main()) | 439 sys.exit(main()) |
| OLD | NEW |