| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 the V8 project authors. All rights reserved. | 2 # Copyright 2013 the V8 project authors. All rights reserved. |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following | 10 # copyright notice, this list of conditions and the following |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | 28 |
| 29 import argparse | 29 import argparse |
| 30 import datetime | 30 import datetime |
| 31 import imp |
| 31 import json | 32 import json |
| 32 import os | 33 import os |
| 33 import re | 34 import re |
| 34 import subprocess | 35 import subprocess |
| 35 import sys | 36 import sys |
| 36 import textwrap | 37 import textwrap |
| 37 import time | 38 import time |
| 38 import urllib2 | 39 import urllib2 |
| 39 | 40 |
| 40 from git_recipes import GitRecipesMixin | 41 from git_recipes import GitRecipesMixin |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 if self._options.reviewer: | 461 if self._options.reviewer: |
| 461 print "Using account %s for review." % self._options.reviewer | 462 print "Using account %s for review." % self._options.reviewer |
| 462 reviewer = self._options.reviewer | 463 reviewer = self._options.reviewer |
| 463 else: | 464 else: |
| 464 print "Please enter the email address of a V8 reviewer for your patch: ", | 465 print "Please enter the email address of a V8 reviewer for your patch: ", |
| 465 self.DieNoManualMode("A reviewer must be specified in forced mode.") | 466 self.DieNoManualMode("A reviewer must be specified in forced mode.") |
| 466 reviewer = self.ReadLine() | 467 reviewer = self.ReadLine() |
| 467 self.GitUpload(reviewer, self._options.author, self._options.force_upload) | 468 self.GitUpload(reviewer, self._options.author, self._options.force_upload) |
| 468 | 469 |
| 469 | 470 |
| 471 class DetermineV8Sheriff(Step): |
| 472 MESSAGE = "Determine the V8 sheriff for code review." |
| 473 |
| 474 def RunStep(self): |
| 475 self["sheriff"] = None |
| 476 if not self._options.sheriff: # pragma: no cover |
| 477 return |
| 478 |
| 479 try: |
| 480 # The googlers mapping maps @google.com accounts to @chromium.org |
| 481 # accounts. |
| 482 googlers = imp.load_source('googlers_mapping', |
| 483 self._options.googlers_mapping) |
| 484 googlers = googlers.list_to_dict(googlers.get_list()) |
| 485 except: # pragma: no cover |
| 486 print "Skip determining sheriff without googler mapping." |
| 487 return |
| 488 |
| 489 # The sheriff determined by the rotation on the waterfall has a |
| 490 # @google.com account. |
| 491 url = "https://chromium-build.appspot.com/p/chromium/sheriff_v8.js" |
| 492 match = re.match(r"document\.write\('(\w+)'\)", self.ReadURL(url)) |
| 493 |
| 494 # If "channel is sheriff", we can't match an account. |
| 495 if match: |
| 496 g_name = match.group(1) |
| 497 self["sheriff"] = googlers.get(g_name + "@google.com", |
| 498 g_name + "@chromium.org") |
| 499 self._options.reviewer = self["sheriff"] |
| 500 print "Found active sheriff: %s" % self["sheriff"] |
| 501 else: |
| 502 print "No active sheriff found." |
| 503 |
| 504 |
| 470 def MakeStep(step_class=Step, number=0, state=None, config=None, | 505 def MakeStep(step_class=Step, number=0, state=None, config=None, |
| 471 options=None, side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER): | 506 options=None, side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER): |
| 472 # Allow to pass in empty dictionaries. | 507 # Allow to pass in empty dictionaries. |
| 473 state = state if state is not None else {} | 508 state = state if state is not None else {} |
| 474 config = config if config is not None else {} | 509 config = config if config is not None else {} |
| 475 | 510 |
| 476 try: | 511 try: |
| 477 message = step_class.MESSAGE | 512 message = step_class.MESSAGE |
| 478 except AttributeError: | 513 except AttributeError: |
| 479 message = step_class.__name__ | 514 message = step_class.__name__ |
| (...skipping 24 matching lines...) Expand all Loading... |
| 504 def _ProcessOptions(self, options): | 539 def _ProcessOptions(self, options): |
| 505 return True | 540 return True |
| 506 | 541 |
| 507 def _Steps(self): # pragma: no cover | 542 def _Steps(self): # pragma: no cover |
| 508 raise Exception("Not implemented.") | 543 raise Exception("Not implemented.") |
| 509 | 544 |
| 510 def MakeOptions(self, args=None): | 545 def MakeOptions(self, args=None): |
| 511 parser = argparse.ArgumentParser(description=self._Description()) | 546 parser = argparse.ArgumentParser(description=self._Description()) |
| 512 parser.add_argument("-a", "--author", default="", | 547 parser.add_argument("-a", "--author", default="", |
| 513 help="The author email used for rietveld.") | 548 help="The author email used for rietveld.") |
| 549 parser.add_argument("-g", "--googlers-mapping", |
| 550 help="Path to the script mapping google accounts.") |
| 514 parser.add_argument("-r", "--reviewer", default="", | 551 parser.add_argument("-r", "--reviewer", default="", |
| 515 help="The account name to be used for reviews.") | 552 help="The account name to be used for reviews.") |
| 553 parser.add_argument("--sheriff", default=False, action="store_true", |
| 554 help=("Determine current sheriff to review CLs. On " |
| 555 "success, this will overwrite the reviewer " |
| 556 "option.")) |
| 516 parser.add_argument("-s", "--step", | 557 parser.add_argument("-s", "--step", |
| 517 help="Specify the step where to start work. Default: 0.", | 558 help="Specify the step where to start work. Default: 0.", |
| 518 default=0, type=int) | 559 default=0, type=int) |
| 519 | 560 |
| 520 self._PrepareOptions(parser) | 561 self._PrepareOptions(parser) |
| 521 | 562 |
| 522 if args is None: # pragma: no cover | 563 if args is None: # pragma: no cover |
| 523 options = parser.parse_args() | 564 options = parser.parse_args() |
| 524 else: | 565 else: |
| 525 options = parser.parse_args(args) | 566 options = parser.parse_args(args) |
| 526 | 567 |
| 527 # Process common options. | 568 # Process common options. |
| 528 if options.step < 0: # pragma: no cover | 569 if options.step < 0: # pragma: no cover |
| 529 print "Bad step number %d" % options.step | 570 print "Bad step number %d" % options.step |
| 530 parser.print_help() | 571 parser.print_help() |
| 531 return None | 572 return None |
| 573 if options.sheriff and not options.googlers_mapping: # pragma: no cover |
| 574 print "To determine the current sheriff, requires the googler mapping" |
| 575 parser.print_help() |
| 576 return None |
| 532 | 577 |
| 533 # Defaults for options, common to all scripts. | 578 # Defaults for options, common to all scripts. |
| 534 options.manual = getattr(options, "manual", True) | 579 options.manual = getattr(options, "manual", True) |
| 535 options.force = getattr(options, "force", False) | 580 options.force = getattr(options, "force", False) |
| 536 | 581 |
| 537 # Derived options. | 582 # Derived options. |
| 538 options.requires_editor = not options.force | 583 options.requires_editor = not options.force |
| 539 options.wait_for_lgtm = not options.force | 584 options.wait_for_lgtm = not options.force |
| 540 options.force_readline_defaults = not options.manual | 585 options.force_readline_defaults = not options.manual |
| 541 options.force_upload = not options.manual | 586 options.force_upload = not options.manual |
| (...skipping 17 matching lines...) Expand all Loading... |
| 559 for (number, step_class) in enumerate(step_classes): | 604 for (number, step_class) in enumerate(step_classes): |
| 560 steps.append(MakeStep(step_class, number, self._state, self._config, | 605 steps.append(MakeStep(step_class, number, self._state, self._config, |
| 561 options, self._side_effect_handler)) | 606 options, self._side_effect_handler)) |
| 562 for step in steps[options.step:]: | 607 for step in steps[options.step:]: |
| 563 if step.Run(): | 608 if step.Run(): |
| 564 return 1 | 609 return 1 |
| 565 return 0 | 610 return 0 |
| 566 | 611 |
| 567 def Run(self, args=None): | 612 def Run(self, args=None): |
| 568 return self.RunSteps(self._Steps(), args) | 613 return self.RunSteps(self._Steps(), args) |
| OLD | NEW |