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 *
12 DEPS_FILE = "DEPS_FILE"
16 PERSISTFILE_BASENAME: "/tmp/v8-chromium-roll-tempfile",
17 DOT_GIT_LOCATION: ".git",
22 class Preparation(Step):
23 MESSAGE = "Preparation."
29 class DetectLastPush(Step):
30 MESSAGE = "Detect commit ID of last push to trunk."
33 self["last_push"] = self._options.last_push or self.FindLastTrunkPush(
35 self["trunk_revision"] = self.GitSVNFindSVNRev(self["last_push"])
36 self["push_title"] = self.GitLog(n=1, format="%s",
37 git_hash=self["last_push"])
40 class CheckChromium(Step):
41 MESSAGE = "Ask for chromium checkout."
44 self["chrome_path"] = self._options.chromium
45 while not self["chrome_path"]:
46 self.DieNoManualMode("Please specify the path to a Chromium checkout in "
48 print ("Please specify the path to the chromium \"src\" directory: "),
49 self["chrome_path"] = self.ReadLine()
52 class SwitchChromium(Step):
53 MESSAGE = "Switch to Chromium checkout."
54 REQUIRES = "chrome_path"
57 self["v8_path"] = os.getcwd()
58 os.chdir(self["chrome_path"])
59 self.InitialEnvironmentChecks()
60 # Check for a clean workdir.
61 if not self.GitIsWorkdirClean(): # pragma: no cover
62 self.Die("Workspace is not clean. Please commit or undo your changes.")
63 # Assert that the DEPS file is there.
64 if not os.path.exists(self.Config(DEPS_FILE)): # pragma: no cover
65 self.Die("DEPS file not present.")
68 class UpdateChromiumCheckout(Step):
69 MESSAGE = "Update the checkout and create a new branch."
70 REQUIRES = "chrome_path"
73 os.chdir(self["chrome_path"])
74 self.GitCheckout("master")
76 self.GitCreateBranch("v8-roll-%s" % self["trunk_revision"])
80 MESSAGE = "Create and upload CL."
81 REQUIRES = "chrome_path"
84 os.chdir(self["chrome_path"])
87 deps = FileToText(self.Config(DEPS_FILE))
88 deps = re.sub("(?<=\"v8_revision\": \")([0-9]+)(?=\")",
89 self["trunk_revision"],
91 TextToFile(deps, self.Config(DEPS_FILE))
93 if self._options.reviewer and not self._options.manual:
94 print "Using account %s for review." % self._options.reviewer
95 rev = self._options.reviewer
97 print "Please enter the email address of a reviewer for the roll CL: ",
98 self.DieNoManualMode("A reviewer must be specified in forced mode.")
101 commit_title = "Update V8 to %s." % self["push_title"].lower()
104 sheriff = ("\n\nPlease reply to the V8 sheriff %s in case of problems."
106 self.GitCommit("%s%s\n\nTBR=%s" % (commit_title, sheriff, rev))
107 self.GitUpload(author=self._options.author,
108 force=self._options.force_upload,
109 cq=self._options.use_commit_queue)
113 class SwitchV8(Step):
114 MESSAGE = "Returning to V8 checkout."
115 REQUIRES = "chrome_path"
118 os.chdir(self["v8_path"])
125 print("Congratulations, you have successfully rolled the push r%s it into "
126 "Chromium. Please don't forget to update the v8rel spreadsheet."
127 % self["trunk_revision"])
129 # Clean up all temporary files.
130 Command("rm", "-f %s*" % self._config[PERSISTFILE_BASENAME])
133 class ChromiumRoll(ScriptsBase):
134 def _PrepareOptions(self, parser):
135 group = parser.add_mutually_exclusive_group()
136 group.add_argument("-f", "--force",
137 help="Don't prompt the user.",
138 default=False, action="store_true")
139 group.add_argument("-m", "--manual",
140 help="Prompt the user at every important step.",
141 default=False, action="store_true")
142 parser.add_argument("-c", "--chromium",
143 help=("The path to your Chromium src/ "
144 "directory to automate the V8 roll."))
145 parser.add_argument("-l", "--last-push",
146 help="The git commit ID of the last push to trunk.")
147 parser.add_argument("--use-commit-queue",
148 help="Check the CQ bit on upload.",
149 default=False, action="store_true")
151 def _ProcessOptions(self, options): # pragma: no cover
152 if not options.manual and not options.reviewer:
153 print "A reviewer (-r) is required in (semi-)automatic mode."
155 if not options.manual and not options.chromium:
156 print "A chromium checkout (-c) is required in (semi-)automatic mode."
158 if not options.manual and not options.author:
159 print "Specify your chromium.org email with -a in (semi-)automatic mode."
162 options.tbr_commit = not options.manual
172 UpdateChromiumCheckout,
179 if __name__ == "__main__": # pragma: no cover
180 sys.exit(ChromiumRoll(CONFIG).Run())