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.
12 from common_includes import *
16 PERSISTFILE_BASENAME: "/tmp/v8-auto-roll-tempfile",
19 CR_DEPS_URL = 'http://src.chromium.org/svn/trunk/src/DEPS'
21 class CheckActiveRoll(Step):
22 MESSAGE = "Check active roll."
25 def ContainsChromiumRoll(changes):
26 for change in changes:
27 if change["subject"].startswith("Update V8 to"):
34 "owner": self._options.author,
38 params = urllib.urlencode(params)
39 search_url = "https://codereview.chromium.org/search"
40 result = self.ReadURL(search_url, params, wait_plan=[5, 20])
41 if self.ContainsChromiumRoll(json.loads(result)["results"]):
42 print "Stop due to existing Chromium roll."
46 class DetectLastPush(Step):
47 MESSAGE = "Detect commit ID of the last push to trunk."
50 push_hash = self.FindLastTrunkPush(include_patches=True)
51 self["last_push"] = self.GitSVNFindSVNRev(push_hash)
54 class DetectLastRoll(Step):
55 MESSAGE = "Detect commit ID of the last Chromium roll."
58 # Interpret the DEPS file to retrieve the v8 revision.
59 Var = lambda var: '%s'
60 exec(self.ReadURL(CR_DEPS_URL))
61 last_roll = vars['v8_revision']
62 if last_roll >= self["last_push"]:
63 print("There is no newer v8 revision than the one in Chromium (%s)."
68 class RollChromium(Step):
69 MESSAGE = "Roll V8 into Chromium."
72 if self._options.roll:
74 "--author", self._options.author,
75 "--reviewer", self._options.reviewer,
76 "--chromium", self._options.chromium,
79 if self._options.sheriff:
81 "--sheriff", "--googlers-mapping", self._options.googlers_mapping])
82 R = chromium_roll.ChromiumRoll
83 self._side_effect_handler.Call(
84 R(chromium_roll.CONFIG, self._side_effect_handler).Run,
88 class AutoRoll(ScriptsBase):
89 def _PrepareOptions(self, parser):
90 parser.add_argument("-c", "--chromium", required=True,
91 help=("The path to your Chromium src/ "
92 "directory to automate the V8 roll."))
93 parser.add_argument("--roll",
94 help="Make Chromium roll. Dry run if unspecified.",
95 default=False, action="store_true")
97 def _ProcessOptions(self, options): # pragma: no cover
98 if not options.reviewer:
99 print "A reviewer (-r) is required."
101 if not options.author:
102 print "An author (-a) is required."
115 if __name__ == "__main__": # pragma: no cover
116 sys.exit(AutoRoll(CONFIG).Run())