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)"
|
|
|
|
PUSH_MSG_GIT_RE = re.compile(r".* \(based on (?P<git_rev>[a-fA-F0-9]+)\)$")
|
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
|
|
|
|
2014-09-23 14:41:36 +00:00
|
|
|
if(self["current_branch"] == self.Config("TRUNKBRANCH")
|
|
|
|
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()
|
2014-09-23 14:41:36 +00:00
|
|
|
self.DeleteBranch(self.Config("TRUNKBRANCH"))
|
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.")
|
|
|
|
|
|
|
|
|
2013-11-08 14:27:16 +00:00
|
|
|
class DetectLastPush(Step):
|
2013-11-22 09:48:43 +00:00
|
|
|
MESSAGE = "Detect commit ID of last push to trunk."
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
def RunStep(self):
|
2014-02-28 21:49:51 +00:00
|
|
|
last_push = self._options.last_push or self.FindLastTrunkPush()
|
2013-11-08 14:27:16 +00:00
|
|
|
while True:
|
|
|
|
# Print assumed commit, circumventing git's pager.
|
2014-02-20 16:39:41 +00:00
|
|
|
print self.GitLog(n=1, git_hash=last_push)
|
2013-11-08 14:27:16 +00:00
|
|
|
if self.Confirm("Is the commit printed above the last push to trunk?"):
|
|
|
|
break
|
2014-02-20 16:39:41 +00:00
|
|
|
last_push = self.FindLastTrunkPush(parent_hash=last_push)
|
2014-02-19 13:40:30 +00:00
|
|
|
|
2014-02-28 21:49:51 +00:00
|
|
|
if self._options.last_bleeding_edge:
|
2014-02-19 13:40:30 +00:00
|
|
|
# Read the bleeding edge revision of the last push from a command-line
|
|
|
|
# option.
|
2014-02-28 21:49:51 +00:00
|
|
|
last_push_bleeding_edge = self._options.last_bleeding_edge
|
2014-02-19 13:40:30 +00:00
|
|
|
else:
|
|
|
|
# Retrieve the bleeding edge revision of the last push from the text in
|
|
|
|
# the push commit message.
|
2014-02-20 16:39:41 +00:00
|
|
|
last_push_title = self.GitLog(n=1, format="%s", git_hash=last_push)
|
2014-11-12 17:54:11 +00:00
|
|
|
last_push_bleeding_edge = PUSH_MSG_GIT_RE.match(
|
|
|
|
last_push_title).group("git_rev")
|
2014-10-29 14:19:59 +00:00
|
|
|
|
2014-03-12 10:45:23 +00:00
|
|
|
if not last_push_bleeding_edge: # pragma: no cover
|
2014-02-19 13:40:30 +00:00
|
|
|
self.Die("Could not retrieve bleeding edge git hash for trunk push %s"
|
2014-02-20 16:39:41 +00:00
|
|
|
% last_push)
|
2014-02-19 13:40:30 +00:00
|
|
|
|
2014-10-29 14:19:59 +00:00
|
|
|
# This points to the git hash of the last push on trunk.
|
2014-02-20 16:39:41 +00:00
|
|
|
self["last_push_trunk"] = last_push
|
2014-03-20 09:23:44 +00:00
|
|
|
# This points to the last bleeding_edge revision that went into the last
|
|
|
|
# push.
|
2014-03-20 15:44:30 +00:00
|
|
|
# TODO(machenbach): Do we need a check to make sure we're not pushing a
|
|
|
|
# revision older than the last push? If we do this, the output of the
|
|
|
|
# current change log preparation won't make much sense.
|
2014-02-19 13:40:30 +00:00
|
|
|
self["last_push_bleeding_edge"] = last_push_bleeding_edge
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
|
2014-07-16 07:57:13 +00:00
|
|
|
# TODO(machenbach): Code similarities with bump_up_version.py. Merge after
|
|
|
|
# turning this script into a pure git script.
|
|
|
|
class GetCurrentBleedingEdgeVersion(Step):
|
|
|
|
MESSAGE = "Get latest bleeding edge version."
|
|
|
|
|
|
|
|
def RunStep(self):
|
2014-09-25 13:25:14 +00:00
|
|
|
self.GitCheckoutFile(VERSION_FILE, self.vc.RemoteMasterBranch())
|
2014-07-16 07:57:13 +00:00
|
|
|
|
|
|
|
# Store latest version.
|
|
|
|
self.ReadAndPersistVersion("latest_")
|
|
|
|
self["latest_version"] = self.ArrayToVersion("latest_")
|
|
|
|
print "Bleeding edge version: %s" % self["latest_version"]
|
|
|
|
|
|
|
|
|
2014-03-19 13:10:41 +00:00
|
|
|
class IncrementVersion(Step):
|
|
|
|
MESSAGE = "Increment version number."
|
|
|
|
|
|
|
|
def RunStep(self):
|
|
|
|
# Retrieve current version from last trunk push.
|
2014-09-23 09:35:49 +00:00
|
|
|
self.GitCheckoutFile(VERSION_FILE, self["last_push_trunk"])
|
2014-03-19 13:10:41 +00:00
|
|
|
self.ReadAndPersistVersion()
|
2014-07-16 07:57:13 +00:00
|
|
|
self["trunk_version"] = self.ArrayToVersion("")
|
|
|
|
|
|
|
|
if self["latest_build"] == "9999": # pragma: no cover
|
|
|
|
# If version control on bleeding edge was switched off, just use the last
|
|
|
|
# trunk version.
|
|
|
|
self["latest_version"] = self["trunk_version"]
|
|
|
|
|
|
|
|
if SortingKey(self["trunk_version"]) < SortingKey(self["latest_version"]):
|
|
|
|
# If the version on bleeding_edge is newer than on trunk, use it.
|
2014-09-25 13:25:14 +00:00
|
|
|
self.GitCheckoutFile(VERSION_FILE, self.vc.RemoteMasterBranch())
|
2014-07-16 07:57:13 +00:00
|
|
|
self.ReadAndPersistVersion()
|
2014-03-19 13:10:41 +00:00
|
|
|
|
|
|
|
if self.Confirm(("Automatically increment BUILD_NUMBER? (Saying 'n' will "
|
|
|
|
"fire up your EDITOR on %s so you can make arbitrary "
|
|
|
|
"changes. When you're done, save the file and exit your "
|
2014-09-23 09:35:49 +00:00
|
|
|
"EDITOR.)" % VERSION_FILE)):
|
2014-07-16 07:57:13 +00:00
|
|
|
|
2014-09-23 09:35:49 +00:00
|
|
|
text = FileToText(os.path.join(self.default_cwd, VERSION_FILE))
|
2014-03-19 13:10:41 +00:00
|
|
|
text = MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$",
|
|
|
|
r"\g<space>%s" % str(int(self["build"]) + 1),
|
|
|
|
text)
|
2014-09-23 09:35:49 +00:00
|
|
|
TextToFile(text, os.path.join(self.default_cwd, VERSION_FILE))
|
2014-03-19 13:10:41 +00:00
|
|
|
else:
|
2014-09-23 09:35:49 +00:00
|
|
|
self.Editor(os.path.join(self.default_cwd, VERSION_FILE))
|
2014-03-19 13:10:41 +00:00
|
|
|
|
|
|
|
# Variables prefixed with 'new_' contain the new version numbers for the
|
|
|
|
# ongoing trunk push.
|
|
|
|
self.ReadAndPersistVersion("new_")
|
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"])
|
|
|
|
|
|
|
|
|
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",
|
2014-03-20 15:44:30 +00:00
|
|
|
git_hash="%s..%s" % (self["last_push_bleeding_edge"],
|
|
|
|
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.")
|
|
|
|
|
2014-03-12 07:39:56 +00:00
|
|
|
# Safe new change log for adding it later to the trunk 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):
|
2013-11-22 09:48:43 +00:00
|
|
|
MESSAGE = "Create a new branch from trunk."
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
def RunStep(self):
|
2014-09-25 13:25:14 +00:00
|
|
|
self.GitCreateBranch(self.Config("TRUNKBRANCH"),
|
|
|
|
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"))
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
|
2014-03-15 13:06:08 +00:00
|
|
|
class AddChangeLog(Step):
|
|
|
|
MESSAGE = "Add ChangeLog changes to trunk branch."
|
|
|
|
|
|
|
|
def RunStep(self):
|
|
|
|
# The change log has been modified by the patch. Reset it to the version
|
|
|
|
# on trunk and apply the exact changes determined by this PrepareChangeLog
|
|
|
|
# step above.
|
2014-11-10 11:52:00 +00:00
|
|
|
self.GitCheckoutFile(CHANGELOG_FILE, self.vc.RemoteCandidateBranch())
|
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):
|
2013-11-22 09:48:43 +00:00
|
|
|
MESSAGE = "Set correct version for trunk."
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
def RunStep(self):
|
2014-03-19 10:46:24 +00:00
|
|
|
# The version file has been modified by the patch. Reset it to the version
|
|
|
|
# on trunk and apply the correct version.
|
2014-09-25 13:25:14 +00:00
|
|
|
self.GitCheckoutFile(VERSION_FILE, self.vc.RemoteCandidateBranch())
|
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
|
|
|
|
|
|
|
|
|
|
|
class CommitTrunk(Step):
|
2013-11-22 09:48:43 +00:00
|
|
|
MESSAGE = "Commit to local trunk 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 "
|
|
|
|
"%s, compile, run tests. Do you want to commit this new trunk "
|
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):
|
2014-03-21 12:15:25 +00:00
|
|
|
print("Congratulations, you have successfully created the trunk "
|
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()
|
2014-09-23 14:41:36 +00:00
|
|
|
if self.Config("TRUNKBRANCH") != self["current_branch"]:
|
|
|
|
self.GitDeleteBranch(self.Config("TRUNKBRANCH"))
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
|
2014-03-04 23:27:27 +00:00
|
|
|
class PushToTrunk(ScriptsBase):
|
|
|
|
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")
|
|
|
|
parser.add_argument("-b", "--last-bleeding-edge",
|
|
|
|
help=("The git commit ID of the last bleeding edge "
|
|
|
|
"revision that was pushed to trunk. This is "
|
|
|
|
"used for the auto-generated ChangeLog entry."))
|
|
|
|
parser.add_argument("-l", "--last-push",
|
|
|
|
help="The git commit ID of the last push to trunk.")
|
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",
|
|
|
|
"TRUNKBRANCH": "trunk-push",
|
|
|
|
"PERSISTFILE_BASENAME": "/tmp/v8-push-to-trunk-tempfile",
|
|
|
|
"CHANGELOG_ENTRY_FILE": "/tmp/v8-push-to-trunk-tempfile-changelog-entry",
|
|
|
|
"PATCH_FILE": "/tmp/v8-push-to-trunk-tempfile-patch-file",
|
|
|
|
"COMMITMSG_FILE": "/tmp/v8-push-to-trunk-tempfile-commitmsg",
|
|
|
|
}
|
|
|
|
|
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-04 23:27:27 +00:00
|
|
|
DetectLastPush,
|
2014-07-16 07:57:13 +00:00
|
|
|
GetCurrentBleedingEdgeVersion,
|
2014-03-19 13:10:41 +00:00
|
|
|
IncrementVersion,
|
2014-03-04 23:27:27 +00:00
|
|
|
PrepareChangeLog,
|
|
|
|
EditChangeLog,
|
|
|
|
StragglerCommits,
|
|
|
|
SquashCommits,
|
|
|
|
NewBranch,
|
|
|
|
ApplyChanges,
|
2014-03-15 13:06:08 +00:00
|
|
|
AddChangeLog,
|
2014-03-04 23:27:27 +00:00
|
|
|
SetVersion,
|
|
|
|
CommitTrunk,
|
|
|
|
SanityCheck,
|
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
|
2014-09-23 14:41:36 +00:00
|
|
|
sys.exit(PushToTrunk().Run())
|