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.
10 from common_includes import *
13 ROLL_SUMMARY = ("Summary of changes available at:\n"
14 "https://chromium.googlesource.com/v8/v8/+log/%s..%s")
17 class Preparation(Step):
18 MESSAGE = "Preparation."
21 # Update v8 remote tracking branches.
25 class DetectLastPush(Step):
26 MESSAGE = "Detect commit ID of last release."
29 # The revision that should be rolled.
30 self["last_push"] = self._options.last_push or self.GetLatestRelease()
31 self["push_title"] = self.GitLog(n=1, format="%s",
32 git_hash=self["last_push"])
34 # The master revision this release is based on.
35 self["push_base"] = self.GetLatestReleaseBase()
37 # FIXME(machenbach): Manually specifying a revision doesn't work at the
38 # moment. Needs more complicated logic to find the correct push_base above.
39 # Maybe delete that parameter entirely?
40 assert not self._options.last_push
42 # Determine the master revision of the last roll.
43 version = self.GetVersionTag(self._options.last_roll)
45 self["last_rolled_base"] = self.GetLatestReleaseBase(version=version)
46 assert self["last_rolled_base"]
49 class SwitchChromium(Step):
50 MESSAGE = "Switch to Chromium checkout."
53 self["v8_path"] = os.getcwd()
54 cwd = self._options.chromium
56 self.InitialEnvironmentChecks(cwd)
57 # Check for a clean workdir.
58 if not self.GitIsWorkdirClean(cwd=cwd): # pragma: no cover
59 self.Die("Workspace is not clean. Please commit or undo your changes.")
60 # Assert that the DEPS file is there.
61 if not os.path.exists(os.path.join(cwd, "DEPS")): # pragma: no cover
62 self.Die("DEPS file not present.")
65 class UpdateChromiumCheckout(Step):
66 MESSAGE = "Update the checkout and create a new branch."
69 self.GitCheckout("master", cwd=self._options.chromium)
70 self.Command("gclient", "sync --nohooks", cwd=self._options.chromium)
71 self.GitPull(cwd=self._options.chromium)
76 self.GitCreateBranch("v8-roll-%s" % self["last_push"],
77 cwd=self._options.chromium)
81 MESSAGE = "Create and upload CL."
86 "roll-dep", "v8 %s" % self["last_push"],
87 cwd=self._options.chromium) is None:
88 self.Die("Failed to create deps for %s" % self["last_push"])
91 message.append("Update V8 to %s." % self["push_title"].lower())
94 ROLL_SUMMARY % (self["last_rolled_base"][:8], self["push_base"][:8]))
97 message.append("Please reply to the V8 sheriff %s in case of problems."
99 message.append("TBR=%s" % self._options.reviewer)
100 self.GitCommit("\n\n".join(message),
101 author=self._options.author,
102 cwd=self._options.chromium)
103 if not self._options.dry_run:
104 self.GitUpload(author=self._options.author,
106 cq=self._options.use_commit_queue,
107 cwd=self._options.chromium)
110 self.GitCheckout("master", cwd=self._options.chromium)
111 self.GitDeleteBranch("v8-roll-%s" % self["last_push"],
112 cwd=self._options.chromium)
113 print "Dry run - don't upload."
116 # TODO(machenbach): Make this obsolete. We are only in the chromium chechout
117 # for the initial .git check.
118 class SwitchV8(Step):
119 MESSAGE = "Returning to V8 checkout."
122 os.chdir(self["v8_path"])
129 print("Congratulations, you have successfully rolled %s into "
130 "Chromium. Please don't forget to update the v8rel spreadsheet."
133 # Clean up all temporary files.
134 Command("rm", "-f %s*" % self._config["PERSISTFILE_BASENAME"])
137 class ChromiumRoll(ScriptsBase):
138 def _PrepareOptions(self, parser):
139 parser.add_argument("-c", "--chromium", required=True,
140 help=("The path to your Chromium src/ "
141 "directory to automate the V8 roll."))
142 parser.add_argument("-l", "--last-push",
143 help="The git commit ID of the last candidates push.")
144 parser.add_argument("--last-roll", required=True,
145 help="The git commit ID of the last rolled version.")
146 parser.add_argument("--use-commit-queue",
147 help="Check the CQ bit on upload.",
148 default=False, action="store_true")
150 def _ProcessOptions(self, options): # pragma: no cover
151 if not options.author or not options.reviewer:
152 print "A reviewer (-r) and an author (-a) are required."
155 options.requires_editor = False
157 options.manual = False
162 "PERSISTFILE_BASENAME": "/tmp/v8-chromium-roll-tempfile",
171 UpdateChromiumCheckout,
178 if __name__ == "__main__": # pragma: no cover
179 sys.exit(ChromiumRoll().Run())