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 class Preparation(Step):
14 MESSAGE = "Preparation."
17 # Update v8 remote tracking branches.
21 class DetectLastPush(Step):
22 MESSAGE = "Detect commit ID of last push to trunk."
25 self["last_push"] = self._options.last_push or self.FindLastTrunkPush(
26 branch="origin/master", include_patches=True)
27 self["trunk_revision"] = self.GetCommitPositionNumber(self["last_push"])
28 self["push_title"] = self.GitLog(n=1, format="%s",
29 git_hash=self["last_push"])
32 class SwitchChromium(Step):
33 MESSAGE = "Switch to Chromium checkout."
36 self["v8_path"] = os.getcwd()
37 cwd = self._options.chromium
39 self.InitialEnvironmentChecks(cwd)
40 # Check for a clean workdir.
41 if not self.GitIsWorkdirClean(cwd=cwd): # pragma: no cover
42 self.Die("Workspace is not clean. Please commit or undo your changes.")
43 # Assert that the DEPS file is there.
44 if not os.path.exists(os.path.join(cwd, "DEPS")): # pragma: no cover
45 self.Die("DEPS file not present.")
48 class UpdateChromiumCheckout(Step):
49 MESSAGE = "Update the checkout and create a new branch."
52 self.GitCheckout("master", cwd=self._options.chromium)
53 self.Command("gclient", "sync --nohooks", cwd=self._options.chromium)
54 self.GitPull(cwd=self._options.chromium)
59 self.GitCreateBranch("v8-roll-%s" % self["trunk_revision"],
60 cwd=self._options.chromium)
64 MESSAGE = "Create and upload CL."
69 "roll-dep", "v8 %s" % self["trunk_revision"],
70 cwd=self._options.chromium) is None:
71 self.Die("Failed to create deps for %s" % self["trunk_revision"])
73 commit_title = "Update V8 to %s." % self["push_title"].lower()
76 sheriff = ("\n\nPlease reply to the V8 sheriff %s in case of problems."
78 self.GitCommit("%s%s\n\nTBR=%s" %
79 (commit_title, sheriff, self._options.reviewer),
80 author=self._options.author,
81 cwd=self._options.chromium)
82 if not self._options.dry_run:
83 self.GitUpload(author=self._options.author,
85 cq=self._options.use_commit_queue,
86 cwd=self._options.chromium)
89 self.GitCheckout("master", cwd=self._options.chromium)
90 self.GitDeleteBranch("v8-roll-%s" % self["trunk_revision"],
91 cwd=self._options.chromium)
92 print "Dry run - don't upload."
95 # TODO(machenbach): Make this obsolete. We are only in the chromium chechout
96 # for the initial .git check.
98 MESSAGE = "Returning to V8 checkout."
101 os.chdir(self["v8_path"])
108 print("Congratulations, you have successfully rolled the push r%s it into "
109 "Chromium. Please don't forget to update the v8rel spreadsheet."
110 % self["trunk_revision"])
112 # Clean up all temporary files.
113 Command("rm", "-f %s*" % self._config["PERSISTFILE_BASENAME"])
116 class ChromiumRoll(ScriptsBase):
117 def _PrepareOptions(self, parser):
118 parser.add_argument("-c", "--chromium", required=True,
119 help=("The path to your Chromium src/ "
120 "directory to automate the V8 roll."))
121 parser.add_argument("-l", "--last-push",
122 help="The git commit ID of the last push to trunk.")
123 parser.add_argument("--use-commit-queue",
124 help="Check the CQ bit on upload.",
125 default=False, action="store_true")
127 def _ProcessOptions(self, options): # pragma: no cover
128 if not options.author or not options.reviewer:
129 print "A reviewer (-r) and an author (-a) are required."
132 options.requires_editor = False
134 options.manual = False
139 "PERSISTFILE_BASENAME": "/tmp/v8-chromium-roll-tempfile",
148 UpdateChromiumCheckout,
155 if __name__ == "__main__": # pragma: no cover
156 sys.exit(ChromiumRoll().Run())