2013-11-08 14:27:16 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# Copyright 2013 the V8 project authors. All rights reserved.
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions are
|
|
|
|
# met:
|
|
|
|
#
|
|
|
|
# * Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# * Redistributions in binary form must reproduce the above
|
|
|
|
# copyright notice, this list of conditions and the following
|
|
|
|
# disclaimer in the documentation and/or other materials provided
|
|
|
|
# with the distribution.
|
|
|
|
# * Neither the name of Google Inc. nor the names of its
|
|
|
|
# contributors may be used to endorse or promote products derived
|
|
|
|
# from this software without specific prior written permission.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
2014-02-26 15:13:31 +00:00
|
|
|
import argparse
|
2014-09-05 09:19:48 +00:00
|
|
|
import os
|
2013-11-08 14:27:16 +00:00
|
|
|
import sys
|
|
|
|
import tempfile
|
2013-11-25 14:20:39 +00:00
|
|
|
import urllib2
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
from common_includes import *
|
|
|
|
|
2014-10-29 14:19:59 +00:00
|
|
|
PUSH_MSG_GIT_SUFFIX = " (based on %s)"
|
2015-01-28 10:08:53 +00:00
|
|
|
|
2014-02-19 13:40:30 +00:00
|
|
|
|
2013-11-08 14:27:16 +00:00
|
|
|
class Preparation(Step):
|
2013-11-22 09:48:43 +00:00
|
|
|
MESSAGE = "Preparation."
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
def RunStep(self):
|
2014-09-19 13:37:34 +00:00
|
|
|
self.InitialEnvironmentChecks(self.default_cwd)
|
2013-11-08 14:27:16 +00:00
|
|
|
self.CommonPrepare()
|
2014-05-05 15:16:26 +00:00
|
|
|
|
2015-01-26 13:29:23 +00:00
|
|
|
if(self["current_branch"] == self.Config("CANDIDATESBRANCH")
|
2014-09-23 14:41:36 +00:00
|
|
|
or self["current_branch"] == self.Config("BRANCHNAME")):
|
2014-05-05 15:16:26 +00:00
|
|
|
print "Warning: Script started on branch %s" % self["current_branch"]
|
|
|
|
|
2013-11-18 14:10:47 +00:00
|
|
|
self.PrepareBranch()
|
2015-01-26 13:29:23 +00:00
|
|
|
self.DeleteBranch(self.Config("CANDIDATESBRANCH"))
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
class FreshBranch(Step):
|
2013-11-22 09:48:43 +00:00
|
|
|
MESSAGE = "Create a fresh branch."
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
def RunStep(self):
|
2014-09-25 13:25:14 +00:00
|
|
|
self.GitCreateBranch(self.Config("BRANCHNAME"),
|
|
|
|
self.vc.RemoteMasterBranch())
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
|
2014-03-20 15:44:30 +00:00
|
|
|
class PreparePushRevision(Step):
|
|
|
|
MESSAGE = "Check which revision to push."
|
|
|
|
|
|
|
|
def RunStep(self):
|
|
|
|
if self._options.revision:
|
2014-10-29 14:19:59 +00:00
|
|
|
self["push_hash"] = self._options.revision
|
2014-03-20 15:44:30 +00:00
|
|
|
else:
|
|
|
|
self["push_hash"] = self.GitLog(n=1, format="%H", git_hash="HEAD")
|
|
|
|
if not self["push_hash"]: # pragma: no cover
|
|
|
|
self.Die("Could not determine the git hash for the push.")
|
|
|
|
|
|
|
|
|
2015-01-27 08:53:28 +00:00
|
|
|
class IncrementVersion(Step):
|
|
|
|
MESSAGE = "Increment version number."
|
2014-07-16 07:57:13 +00:00
|
|
|
|
|
|
|
def RunStep(self):
|
2015-01-27 08:53:28 +00:00
|
|
|
latest_version = self.GetLatestVersion()
|
2015-01-23 10:30:32 +00:00
|
|
|
|
|
|
|
# The version file on master can be used to bump up major/minor at
|
|
|
|
# branch time.
|
2014-09-25 13:25:14 +00:00
|
|
|
self.GitCheckoutFile(VERSION_FILE, self.vc.RemoteMasterBranch())
|
2015-01-23 10:30:32 +00:00
|
|
|
self.ReadAndPersistVersion("master_")
|
2015-01-27 08:53:28 +00:00
|
|
|
master_version = self.ArrayToVersion("master_")
|
2014-07-16 07:57:13 +00:00
|
|
|
|
2015-01-27 08:53:28 +00:00
|
|
|
# Use the highest version from master or from tags to determine the new
|
|
|
|
# version.
|
|
|
|
authoritative_version = sorted(
|
|
|
|
[master_version, latest_version], key=SortingKey)[1]
|
|
|
|
self.StoreVersion(authoritative_version, "authoritative_")
|
2014-07-16 07:57:13 +00:00
|
|
|
|
2014-03-19 13:10:41 +00:00
|
|
|
# Variables prefixed with 'new_' contain the new version numbers for the
|
2015-01-26 13:29:23 +00:00
|
|
|
# ongoing candidates push.
|
2015-01-27 08:53:28 +00:00
|
|
|
self["new_major"] = self["authoritative_major"]
|
|
|
|
self["new_minor"] = self["authoritative_minor"]
|
|
|
|
self["new_build"] = str(int(self["authoritative_build"]) + 1)
|
2014-07-16 07:57:13 +00:00
|
|
|
|
|
|
|
# Make sure patch level is 0 in a new push.
|
|
|
|
self["new_patch"] = "0"
|
|
|
|
|
2014-03-19 13:10:41 +00:00
|
|
|
self["version"] = "%s.%s.%s" % (self["new_major"],
|
|
|
|
self["new_minor"],
|
|
|
|
self["new_build"])
|
|
|
|
|
2015-01-27 08:53:28 +00:00
|
|
|
print ("Incremented version to %s" % self["version"])
|
|
|
|
|
2014-03-19 13:10:41 +00:00
|
|
|
|
2015-01-28 10:08:53 +00:00
|
|
|
class DetectLastRelease(Step):
|
|
|
|
MESSAGE = "Detect commit ID of last release base."
|
|
|
|
|
|
|
|
def RunStep(self):
|
|
|
|
if self._options.last_master:
|
|
|
|
self["last_push_master"] = self._options.last_master
|
|
|
|
else:
|
|
|
|
self["last_push_master"] = self.GetLatestReleaseBase()
|
|
|
|
|
|
|
|
|
2013-11-08 14:27:16 +00:00
|
|
|
class PrepareChangeLog(Step):
|
2013-11-22 09:48:43 +00:00
|
|
|
MESSAGE = "Prepare raw ChangeLog entry."
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2013-11-25 14:20:39 +00:00
|
|
|
def Reload(self, body):
|
|
|
|
"""Attempts to reload the commit message from rietveld in order to allow
|
|
|
|
late changes to the LOG flag. Note: This is brittle to future changes of
|
|
|
|
the web page name or structure.
|
|
|
|
"""
|
|
|
|
match = re.search(r"^Review URL: https://codereview\.chromium\.org/(\d+)$",
|
|
|
|
body, flags=re.M)
|
|
|
|
if match:
|
2014-02-19 11:56:48 +00:00
|
|
|
cl_url = ("https://codereview.chromium.org/%s/description"
|
|
|
|
% match.group(1))
|
2013-11-25 14:20:39 +00:00
|
|
|
try:
|
2013-12-02 09:53:28 +00:00
|
|
|
# Fetch from Rietveld but only retry once with one second delay since
|
|
|
|
# there might be many revisions.
|
|
|
|
body = self.ReadURL(cl_url, wait_plan=[1])
|
2014-03-12 10:45:23 +00:00
|
|
|
except urllib2.URLError: # pragma: no cover
|
2013-11-25 14:20:39 +00:00
|
|
|
pass
|
|
|
|
return body
|
|
|
|
|
2013-11-08 14:27:16 +00:00
|
|
|
def RunStep(self):
|
2014-02-19 11:56:48 +00:00
|
|
|
self["date"] = self.GetDate()
|
2014-03-19 13:10:41 +00:00
|
|
|
output = "%s: Version %s\n\n" % (self["date"], self["version"])
|
2014-09-23 14:41:36 +00:00
|
|
|
TextToFile(output, self.Config("CHANGELOG_ENTRY_FILE"))
|
2014-02-20 16:39:41 +00:00
|
|
|
commits = self.GitLog(format="%H",
|
2015-01-26 13:29:23 +00:00
|
|
|
git_hash="%s..%s" % (self["last_push_master"],
|
2014-03-20 15:44:30 +00:00
|
|
|
self["push_hash"]))
|
2013-11-18 13:34:32 +00:00
|
|
|
|
2013-11-21 09:35:25 +00:00
|
|
|
# Cache raw commit messages.
|
|
|
|
commit_messages = [
|
|
|
|
[
|
2014-02-20 16:39:41 +00:00
|
|
|
self.GitLog(n=1, format="%s", git_hash=commit),
|
|
|
|
self.Reload(self.GitLog(n=1, format="%B", git_hash=commit)),
|
|
|
|
self.GitLog(n=1, format="%an", git_hash=commit),
|
2013-11-21 09:35:25 +00:00
|
|
|
] for commit in commits.splitlines()
|
|
|
|
]
|
|
|
|
|
|
|
|
# Auto-format commit messages.
|
|
|
|
body = MakeChangeLogBody(commit_messages, auto_format=True)
|
2014-09-23 14:41:36 +00:00
|
|
|
AppendToFile(body, self.Config("CHANGELOG_ENTRY_FILE"))
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2013-11-21 09:35:25 +00:00
|
|
|
msg = (" Performance and stability improvements on all platforms."
|
|
|
|
"\n#\n# The change log above is auto-generated. Please review if "
|
|
|
|
"all relevant\n# commit messages from the list below are included."
|
|
|
|
"\n# All lines starting with # will be stripped.\n#\n")
|
2014-09-23 14:41:36 +00:00
|
|
|
AppendToFile(msg, self.Config("CHANGELOG_ENTRY_FILE"))
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2013-11-21 09:35:25 +00:00
|
|
|
# Include unformatted commit messages as a reference in a comment.
|
|
|
|
comment_body = MakeComment(MakeChangeLogBody(commit_messages))
|
2014-09-23 14:41:36 +00:00
|
|
|
AppendToFile(comment_body, self.Config("CHANGELOG_ENTRY_FILE"))
|
2013-11-21 09:35:25 +00:00
|
|
|
|
2013-11-18 13:34:32 +00:00
|
|
|
|
2013-11-08 14:27:16 +00:00
|
|
|
class EditChangeLog(Step):
|
2013-11-22 09:48:43 +00:00
|
|
|
MESSAGE = "Edit ChangeLog entry."
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
def RunStep(self):
|
|
|
|
print ("Please press <Return> to have your EDITOR open the ChangeLog "
|
|
|
|
"entry, then edit its contents to your liking. When you're done, "
|
|
|
|
"save the file and exit your EDITOR. ")
|
2013-11-20 08:49:42 +00:00
|
|
|
self.ReadLine(default="")
|
2014-09-23 14:41:36 +00:00
|
|
|
self.Editor(self.Config("CHANGELOG_ENTRY_FILE"))
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2013-11-22 09:48:43 +00:00
|
|
|
# Strip comments and reformat with correct indentation.
|
2014-09-23 14:41:36 +00:00
|
|
|
changelog_entry = FileToText(self.Config("CHANGELOG_ENTRY_FILE")).rstrip()
|
2013-11-21 09:35:25 +00:00
|
|
|
changelog_entry = StripComments(changelog_entry)
|
2013-11-22 09:48:43 +00:00
|
|
|
changelog_entry = "\n".join(map(Fill80, changelog_entry.splitlines()))
|
2013-11-25 14:20:39 +00:00
|
|
|
changelog_entry = changelog_entry.lstrip()
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2014-03-12 10:45:23 +00:00
|
|
|
if changelog_entry == "": # pragma: no cover
|
2013-11-08 14:27:16 +00:00
|
|
|
self.Die("Empty ChangeLog entry.")
|
|
|
|
|
2015-01-26 13:29:23 +00:00
|
|
|
# Safe new change log for adding it later to the candidates patch.
|
2014-09-23 14:41:36 +00:00
|
|
|
TextToFile(changelog_entry, self.Config("CHANGELOG_ENTRY_FILE"))
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
class StragglerCommits(Step):
|
2013-11-22 09:48:43 +00:00
|
|
|
MESSAGE = ("Fetch straggler commits that sneaked in since this script was "
|
|
|
|
"started.")
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
def RunStep(self):
|
2014-09-25 13:25:14 +00:00
|
|
|
self.vc.Fetch()
|
|
|
|
self.GitCheckout(self.vc.RemoteMasterBranch())
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
class SquashCommits(Step):
|
2013-11-22 09:48:43 +00:00
|
|
|
MESSAGE = "Squash commits into one."
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
def RunStep(self):
|
|
|
|
# Instead of relying on "git rebase -i", we'll just create a diff, because
|
2014-03-13 15:48:24 +00:00
|
|
|
# that's easier to automate.
|
2014-09-25 13:25:14 +00:00
|
|
|
TextToFile(self.GitDiff(self.vc.RemoteCandidateBranch(),
|
|
|
|
self["push_hash"]),
|
2014-09-23 14:41:36 +00:00
|
|
|
self.Config("PATCH_FILE"))
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2013-12-11 15:05:53 +00:00
|
|
|
# Convert the ChangeLog entry to commit message format.
|
2014-09-23 14:41:36 +00:00
|
|
|
text = FileToText(self.Config("CHANGELOG_ENTRY_FILE"))
|
2013-12-11 15:05:53 +00:00
|
|
|
|
|
|
|
# Remove date and trailing white space.
|
2014-02-19 11:56:48 +00:00
|
|
|
text = re.sub(r"^%s: " % self["date"], "", text.rstrip())
|
2013-12-11 15:05:53 +00:00
|
|
|
|
2014-10-29 14:19:59 +00:00
|
|
|
# Show the used master hash in the commit message.
|
|
|
|
suffix = PUSH_MSG_GIT_SUFFIX % self["push_hash"]
|
2014-02-19 13:40:30 +00:00
|
|
|
text = MSub(r"^(Version \d+\.\d+\.\d+)$", "\\1%s" % suffix, text)
|
2014-01-23 13:44:52 +00:00
|
|
|
|
2013-12-11 15:05:53 +00:00
|
|
|
# Remove indentation and merge paragraphs into single long lines, keeping
|
|
|
|
# empty lines between them.
|
|
|
|
def SplitMapJoin(split_text, fun, join_text):
|
|
|
|
return lambda text: join_text.join(map(fun, text.split(split_text)))
|
|
|
|
strip = lambda line: line.strip()
|
|
|
|
text = SplitMapJoin("\n\n", SplitMapJoin("\n", strip, " "), "\n\n")(text)
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2014-03-12 10:45:23 +00:00
|
|
|
if not text: # pragma: no cover
|
2013-11-08 14:27:16 +00:00
|
|
|
self.Die("Commit message editing failed.")
|
2014-10-07 10:46:04 +00:00
|
|
|
self["commit_title"] = text.splitlines()[0]
|
2014-09-23 14:41:36 +00:00
|
|
|
TextToFile(text, self.Config("COMMITMSG_FILE"))
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
class NewBranch(Step):
|
2015-01-26 13:29:23 +00:00
|
|
|
MESSAGE = "Create a new branch from candidates."
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
def RunStep(self):
|
2015-01-26 13:29:23 +00:00
|
|
|
self.GitCreateBranch(self.Config("CANDIDATESBRANCH"),
|
2014-09-25 13:25:14 +00:00
|
|
|
self.vc.RemoteCandidateBranch())
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ApplyChanges(Step):
|
2013-11-22 09:48:43 +00:00
|
|
|
MESSAGE = "Apply squashed changes."
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
def RunStep(self):
|
2014-09-23 14:41:36 +00:00
|
|
|
self.ApplyPatch(self.Config("PATCH_FILE"))
|
|
|
|
os.remove(self.Config("PATCH_FILE"))
|
2015-01-23 15:30:17 +00:00
|
|
|
# The change log has been modified by the patch. Reset it to the version
|
2015-01-26 13:29:23 +00:00
|
|
|
# on candidates and apply the exact changes determined by this
|
|
|
|
# PrepareChangeLog step above.
|
2015-01-23 15:30:17 +00:00
|
|
|
self.GitCheckoutFile(CHANGELOG_FILE, self.vc.RemoteCandidateBranch())
|
|
|
|
# The version file has been modified by the patch. Reset it to the version
|
2015-01-26 13:29:23 +00:00
|
|
|
# on candidates.
|
2015-01-23 15:30:17 +00:00
|
|
|
self.GitCheckoutFile(VERSION_FILE, self.vc.RemoteCandidateBranch())
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
|
2015-01-23 14:58:49 +00:00
|
|
|
class CommitSquash(Step):
|
|
|
|
MESSAGE = "Commit to local candidates branch."
|
|
|
|
|
|
|
|
def RunStep(self):
|
|
|
|
# Make a first commit with a slightly different title to not confuse
|
|
|
|
# the tagging.
|
|
|
|
msg = FileToText(self.Config("COMMITMSG_FILE")).splitlines()
|
|
|
|
msg[0] = msg[0].replace("(based on", "(squashed - based on")
|
|
|
|
self.GitCommit(message = "\n".join(msg))
|
|
|
|
|
|
|
|
|
|
|
|
class PrepareVersionBranch(Step):
|
|
|
|
MESSAGE = "Prepare new branch to commit version and changelog file."
|
|
|
|
|
|
|
|
def RunStep(self):
|
|
|
|
self.GitCheckout("master")
|
|
|
|
self.Git("fetch")
|
2015-01-26 13:29:23 +00:00
|
|
|
self.GitDeleteBranch(self.Config("CANDIDATESBRANCH"))
|
|
|
|
self.GitCreateBranch(self.Config("CANDIDATESBRANCH"),
|
2015-01-23 14:58:49 +00:00
|
|
|
self.vc.RemoteCandidateBranch())
|
|
|
|
|
|
|
|
|
2014-03-15 13:06:08 +00:00
|
|
|
class AddChangeLog(Step):
|
2015-01-26 13:29:23 +00:00
|
|
|
MESSAGE = "Add ChangeLog changes to candidates branch."
|
2014-03-15 13:06:08 +00:00
|
|
|
|
|
|
|
def RunStep(self):
|
2014-09-23 14:41:36 +00:00
|
|
|
changelog_entry = FileToText(self.Config("CHANGELOG_ENTRY_FILE"))
|
2014-11-10 11:52:00 +00:00
|
|
|
old_change_log = FileToText(os.path.join(self.default_cwd, CHANGELOG_FILE))
|
2014-03-15 13:06:08 +00:00
|
|
|
new_change_log = "%s\n\n\n%s" % (changelog_entry, old_change_log)
|
2014-11-10 11:52:00 +00:00
|
|
|
TextToFile(new_change_log, os.path.join(self.default_cwd, CHANGELOG_FILE))
|
2014-09-23 14:41:36 +00:00
|
|
|
os.remove(self.Config("CHANGELOG_ENTRY_FILE"))
|
2014-03-15 13:06:08 +00:00
|
|
|
|
|
|
|
|
2013-11-08 14:27:16 +00:00
|
|
|
class SetVersion(Step):
|
2015-01-26 13:29:23 +00:00
|
|
|
MESSAGE = "Set correct version for candidates."
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
def RunStep(self):
|
2014-09-23 09:35:49 +00:00
|
|
|
self.SetVersion(os.path.join(self.default_cwd, VERSION_FILE), "new_")
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
|
2015-01-23 14:58:49 +00:00
|
|
|
class CommitCandidate(Step):
|
|
|
|
MESSAGE = "Commit version and changelog to local candidates branch."
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
def RunStep(self):
|
2014-09-23 14:41:36 +00:00
|
|
|
self.GitCommit(file_name = self.Config("COMMITMSG_FILE"))
|
|
|
|
os.remove(self.Config("COMMITMSG_FILE"))
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
class SanityCheck(Step):
|
2013-11-22 09:48:43 +00:00
|
|
|
MESSAGE = "Sanity check."
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
def RunStep(self):
|
2014-03-20 09:23:44 +00:00
|
|
|
# TODO(machenbach): Run presubmit script here as it is now missing in the
|
|
|
|
# prepare push process.
|
2013-11-08 14:27:16 +00:00
|
|
|
if not self.Confirm("Please check if your local checkout is sane: Inspect "
|
2015-01-26 13:29:23 +00:00
|
|
|
"%s, compile, run tests. Do you want to commit this new candidates "
|
2014-09-23 09:35:49 +00:00
|
|
|
"revision to the repository?" % VERSION_FILE):
|
2014-03-12 10:45:23 +00:00
|
|
|
self.Die("Execution canceled.") # pragma: no cover
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
|
2014-11-12 17:54:11 +00:00
|
|
|
class Land(Step):
|
|
|
|
MESSAGE = "Land the patch."
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
def RunStep(self):
|
2014-11-13 09:22:45 +00:00
|
|
|
self.vc.CLLand()
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TagRevision(Step):
|
2013-11-22 09:48:43 +00:00
|
|
|
MESSAGE = "Tag the new revision."
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
def RunStep(self):
|
2014-10-07 10:46:04 +00:00
|
|
|
self.vc.Tag(
|
|
|
|
self["version"], self.vc.RemoteCandidateBranch(), self["commit_title"])
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
class CleanUp(Step):
|
2013-11-22 09:48:43 +00:00
|
|
|
MESSAGE = "Done!"
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
def RunStep(self):
|
2015-01-26 13:29:23 +00:00
|
|
|
print("Congratulations, you have successfully created the candidates "
|
2014-09-25 14:09:34 +00:00
|
|
|
"revision %s."
|
2014-03-21 12:15:25 +00:00
|
|
|
% self["version"])
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
self.CommonCleanup()
|
2015-01-26 13:29:23 +00:00
|
|
|
if self.Config("CANDIDATESBRANCH") != self["current_branch"]:
|
|
|
|
self.GitDeleteBranch(self.Config("CANDIDATESBRANCH"))
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
|
2015-01-26 13:29:23 +00:00
|
|
|
class PushToCandidates(ScriptsBase):
|
2014-03-04 23:27:27 +00:00
|
|
|
def _PrepareOptions(self, parser):
|
|
|
|
group = parser.add_mutually_exclusive_group()
|
|
|
|
group.add_argument("-f", "--force",
|
|
|
|
help="Don't prompt the user.",
|
|
|
|
default=False, action="store_true")
|
|
|
|
group.add_argument("-m", "--manual",
|
|
|
|
help="Prompt the user at every important step.",
|
|
|
|
default=False, action="store_true")
|
2015-01-26 13:29:23 +00:00
|
|
|
parser.add_argument("-b", "--last-master",
|
|
|
|
help=("The git commit ID of the last master "
|
|
|
|
"revision that was pushed to candidates. This is"
|
|
|
|
" used for the auto-generated ChangeLog entry."))
|
2014-03-04 23:27:27 +00:00
|
|
|
parser.add_argument("-l", "--last-push",
|
2015-01-26 13:29:23 +00:00
|
|
|
help="The git commit ID of the last candidates push.")
|
2014-03-20 15:44:30 +00:00
|
|
|
parser.add_argument("-R", "--revision",
|
2014-10-29 14:19:59 +00:00
|
|
|
help="The git commit ID to push (defaults to HEAD).")
|
2014-03-04 23:27:27 +00:00
|
|
|
|
2014-03-12 10:45:23 +00:00
|
|
|
def _ProcessOptions(self, options): # pragma: no cover
|
2014-03-04 23:27:27 +00:00
|
|
|
if not options.manual and not options.reviewer:
|
|
|
|
print "A reviewer (-r) is required in (semi-)automatic mode."
|
|
|
|
return False
|
|
|
|
if not options.manual and not options.author:
|
|
|
|
print "Specify your chromium.org email with -a in (semi-)automatic mode."
|
|
|
|
return False
|
|
|
|
|
|
|
|
options.tbr_commit = not options.manual
|
|
|
|
return True
|
|
|
|
|
2014-09-23 14:41:36 +00:00
|
|
|
def _Config(self):
|
|
|
|
return {
|
|
|
|
"BRANCHNAME": "prepare-push",
|
2015-01-26 13:29:23 +00:00
|
|
|
"CANDIDATESBRANCH": "candidates-push",
|
|
|
|
"PERSISTFILE_BASENAME": "/tmp/v8-push-to-candidates-tempfile",
|
|
|
|
"CHANGELOG_ENTRY_FILE":
|
|
|
|
"/tmp/v8-push-to-candidates-tempfile-changelog-entry",
|
|
|
|
"PATCH_FILE": "/tmp/v8-push-to-candidates-tempfile-patch-file",
|
|
|
|
"COMMITMSG_FILE": "/tmp/v8-push-to-candidates-tempfile-commitmsg",
|
2014-09-23 14:41:36 +00:00
|
|
|
}
|
|
|
|
|
2014-03-04 23:27:27 +00:00
|
|
|
def _Steps(self):
|
|
|
|
return [
|
|
|
|
Preparation,
|
|
|
|
FreshBranch,
|
2014-03-20 15:44:30 +00:00
|
|
|
PreparePushRevision,
|
2014-03-19 13:10:41 +00:00
|
|
|
IncrementVersion,
|
2015-01-28 10:08:53 +00:00
|
|
|
DetectLastRelease,
|
2014-03-04 23:27:27 +00:00
|
|
|
PrepareChangeLog,
|
|
|
|
EditChangeLog,
|
|
|
|
StragglerCommits,
|
|
|
|
SquashCommits,
|
|
|
|
NewBranch,
|
|
|
|
ApplyChanges,
|
2015-01-23 14:58:49 +00:00
|
|
|
CommitSquash,
|
|
|
|
SanityCheck,
|
|
|
|
Land,
|
|
|
|
PrepareVersionBranch,
|
2014-03-15 13:06:08 +00:00
|
|
|
AddChangeLog,
|
2014-03-04 23:27:27 +00:00
|
|
|
SetVersion,
|
2015-01-23 14:58:49 +00:00
|
|
|
CommitCandidate,
|
2014-11-12 17:54:11 +00:00
|
|
|
Land,
|
2014-03-04 23:27:27 +00:00
|
|
|
TagRevision,
|
|
|
|
CleanUp,
|
|
|
|
]
|
|
|
|
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2014-03-12 10:45:23 +00:00
|
|
|
if __name__ == "__main__": # pragma: no cover
|
2015-01-26 13:29:23 +00:00
|
|
|
sys.exit(PushToCandidates().Run())
|