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 *
|
|
|
|
|
|
|
|
|
|
|
|
class Preparation(Step):
|
|
|
|
MESSAGE = "Preparation."
|
|
|
|
|
|
|
|
def RunStep(self):
|
2014-09-04 08:42:21 +00:00
|
|
|
# Update v8 remote tracking branches.
|
|
|
|
self.GitFetchOrigin()
|
2014-03-21 12:15:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
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(
|
2014-09-04 08:42:21 +00:00
|
|
|
branch="origin/master", include_patches=True)
|
|
|
|
self["trunk_revision"] = self.GetCommitPositionNumber(self["last_push"])
|
2014-03-21 12:15:25 +00:00
|
|
|
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-05 09:19:48 +00:00
|
|
|
cwd = self._options.chromium
|
|
|
|
os.chdir(cwd)
|
2014-09-19 13:37:34 +00:00
|
|
|
self.InitialEnvironmentChecks(cwd)
|
2014-03-21 12:15:25 +00:00
|
|
|
# Check for a clean workdir.
|
2014-09-05 09:19:48 +00:00
|
|
|
if not self.GitIsWorkdirClean(cwd=cwd): # pragma: no cover
|
2014-03-21 12:15:25 +00:00
|
|
|
self.Die("Workspace is not clean. Please commit or undo your changes.")
|
|
|
|
# Assert that the DEPS file is there.
|
2014-09-05 09:19:48 +00:00
|
|
|
if not os.path.exists(os.path.join(cwd, "DEPS")): # pragma: no cover
|
2014-03-21 12:15:25 +00:00
|
|
|
self.Die("DEPS file not present.")
|
|
|
|
|
|
|
|
|
|
|
|
class UpdateChromiumCheckout(Step):
|
|
|
|
MESSAGE = "Update the checkout and create a new branch."
|
|
|
|
|
|
|
|
def RunStep(self):
|
2014-09-05 09:19:48 +00:00
|
|
|
self.GitCheckout("master", cwd=self._options.chromium)
|
|
|
|
self.Command("gclient", "sync --nohooks", cwd=self._options.chromium)
|
|
|
|
self.GitPull(cwd=self._options.chromium)
|
|
|
|
|
|
|
|
# Update v8 remotes.
|
|
|
|
self.GitFetchOrigin()
|
|
|
|
|
|
|
|
self.GitCreateBranch("v8-roll-%s" % self["trunk_revision"],
|
|
|
|
cwd=self._options.chromium)
|
2014-03-21 12:15:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
class UploadCL(Step):
|
|
|
|
MESSAGE = "Create and upload CL."
|
|
|
|
|
|
|
|
def RunStep(self):
|
|
|
|
# Patch DEPS file.
|
2014-09-05 09:19:48 +00:00
|
|
|
if self.Command(
|
|
|
|
"roll-dep", "v8 %s" % self["trunk_revision"],
|
|
|
|
cwd=self._options.chromium) is None:
|
2014-08-25 20:04:23 +00:00
|
|
|
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" %
|
2014-09-03 11:59:43 +00:00
|
|
|
(commit_title, sheriff, self._options.reviewer),
|
2014-09-05 09:19:48 +00:00
|
|
|
author=self._options.author,
|
|
|
|
cwd=self._options.chromium)
|
2014-09-03 08:29:53 +00:00
|
|
|
if not self._options.dry_run:
|
|
|
|
self.GitUpload(author=self._options.author,
|
|
|
|
force=True,
|
2014-09-05 09:19:48 +00:00
|
|
|
cq=self._options.use_commit_queue,
|
|
|
|
cwd=self._options.chromium)
|
2014-09-03 08:29:53 +00:00
|
|
|
print "CL uploaded."
|
|
|
|
else:
|
2014-09-05 09:19:48 +00:00
|
|
|
self.GitCheckout("master", cwd=self._options.chromium)
|
|
|
|
self.GitDeleteBranch("v8-roll-%s" % self["trunk_revision"],
|
|
|
|
cwd=self._options.chromium)
|
2014-09-03 08:29:53 +00:00
|
|
|
print "Dry run - don't upload."
|
2014-03-21 12:15:25 +00:00
|
|
|
|
|
|
|
|
2014-09-05 09:19:48 +00:00
|
|
|
# TODO(machenbach): Make this obsolete. We are only in the chromium chechout
|
|
|
|
# for the initial .git check.
|
2014-03-21 12:15:25 +00:00
|
|
|
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.
|
2014-09-23 14:41:36 +00:00
|
|
|
Command("rm", "-f %s*" % self._config["PERSISTFILE_BASENAME"])
|
2014-03-21 12:15:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2014-09-23 14:41:36 +00:00
|
|
|
def _Config(self):
|
|
|
|
return {
|
|
|
|
"PERSISTFILE_BASENAME": "/tmp/v8-chromium-roll-tempfile",
|
|
|
|
}
|
|
|
|
|
2014-03-21 12:15:25 +00:00
|
|
|
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
|
2014-09-23 14:41:36 +00:00
|
|
|
sys.exit(ChromiumRoll().Run())
|