Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 # Copyright 2014 the V8 project authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 import argparse | |
| 7 import json | |
| 8 import os | |
| 9 import sys | |
| 10 import urllib | |
| 11 | |
| 12 from common_includes import * | |
| 13 import chromium_roll | |
| 14 | |
| 15 CR_DEPS_URL = 'http://src.chromium.org/svn/trunk/src/DEPS' | |
| 16 | |
| 17 class CheckActiveRoll(Step): | |
| 18 MESSAGE = "Check active roll." | |
| 19 | |
| 20 @staticmethod | |
| 21 def ContainsChromiumRoll(changes): | |
| 22 for change in changes: | |
| 23 if change["subject"].startswith("Update V8 to"): | |
| 24 return True | |
| 25 return False | |
| 26 | |
| 27 def RunStep(self): | |
| 28 params = { | |
| 29 "closed": 3, | |
| 30 "owner": self._options.author, | |
| 31 "limit": 30, | |
| 32 "format": "json", | |
| 33 } | |
| 34 params = urllib.urlencode(params) | |
| 35 search_url = "https://codereview.chromium.org/search" | |
| 36 result = self.ReadURL(search_url, params, wait_plan=[5, 20]) | |
| 37 if self.ContainsChromiumRoll(json.loads(result)["results"]): | |
| 38 print "Stop due to existing Chromium roll." | |
| 39 return True | |
| 40 | |
| 41 | |
| 42 class DetectLastPush(Step): | |
| 43 MESSAGE = "Detect commit ID of the last push to trunk." | |
| 44 | |
| 45 def RunStep(self): | |
| 46 push_hash = self.FindLastTrunkPush() | |
| 47 self["last_push"] = self.GitSVNFindSVNRev(push_hash) | |
| 48 | |
| 49 | |
| 50 class DetectLastRoll(Step): | |
| 51 MESSAGE = "Detect commit ID of the last Chromium roll." | |
| 52 | |
| 53 def RunStep(self): | |
| 54 # Interpret the DEPS file to retrieve the v8 revision. | |
| 55 Var = lambda var: '%s' | |
| 56 exec(self.ReadURL(CR_DEPS_URL)) | |
| 57 last_roll = vars['v8_revision'] | |
| 58 if last_roll >= self["last_push"]: | |
| 59 print("There is no newer v8 revision than the one in Chromium (%s)." | |
| 60 % last_roll) | |
| 61 return True | |
| 62 | |
| 63 | |
| 64 class RollChromium(Step): | |
| 65 MESSAGE = "Roll V8 into Chromium." | |
| 66 | |
| 67 def RunStep(self): | |
| 68 if self._options.roll: | |
| 69 R = chromium_roll.ChromiumRoll | |
| 70 self._side_effect_handler.Call( | |
| 71 R(chromium_roll.CONFIG, self._side_effect_handler).Run, | |
| 72 ["--author", self._options.author, | |
| 73 "--reviewer", self._options.reviewer, | |
| 74 "--chromium", self._options.chromium, | |
| 75 "--force"]) | |
| 76 | |
| 77 | |
| 78 class AutoRoll(ScriptsBase): | |
| 79 def _PrepareOptions(self, parser): | |
| 80 group = parser.add_mutually_exclusive_group() | |
| 81 parser.add_argument("-c", "--chromium", required=True, | |
| 82 help=("The path to your Chromium src/ " | |
| 83 "directory to automate the V8 roll.")) | |
| 84 parser.add_argument("--roll", | |
| 85 help="Make Chromium roll. Dry run if unspecified.", | |
| 86 default=False, action="store_true") | |
| 87 | |
| 88 def _ProcessOptions(self, options): # pragma: no cover | |
| 89 if not options.reviewer: | |
| 90 print "A reviewer (-r) is required." | |
| 91 return False | |
| 92 if not options.author: | |
| 93 print "A author (-a) is required." | |
|
Jarin
2014/04/02 06:30:40
Nit: "A" -> "An"
| |
| 94 return False | |
| 95 return True | |
| 96 | |
| 97 def _Steps(self): | |
| 98 return [ | |
| 99 CheckActiveRoll, | |
| 100 DetectLastPush, | |
| 101 DetectLastRoll, | |
| 102 RollChromium, | |
| 103 ] | |
| 104 | |
| 105 | |
| 106 if __name__ == "__main__": # pragma: no cover | |
| 107 sys.exit(AutoRoll(CONFIG).Run()) | |
| OLD | NEW |