2014-03-21 12:15:25 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# Copyright 2014 the V8 project authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
from common_includes import *
|
|
|
|
|
|
|
|
DEPS_FILE = "DEPS_FILE"
|
|
|
|
CHROMIUM = "CHROMIUM"
|
|
|
|
|
|
|
|
CONFIG = {
|
|
|
|
PERSISTFILE_BASENAME: "/tmp/v8-chromium-roll-tempfile",
|
|
|
|
DOT_GIT_LOCATION: ".git",
|
|
|
|
DEPS_FILE: "DEPS",
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class Preparation(Step):
|
|
|
|
MESSAGE = "Preparation."
|
|
|
|
|
|
|
|
def RunStep(self):
|
|
|
|
self.CommonPrepare()
|
|
|
|
|
|
|
|
|
|
|
|
class DetectLastPush(Step):
|
|
|
|
MESSAGE = "Detect commit ID of last push to trunk."
|
|
|
|
|
|
|
|
def RunStep(self):
|
2014-04-04 07:23:45 +00:00
|
|
|
self["last_push"] = self._options.last_push or self.FindLastTrunkPush(
|
|
|
|
include_patches=True)
|
2014-03-21 12:15:25 +00:00
|
|
|
self["trunk_revision"] = self.GitSVNFindSVNRev(self["last_push"])
|
|
|
|
self["push_title"] = self.GitLog(n=1, format="%s",
|
|
|
|
git_hash=self["last_push"])
|
|
|
|
|
|
|
|
|
|
|
|
class SwitchChromium(Step):
|
|
|
|
MESSAGE = "Switch to Chromium checkout."
|
|
|
|
|
|
|
|
def RunStep(self):
|
|
|
|
self["v8_path"] = os.getcwd()
|
2014-09-03 06:50:18 +00:00
|
|
|
os.chdir(self._options.chromium)
|
2014-03-21 12:15:25 +00:00
|
|
|
self.InitialEnvironmentChecks()
|
|
|
|
# Check for a clean workdir.
|
|
|
|
if not self.GitIsWorkdirClean(): # pragma: no cover
|
|
|
|
self.Die("Workspace is not clean. Please commit or undo your changes.")
|
|
|
|
# Assert that the DEPS file is there.
|
|
|
|
if not os.path.exists(self.Config(DEPS_FILE)): # pragma: no cover
|
|
|
|
self.Die("DEPS file not present.")
|
|
|
|
|
|
|
|
|
|
|
|
class UpdateChromiumCheckout(Step):
|
|
|
|
MESSAGE = "Update the checkout and create a new branch."
|
|
|
|
|
|
|
|
def RunStep(self):
|
2014-09-03 06:50:18 +00:00
|
|
|
os.chdir(self._options.chromium)
|
2014-03-21 12:15:25 +00:00
|
|
|
self.GitCheckout("master")
|
2014-08-27 09:54:03 +00:00
|
|
|
self._side_effect_handler.Command("gclient", "sync --nohooks")
|
2014-09-02 12:56:07 +00:00
|
|
|
self.GitPull()
|
2014-08-27 13:13:40 +00:00
|
|
|
try:
|
|
|
|
# TODO(machenbach): Add cwd to git calls.
|
2014-09-03 06:50:18 +00:00
|
|
|
os.chdir(os.path.join(self._options.chromium, "v8"))
|
2014-08-27 13:13:40 +00:00
|
|
|
self.GitFetchOrigin()
|
|
|
|
finally:
|
2014-09-03 06:50:18 +00:00
|
|
|
os.chdir(self._options.chromium)
|
2014-03-21 12:15:25 +00:00
|
|
|
self.GitCreateBranch("v8-roll-%s" % self["trunk_revision"])
|
|
|
|
|
|
|
|
|
|
|
|
class UploadCL(Step):
|
|
|
|
MESSAGE = "Create and upload CL."
|
|
|
|
|
|
|
|
def RunStep(self):
|
2014-09-03 06:50:18 +00:00
|
|
|
os.chdir(self._options.chromium)
|
2014-03-21 12:15:25 +00:00
|
|
|
|
|
|
|
# Patch DEPS file.
|
2014-08-25 20:04:23 +00:00
|
|
|
if self._side_effect_handler.Command(
|
|
|
|
"roll-dep", "v8 %s" % self["trunk_revision"]) is None:
|
|
|
|
self.Die("Failed to create deps for %s" % self["trunk_revision"])
|
2014-03-21 12:15:25 +00:00
|
|
|
|
|
|
|
commit_title = "Update V8 to %s." % self["push_title"].lower()
|
2014-04-08 12:07:49 +00:00
|
|
|
sheriff = ""
|
|
|
|
if self["sheriff"]:
|
|
|
|
sheriff = ("\n\nPlease reply to the V8 sheriff %s in case of problems."
|
|
|
|
% self["sheriff"])
|
2014-09-03 06:50:18 +00:00
|
|
|
self.GitCommit("%s%s\n\nTBR=%s" %
|
|
|
|
(commit_title, sheriff, self._options.reviewer))
|
2014-03-21 12:15:25 +00:00
|
|
|
self.GitUpload(author=self._options.author,
|
2014-09-03 06:50:18 +00:00
|
|
|
force=True,
|
2014-06-25 08:17:45 +00:00
|
|
|
cq=self._options.use_commit_queue)
|
2014-03-21 12:15:25 +00:00
|
|
|
print "CL uploaded."
|
|
|
|
|
|
|
|
|
|
|
|
class SwitchV8(Step):
|
|
|
|
MESSAGE = "Returning to V8 checkout."
|
|
|
|
|
|
|
|
def RunStep(self):
|
|
|
|
os.chdir(self["v8_path"])
|
|
|
|
|
|
|
|
|
|
|
|
class CleanUp(Step):
|
|
|
|
MESSAGE = "Done!"
|
|
|
|
|
|
|
|
def RunStep(self):
|
|
|
|
print("Congratulations, you have successfully rolled the push r%s it into "
|
|
|
|
"Chromium. Please don't forget to update the v8rel spreadsheet."
|
|
|
|
% self["trunk_revision"])
|
|
|
|
|
|
|
|
# Clean up all temporary files.
|
|
|
|
Command("rm", "-f %s*" % self._config[PERSISTFILE_BASENAME])
|
|
|
|
|
|
|
|
|
|
|
|
class ChromiumRoll(ScriptsBase):
|
|
|
|
def _PrepareOptions(self, parser):
|
2014-09-03 06:50:18 +00:00
|
|
|
parser.add_argument("-c", "--chromium", required=True,
|
2014-03-21 12:15:25 +00:00
|
|
|
help=("The path to your Chromium src/ "
|
|
|
|
"directory to automate the V8 roll."))
|
|
|
|
parser.add_argument("-l", "--last-push",
|
|
|
|
help="The git commit ID of the last push to trunk.")
|
2014-06-25 08:17:45 +00:00
|
|
|
parser.add_argument("--use-commit-queue",
|
|
|
|
help="Check the CQ bit on upload.",
|
|
|
|
default=False, action="store_true")
|
2014-03-21 12:15:25 +00:00
|
|
|
|
|
|
|
def _ProcessOptions(self, options): # pragma: no cover
|
2014-09-03 06:50:18 +00:00
|
|
|
if not options.author or not options.reviewer:
|
|
|
|
print "A reviewer (-r) and an author (-a) are required."
|
2014-03-21 12:15:25 +00:00
|
|
|
return False
|
|
|
|
|
2014-09-03 06:50:18 +00:00
|
|
|
options.requires_editor = False
|
|
|
|
options.force = True
|
|
|
|
options.manual = False
|
2014-03-21 12:15:25 +00:00
|
|
|
return True
|
|
|
|
|
|
|
|
def _Steps(self):
|
|
|
|
return [
|
|
|
|
Preparation,
|
|
|
|
DetectLastPush,
|
2014-04-08 12:07:49 +00:00
|
|
|
DetermineV8Sheriff,
|
2014-03-21 12:15:25 +00:00
|
|
|
SwitchChromium,
|
|
|
|
UpdateChromiumCheckout,
|
|
|
|
UploadCL,
|
|
|
|
SwitchV8,
|
|
|
|
CleanUp,
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": # pragma: no cover
|
|
|
|
sys.exit(ChromiumRoll(CONFIG).Run())
|