Clean up release scripts.

This makes some internal renaming, e.g. trunk -> candidates,
bleeding edge -> master, without changing the api.

Also remove some unused bailout steps from the push script.

Remove unused bump version script.

BUG=chromium:451975
TBR=tandrii@chromium.org
NOTRY=true
LOG=n

Review URL: https://codereview.chromium.org/873213002

Cr-Commit-Position: refs/heads/master@{#26269}
This commit is contained in:
machenbach 2015-01-26 05:29:23 -08:00 committed by Commit bot
parent 00f3f99221
commit 379dcd5bd4
9 changed files with 146 additions and 542 deletions

View File

@ -46,30 +46,6 @@ class Preparation(Step):
self.CommonPrepare()
class CheckAutoPushSettings(Step):
MESSAGE = "Checking settings file."
def RunStep(self):
settings_file = os.path.realpath(self.Config("SETTINGS_LOCATION"))
if os.path.exists(settings_file):
settings_dict = json.loads(FileToText(settings_file))
if settings_dict.get("enable_auto_roll") is False:
self.Die("Push to trunk disabled by auto-roll settings file: %s"
% settings_file)
class CheckTreeStatus(Step):
MESSAGE = "Checking v8 tree status message."
def RunStep(self):
status_url = "https://v8-status.appspot.com/current?format=json"
status_json = self.ReadURL(status_url, wait_plan=[5, 20, 300, 300])
self["tree_message"] = json.loads(status_json)["message"]
if re.search(r"nopush|no push", self["tree_message"], flags=re.I):
self.Die("Push to trunk disabled by tree state: %s"
% self["tree_message"])
class FetchCandidate(Step):
MESSAGE = "Fetching V8 roll candidate ref."
@ -79,22 +55,22 @@ class FetchCandidate(Step):
class CheckLastPush(Step):
MESSAGE = "Checking last V8 push to trunk."
MESSAGE = "Checking last V8 push to candidates."
def RunStep(self):
last_push = self.FindLastTrunkPush()
last_push = self.FindLastCandidatesPush()
# Retrieve the bleeding edge revision of the last push from the text in
# Retrieve the master revision of the last push from the text in
# the push commit message.
last_push_title = self.GitLog(n=1, format="%s", git_hash=last_push)
last_push_be = PUSH_MESSAGE_RE.match(last_push_title).group(1)
candidate = PUSH_MESSAGE_RE.match(last_push_title).group(1)
if not last_push_be: # pragma: no cover
self.Die("Could not retrieve bleeding edge revision for trunk push %s"
if not candidate: # pragma: no cover
self.Die("Could not retrieve master revision for candidates push %s"
% last_push)
if self["candidate"] == last_push_be:
print "Already pushed current candidate %s" % last_push_be
if self["candidate"] == candidate:
print "Already pushed current candidate %s" % candidate
return True
@ -116,13 +92,14 @@ class PushToCandidates(Step):
# TODO(machenbach): Update the script before calling it.
if self._options.push:
self._side_effect_handler.Call(push_to_trunk.PushToTrunk().Run, args)
self._side_effect_handler.Call(
push_to_trunk.PushToCandidates().Run, args)
class AutoPush(ScriptsBase):
def _PrepareOptions(self, parser):
parser.add_argument("-p", "--push",
help="Push to trunk. Dry run if unspecified.",
help="Push to candidates. Dry run if unspecified.",
default=False, action="store_true")
def _ProcessOptions(self, options):
@ -135,14 +112,11 @@ class AutoPush(ScriptsBase):
def _Config(self):
return {
"PERSISTFILE_BASENAME": "/tmp/v8-auto-push-tempfile",
"SETTINGS_LOCATION": "~/.auto-roll",
}
def _Steps(self):
return [
Preparation,
CheckAutoPushSettings,
CheckTreeStatus,
FetchCandidate,
CheckLastPush,
PushToCandidates,

View File

@ -39,11 +39,11 @@ class CheckActiveRoll(Step):
class DetectLastPush(Step):
MESSAGE = "Detect commit ID of the last push to trunk."
MESSAGE = "Detect commit ID of the last push to candidates."
def RunStep(self):
self.vc.Fetch()
push_hash = self.FindLastTrunkPush(
push_hash = self.FindLastCandidatesPush(
branch="origin/candidates", include_patches=True)
self["last_push"] = self.GetCommitPositionNumber(push_hash)
@ -58,8 +58,8 @@ class DetectLastRoll(Step):
Var = lambda var: '%s'
exec(FileToText(os.path.join(self._options.chromium, "DEPS")))
last_roll = self.GetCommitPositionNumber(vars['v8_revision'])
# FIXME(machenbach): When rolling from bleeding edge and from trunk there
# be different commit numbers here. Better use version?
# FIXME(machenbach): When rolling from master and from candidates there
# will be different commit numbers here. Better use version?
if int(last_roll) >= int(self["last_push"]):
print("There is no newer v8 revision than the one in Chromium (%s)."
% last_roll)

View File

@ -1,247 +0,0 @@
#!/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.
"""
Script for auto-increasing the version on bleeding_edge.
The script can be run regularly by a cron job. It will increase the build
level of the version on bleeding_edge if:
- the lkgr version is smaller than the version of the latest revision,
- the lkgr version is not a version change itself,
- the tree is not closed for maintenance.
The new version will be the maximum of the bleeding_edge and trunk versions +1.
E.g. latest bleeding_edge version: 3.22.11.0 and latest trunk 3.23.0.0 gives
the new version 3.23.1.0.
This script requires a depot tools git checkout. I.e. 'fetch v8'.
"""
import argparse
import os
import sys
from common_includes import *
VERSION_BRANCH = "auto-bump-up-version"
# TODO(machenbach): Add vc interface that works on git mirror.
class Preparation(Step):
MESSAGE = "Preparation."
def RunStep(self):
# TODO(machenbach): Remove after the git switch.
if(self.Config("PERSISTFILE_BASENAME") ==
"/tmp/v8-bump-up-version-tempfile"):
print "This script is disabled until after the v8 git migration."
return True
# Check for a clean workdir.
if not self.GitIsWorkdirClean(): # pragma: no cover
# This is in case a developer runs this script on a dirty tree.
self.GitStash()
self.GitCheckout("master")
self.GitPull()
# Ensure a clean version branch.
self.DeleteBranch(VERSION_BRANCH)
class GetCurrentBleedingEdgeVersion(Step):
MESSAGE = "Get latest bleeding edge version."
def RunStep(self):
self.GitCheckout("master")
# Store latest version and revision.
self.ReadAndPersistVersion()
self["latest_version"] = self.ArrayToVersion("")
self["latest"] = self.GitLog(n=1, format="%H")
print "Bleeding edge version: %s" % self["latest_version"]
# This step is pure paranoia. It forbids the script to continue if the last
# commit changed version.cc. Just in case the other bailout has a bug, this
# prevents the script from continuously commiting version changes.
class LastChangeBailout(Step):
MESSAGE = "Stop script if the last change modified the version."
def RunStep(self):
if VERSION_FILE in self.GitChangedFiles(self["latest"]):
print "Stop due to recent version change."
return True
# TODO(machenbach): Implement this for git.
class FetchLKGR(Step):
MESSAGE = "Fetching V8 LKGR."
def RunStep(self):
lkgr_url = "https://v8-status.appspot.com/lkgr"
self["lkgr_svn"] = self.ReadURL(lkgr_url, wait_plan=[5])
# TODO(machenbach): Implement this for git. With a git lkgr we could simply
# checkout that revision. With svn, we have to search backwards until that
# revision is found.
class GetLKGRVersion(Step):
MESSAGE = "Get bleeding edge lkgr version."
def RunStep(self):
self.GitCheckout("master")
# If the commit was made from svn, there is a mapping entry in the commit
# message.
self["lkgr"] = self.GitLog(
grep="^git-svn-id: [^@]*@%s [A-Za-z0-9-]*$" % self["lkgr_svn"],
format="%H")
# FIXME(machenbach): http://crbug.com/391712 can lead to svn lkgrs on the
# trunk branch (rarely).
if not self["lkgr"]: # pragma: no cover
self.Die("No git hash found for svn lkgr.")
self.GitCreateBranch(VERSION_BRANCH, self["lkgr"])
self.ReadAndPersistVersion("lkgr_")
self["lkgr_version"] = self.ArrayToVersion("lkgr_")
print "LKGR version: %s" % self["lkgr_version"]
# Ensure a clean version branch.
self.GitCheckout("master")
self.DeleteBranch(VERSION_BRANCH)
class LKGRVersionUpToDateBailout(Step):
MESSAGE = "Stop script if the lkgr has a renewed version."
def RunStep(self):
# If a version-change commit becomes the lkgr, don't bump up the version
# again.
if VERSION_FILE in self.GitChangedFiles(self["lkgr"]):
print "Stop because the lkgr is a version change itself."
return True
# Don't bump up the version if it got updated already after the lkgr.
if SortingKey(self["lkgr_version"]) < SortingKey(self["latest_version"]):
print("Stop because the latest version already changed since the lkgr "
"version.")
return True
class GetTrunkVersion(Step):
MESSAGE = "Get latest trunk version."
def RunStep(self):
self.GitCheckout("candidates")
self.GitPull()
self.ReadAndPersistVersion("trunk_")
self["trunk_version"] = self.ArrayToVersion("trunk_")
print "Trunk version: %s" % self["trunk_version"]
class CalculateVersion(Step):
MESSAGE = "Calculate the new version."
def RunStep(self):
if self["lkgr_build"] == "9999": # pragma: no cover
# If version control on bleeding edge was switched off, just use the last
# trunk version.
self["lkgr_version"] = self["trunk_version"]
# The new version needs to be greater than the max on bleeding edge and
# trunk.
max_version = max(self["trunk_version"],
self["lkgr_version"],
key=SortingKey)
# Strip off possible leading zeros.
self["new_major"], self["new_minor"], self["new_build"], _ = (
map(str, map(int, max_version.split("."))))
self["new_build"] = str(int(self["new_build"]) + 1)
self["new_patch"] = "0"
self["new_version"] = ("%s.%s.%s.0" %
(self["new_major"], self["new_minor"], self["new_build"]))
print "New version is %s" % self["new_version"]
if self._options.dry_run: # pragma: no cover
print "Dry run, skipping version change."
return True
class CheckTreeStatus(Step):
MESSAGE = "Checking v8 tree status message."
def RunStep(self):
status_url = "https://v8-status.appspot.com/current?format=json"
status_json = self.ReadURL(status_url, wait_plan=[5, 20, 300, 300])
message = json.loads(status_json)["message"]
if re.search(r"maintenance|no commits", message, flags=re.I):
print "Skip version change by tree status: \"%s\"" % message
return True
class ChangeVersion(Step):
MESSAGE = "Bump up the version."
def RunStep(self):
self.GitCreateBranch(VERSION_BRANCH, "master")
self.SetVersion(os.path.join(self.default_cwd, VERSION_FILE), "new_")
try:
msg = "[Auto-roll] Bump up version to %s" % self["new_version"]
self.GitCommit("%s\n\nTBR=%s" % (msg, self._options.author),
author=self._options.author)
self.GitUpload(author=self._options.author,
force=self._options.force_upload,
bypass_hooks=True)
self.GitCLLand()
print "Successfully changed the version."
finally:
# Clean up.
self.GitCheckout("master")
self.DeleteBranch(VERSION_BRANCH)
class BumpUpVersion(ScriptsBase):
def _PrepareOptions(self, parser):
parser.add_argument("--dry_run", help="Don't commit the new version.",
default=False, action="store_true")
def _ProcessOptions(self, options): # pragma: no cover
if not options.dry_run and not options.author:
print "Specify your chromium.org email with -a"
return False
options.wait_for_lgtm = False
options.force_readline_defaults = True
options.force_upload = True
return True
def _Config(self):
return {
"PERSISTFILE_BASENAME": "/tmp/v8-bump-up-version-tempfile",
"PATCH_FILE": "/tmp/v8-bump-up-version-tempfile-patch-file",
}
def _Steps(self):
return [
Preparation,
GetCurrentBleedingEdgeVersion,
LastChangeBailout,
FetchLKGR,
GetLKGRVersion,
LKGRVersionUpToDateBailout,
GetTrunkVersion,
CalculateVersion,
CheckTreeStatus,
ChangeVersion,
]
if __name__ == "__main__": # pragma: no cover
sys.exit(BumpUpVersion().Run())

View File

@ -19,10 +19,10 @@ class Preparation(Step):
class DetectLastPush(Step):
MESSAGE = "Detect commit ID of last push to trunk."
MESSAGE = "Detect commit ID of last push to candidates."
def RunStep(self):
self["last_push"] = self._options.last_push or self.FindLastTrunkPush(
self["last_push"] = self._options.last_push or self.FindLastCandidatesPush(
branch="origin/candidates", include_patches=True)
self["push_title"] = self.GitLog(n=1, format="%s",
git_hash=self["last_push"])
@ -118,7 +118,7 @@ class ChromiumRoll(ScriptsBase):
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.")
help="The git commit ID of the last candidates push.")
parser.add_argument("--use-commit-queue",
help="Check the CQ bit on upload.",
default=False, action="store_true")

View File

@ -589,7 +589,7 @@ class Step(GitRecipesMixin):
except GitFailedException:
self.WaitForResolvingConflicts(patch_file)
def FindLastTrunkPush(
def FindLastCandidatesPush(
self, parent_hash="", branch="", include_patches=False):
push_pattern = "^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*"
if not include_patches:

View File

@ -47,9 +47,9 @@ class Preparation(Step):
open(self.Config("ALREADY_MERGING_SENTINEL_FILE"), "a").close()
self.InitialEnvironmentChecks(self.default_cwd)
if self._options.revert_bleeding_edge:
# FIXME(machenbach): Make revert bleeding_edge obsolete?
self["merge_to_branch"] = "bleeding_edge"
if self._options.revert_master:
# FIXME(machenbach): Make revert master obsolete?
self["merge_to_branch"] = "master"
elif self._options.branch:
self["merge_to_branch"] = self._options.branch
else: # pragma: no cover
@ -111,7 +111,7 @@ class CreateCommitMessage(Step):
if not self["revision_list"]: # pragma: no cover
self.Die("Revision list is empty.")
if self._options.revert and not self._options.revert_bleeding_edge:
if self._options.revert and not self._options.revert_master:
action_text = "Rollback of %s"
else:
action_text = "Merged %s"
@ -156,7 +156,7 @@ class PrepareVersion(Step):
MESSAGE = "Prepare version file."
def RunStep(self):
if self._options.revert_bleeding_edge:
if self._options.revert_master:
return
# This is used to calculate the patch level increment.
self.ReadAndPersistVersion()
@ -166,7 +166,7 @@ class IncrementVersion(Step):
MESSAGE = "Increment version number."
def RunStep(self):
if self._options.revert_bleeding_edge:
if self._options.revert_master:
return
new_patch = str(int(self["patch"]) + 1)
if self.Confirm("Automatically increment PATCH_LEVEL? (Saying 'n' will "
@ -192,7 +192,7 @@ class CommitLocal(Step):
def RunStep(self):
# Add a commit message title.
if self._options.revert and self._options.revert_bleeding_edge:
if self._options.revert and self._options.revert_master:
# TODO(machenbach): Find a better convention if multiple patches are
# reverted in one CL.
self["commit_title"] = "Revert on master"
@ -218,7 +218,7 @@ class TagRevision(Step):
MESSAGE = "Create the tag."
def RunStep(self):
if self._options.revert_bleeding_edge:
if self._options.revert_master:
return
print "Creating tag %s" % self["version"]
self.vc.Tag(self["version"],
@ -231,7 +231,7 @@ class CleanUp(Step):
def RunStep(self):
self.CommonCleanup()
if not self._options.revert_bleeding_edge:
if not self._options.revert_master:
print "*** SUMMARY ***"
print "version: %s" % self["version"]
print "branch: %s" % self["merge_to_branch"]
@ -242,13 +242,13 @@ class CleanUp(Step):
class MergeToBranch(ScriptsBase):
def _Description(self):
return ("Performs the necessary steps to merge revisions from "
"bleeding_edge to other branches, including trunk.")
"master to other branches, including candidates.")
def _PrepareOptions(self, parser):
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument("--branch", help="The branch to merge to.")
group.add_argument("-R", "--revert-bleeding-edge",
help="Revert specified patches from bleeding edge.",
group.add_argument("-R", "--revert-master",
help="Revert specified patches from master.",
default=False, action="store_true")
parser.add_argument("revisions", nargs="*",
help="The revisions to merge.")
@ -264,7 +264,7 @@ class MergeToBranch(ScriptsBase):
help="A patch file to apply as part of the merge.")
def _ProcessOptions(self, options):
# TODO(machenbach): Add a test that covers revert from bleeding_edge
# TODO(machenbach): Add a test that covers revert from master
if len(options.revisions) < 1:
if not options.patch:
print "Either a patch file or revision numbers must be specified"

View File

@ -48,12 +48,12 @@ class Preparation(Step):
# Make sure tags are fetched.
self.Git("fetch origin +refs/tags/*:refs/tags/*")
if(self["current_branch"] == self.Config("TRUNKBRANCH")
if(self["current_branch"] == self.Config("CANDIDATESBRANCH")
or self["current_branch"] == self.Config("BRANCHNAME")):
print "Warning: Script started on branch %s" % self["current_branch"]
self.PrepareBranch()
self.DeleteBranch(self.Config("TRUNKBRANCH"))
self.DeleteBranch(self.Config("CANDIDATESBRANCH"))
class FreshBranch(Step):
@ -77,40 +77,41 @@ class PreparePushRevision(Step):
class DetectLastPush(Step):
MESSAGE = "Detect commit ID of last push to trunk."
MESSAGE = "Detect commit ID of last push to CANDIDATES."
def RunStep(self):
last_push = self._options.last_push or self.FindLastTrunkPush()
last_push = self._options.last_push or self.FindLastCandidatesPush()
while True:
# Print assumed commit, circumventing git's pager.
print self.GitLog(n=1, git_hash=last_push)
if self.Confirm("Is the commit printed above the last push to trunk?"):
if self.Confirm(
"Is the commit printed above the last push to candidates?"):
break
last_push = self.FindLastTrunkPush(parent_hash=last_push)
last_push = self.FindLastCandidatesPush(parent_hash=last_push)
if self._options.last_bleeding_edge:
# Read the bleeding edge revision of the last push from a command-line
# option.
last_push_bleeding_edge = self._options.last_bleeding_edge
if self._options.last_master:
# Read the master revision of the last push from a command-line option.
last_push_master = self._options.last_master
else:
# Retrieve the bleeding edge revision of the last push from the text in
# Retrieve the master revision of the last push from the text in
# the push commit message.
last_push_title = self.GitLog(n=1, format="%s", git_hash=last_push)
last_push_bleeding_edge = PUSH_MSG_GIT_RE.match(
last_push_master = PUSH_MSG_GIT_RE.match(
last_push_title).group("git_rev")
if not last_push_bleeding_edge: # pragma: no cover
self.Die("Could not retrieve bleeding edge git hash for trunk push %s"
% last_push)
if not last_push_master: # pragma: no cover
self.Die(
"Could not retrieve master git hash for candidates push %s"
% last_push)
# This points to the git hash of the last push on trunk.
self["last_push_trunk"] = last_push
# This points to the last bleeding_edge revision that went into the last
# This points to the git hash of the last push on candidates.
self["last_push_candidates"] = last_push
# This points to the last master revision that went into the last
# push.
# 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.
self["last_push_bleeding_edge"] = last_push_bleeding_edge
self["last_push_master"] = last_push_master
class GetLatestVersion(Step):
@ -140,7 +141,7 @@ class IncrementVersion(Step):
def RunStep(self):
# Variables prefixed with 'new_' contain the new version numbers for the
# ongoing trunk push.
# ongoing candidates push.
self["new_major"] = self["latest_major"]
self["new_minor"] = self["latest_minor"]
self["new_build"] = str(int(self["latest_build"]) + 1)
@ -179,7 +180,7 @@ class PrepareChangeLog(Step):
output = "%s: Version %s\n\n" % (self["date"], self["version"])
TextToFile(output, self.Config("CHANGELOG_ENTRY_FILE"))
commits = self.GitLog(format="%H",
git_hash="%s..%s" % (self["last_push_bleeding_edge"],
git_hash="%s..%s" % (self["last_push_master"],
self["push_hash"]))
# Cache raw commit messages.
@ -225,7 +226,7 @@ class EditChangeLog(Step):
if changelog_entry == "": # pragma: no cover
self.Die("Empty ChangeLog entry.")
# Safe new change log for adding it later to the trunk patch.
# Safe new change log for adding it later to the candidates patch.
TextToFile(changelog_entry, self.Config("CHANGELOG_ENTRY_FILE"))
@ -272,10 +273,10 @@ class SquashCommits(Step):
class NewBranch(Step):
MESSAGE = "Create a new branch from trunk."
MESSAGE = "Create a new branch from candidates."
def RunStep(self):
self.GitCreateBranch(self.Config("TRUNKBRANCH"),
self.GitCreateBranch(self.Config("CANDIDATESBRANCH"),
self.vc.RemoteCandidateBranch())
@ -286,11 +287,11 @@ class ApplyChanges(Step):
self.ApplyPatch(self.Config("PATCH_FILE"))
os.remove(self.Config("PATCH_FILE"))
# 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.
# on candidates and apply the exact changes determined by this
# PrepareChangeLog step above.
self.GitCheckoutFile(CHANGELOG_FILE, self.vc.RemoteCandidateBranch())
# The version file has been modified by the patch. Reset it to the version
# on trunk.
# on candidates.
self.GitCheckoutFile(VERSION_FILE, self.vc.RemoteCandidateBranch())
@ -311,13 +312,13 @@ class PrepareVersionBranch(Step):
def RunStep(self):
self.GitCheckout("master")
self.Git("fetch")
self.GitDeleteBranch(self.Config("TRUNKBRANCH"))
self.GitCreateBranch(self.Config("TRUNKBRANCH"),
self.GitDeleteBranch(self.Config("CANDIDATESBRANCH"))
self.GitCreateBranch(self.Config("CANDIDATESBRANCH"),
self.vc.RemoteCandidateBranch())
class AddChangeLog(Step):
MESSAGE = "Add ChangeLog changes to trunk branch."
MESSAGE = "Add ChangeLog changes to candidates branch."
def RunStep(self):
changelog_entry = FileToText(self.Config("CHANGELOG_ENTRY_FILE"))
@ -328,7 +329,7 @@ class AddChangeLog(Step):
class SetVersion(Step):
MESSAGE = "Set correct version for trunk."
MESSAGE = "Set correct version for candidates."
def RunStep(self):
self.SetVersion(os.path.join(self.default_cwd, VERSION_FILE), "new_")
@ -349,7 +350,7 @@ class SanityCheck(Step):
# TODO(machenbach): Run presubmit script here as it is now missing in the
# prepare push process.
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 "
"%s, compile, run tests. Do you want to commit this new candidates "
"revision to the repository?" % VERSION_FILE):
self.Die("Execution canceled.") # pragma: no cover
@ -373,16 +374,16 @@ class CleanUp(Step):
MESSAGE = "Done!"
def RunStep(self):
print("Congratulations, you have successfully created the trunk "
print("Congratulations, you have successfully created the candidates "
"revision %s."
% self["version"])
self.CommonCleanup()
if self.Config("TRUNKBRANCH") != self["current_branch"]:
self.GitDeleteBranch(self.Config("TRUNKBRANCH"))
if self.Config("CANDIDATESBRANCH") != self["current_branch"]:
self.GitDeleteBranch(self.Config("CANDIDATESBRANCH"))
class PushToTrunk(ScriptsBase):
class PushToCandidates(ScriptsBase):
def _PrepareOptions(self, parser):
group = parser.add_mutually_exclusive_group()
group.add_argument("-f", "--force",
@ -391,12 +392,12 @@ class PushToTrunk(ScriptsBase):
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("-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."))
parser.add_argument("-l", "--last-push",
help="The git commit ID of the last push to trunk.")
help="The git commit ID of the last candidates push.")
parser.add_argument("-R", "--revision",
help="The git commit ID to push (defaults to HEAD).")
@ -414,11 +415,12 @@ class PushToTrunk(ScriptsBase):
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",
"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",
}
def _Steps(self):
@ -449,4 +451,4 @@ class PushToTrunk(ScriptsBase):
if __name__ == "__main__": # pragma: no cover
sys.exit(PushToTrunk().Run())
sys.exit(PushToCandidates().Run())

View File

@ -3,7 +3,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This script retrieves the history of all V8 branches and trunk revisions and
# This script retrieves the history of all V8 branches and
# their corresponding Chromium revisions.
# Requires a chromium checkout with branch heads:
@ -136,7 +136,7 @@ class RetrieveV8Releases(Step):
return (self._options.max_releases > 0
and len(releases) > self._options.max_releases)
def GetBleedingEdgeGitFromPush(self, title):
def GetMasterHashFromPush(self, title):
return MatchSafe(PUSH_MSG_GIT_RE.match(title))
def GetMergedPatches(self, body):
@ -161,7 +161,7 @@ class RetrieveV8Releases(Step):
def GetReleaseDict(
self, git_hash, bleeding_edge_rev, bleeding_edge_git, branch, version,
self, git_hash, master_position, master_hash, branch, version,
patches, cl_body):
revision = self.GetCommitPositionNumber(git_hash)
return {
@ -170,9 +170,9 @@ class RetrieveV8Releases(Step):
# The git revision on the branch.
"revision_git": git_hash,
# The cr commit position number on master.
"bleeding_edge": bleeding_edge_rev,
"bleeding_edge": master_position,
# The same for git.
"bleeding_edge_git": bleeding_edge_git,
"bleeding_edge_git": master_hash,
# The branch name.
"branch": branch,
# The version for displaying in the form 3.26.3 or 3.26.3.12.
@ -185,8 +185,8 @@ class RetrieveV8Releases(Step):
"chromium_revision": "",
# Default for easier output formatting.
"chromium_branch": "",
# Link to the CL on code review. Trunk pushes are not uploaded, so this
# field will be populated below with the recent roll CL link.
# Link to the CL on code review. Candiates pushes are not uploaded,
# so this field will be populated below with the recent roll CL link.
"review_link": MatchSafe(REVIEW_LINK_RE.search(cl_body)),
# Link to the commit message on google code.
"revision_link": ("https://code.google.com/p/v8/source/detail?r=%s"
@ -208,13 +208,13 @@ class RetrieveV8Releases(Step):
patches = self.GetMergedPatches(body)
title = self.GitLog(n=1, format="%s", git_hash=git_hash)
bleeding_edge_git = self.GetBleedingEdgeGitFromPush(title)
bleeding_edge_position = ""
if bleeding_edge_git:
bleeding_edge_position = self.GetCommitPositionNumber(bleeding_edge_git)
master_hash = self.GetMasterHashFromPush(title)
master_position = ""
if master_hash:
master_position = self.GetCommitPositionNumber(master_hash)
# TODO(machenbach): Add the commit position number.
return self.GetReleaseDict(
git_hash, bleeding_edge_position, bleeding_edge_git, branch, version,
git_hash, master_position, master_hash, branch, version,
patches, body), self["patch"]
def GetReleasesFromMaster(self):
@ -270,7 +270,7 @@ class RetrieveV8Releases(Step):
branches = self.vc.GetBranches()
releases = []
if self._options.branch == 'recent':
# Get only recent development on trunk, beta and stable.
# Get only recent development on candidates, beta and stable.
if self._options.max_releases == 0: # pragma: no cover
self._options.max_releases = 10
beta, stable = SortBranches(branches)[0:2]
@ -373,7 +373,7 @@ class RetrieveChromiumV8Releases(Step):
# Clean up.
self.GitCheckoutFileSafe("DEPS", "HEAD", cwd=cwd)
# Add the chromium ranges to the v8 trunk and bleeding_edge releases.
# Add the chromium ranges to the v8 candidates and master releases.
all_ranges = BuildRevisionRanges(cr_releases)
releases_dict = dict((r["revision"], r) for r in releases)
for revision, ranges in all_ranges.iteritems():
@ -386,13 +386,13 @@ class RietrieveChromiumBranches(Step):
def RunStep(self):
cwd = self._options.chromium
trunk_releases = filter(lambda r: r["branch"] == self.vc.CandidateBranch(),
self["releases"])
if not trunk_releases: # pragma: no cover
print "No trunk releases detected. Skipping chromium history."
cand_releases = filter(lambda r: r["branch"] == self.vc.CandidateBranch(),
self["releases"])
if not cand_releases: # pragma: no cover
print "No candidates releases detected. Skipping chromium history."
return True
oldest_v8_rev = int(trunk_releases[-1]["revision"])
oldest_v8_rev = int(cand_releases[-1]["revision"])
# Filter out irrelevant branches.
branches = filter(lambda r: re.match(r"branch-heads/\d+", r),
@ -430,11 +430,11 @@ class RietrieveChromiumBranches(Step):
# Clean up.
self.GitCheckoutFileSafe("DEPS", "HEAD", cwd=cwd)
# Add the chromium branches to the v8 trunk releases.
# Add the chromium branches to the v8 candidate releases.
all_ranges = BuildRevisionRanges(cr_branches)
trunk_dict = dict((r["revision"], r) for r in trunk_releases)
cand_dict = dict((r["revision"], r) for r in cand_releases)
for revision, ranges in all_ranges.iteritems():
trunk_dict.get(revision, {})["chromium_branch"] = ranges
cand_dict.get(revision, {})["chromium_branch"] = ranges
class CleanUp(Step):
@ -471,7 +471,8 @@ class Releases(ScriptsBase):
parser.add_argument("-b", "--branch", default="recent",
help=("The branch to analyze. If 'all' is specified, "
"analyze all branches. If 'recent' (default) "
"is specified, track beta, stable and trunk."))
"is specified, track beta, stable and "
"candidates."))
parser.add_argument("-c", "--chromium",
help=("The path to your Chromium src/ "
"directory to automate the V8 roll."))

View File

@ -45,22 +45,19 @@ import chromium_roll
from chromium_roll import ChromiumRoll
import releases
from releases import Releases
import bump_up_version
from bump_up_version import BumpUpVersion
from bump_up_version import LastChangeBailout
from bump_up_version import LKGRVersionUpToDateBailout
from auto_tag import AutoTag
TEST_CONFIG = {
"DEFAULT_CWD": None,
"BRANCHNAME": "test-prepare-push",
"TRUNKBRANCH": "test-trunk-push",
"PERSISTFILE_BASENAME": "/tmp/test-v8-push-to-trunk-tempfile",
"CHANGELOG_ENTRY_FILE": "/tmp/test-v8-push-to-trunk-tempfile-changelog-entry",
"PATCH_FILE": "/tmp/test-v8-push-to-trunk-tempfile-patch",
"COMMITMSG_FILE": "/tmp/test-v8-push-to-trunk-tempfile-commitmsg",
"CHROMIUM": "/tmp/test-v8-push-to-trunk-tempfile-chromium",
"CANDIDATESBRANCH": "test-candidates-push",
"PERSISTFILE_BASENAME": "/tmp/test-v8-push-to-candidates-tempfile",
"CHANGELOG_ENTRY_FILE":
"/tmp/test-v8-push-to-candidates-tempfile-changelog-entry",
"PATCH_FILE": "/tmp/test-v8-push-to-candidates-tempfile-patch",
"COMMITMSG_FILE": "/tmp/test-v8-push-to-candidates-tempfile-commitmsg",
"CHROMIUM": "/tmp/test-v8-push-to-candidates-tempfile-chromium",
"SETTINGS_LOCATION": None,
"ALREADY_MERGING_SENTINEL_FILE":
"/tmp/test-merge-to-branch-tempfile-already-merging",
@ -376,7 +373,7 @@ class ScriptTest(unittest.TestCase):
config=TEST_CONFIG, side_effect_handler=self,
options=options)
def RunStep(self, script=PushToTrunk, step_class=Step, args=None):
def RunStep(self, script=PushToCandidates, step_class=Step, args=None):
"""Convenience wrapper."""
args = args if args is not None else ["-m"]
return script(TEST_CONFIG, self, self._state).RunSteps([step_class], args)
@ -540,7 +537,7 @@ class ScriptTest(unittest.TestCase):
Cmd("git log -1 --format=%H HEAD", "push_hash")
])
self.RunStep(PushToTrunk, PreparePushRevision)
self.RunStep(PushToCandidates, PreparePushRevision)
self.assertEquals("push_hash", self._state["push_hash"])
def testPrepareChangeLog(self):
@ -567,10 +564,10 @@ class ScriptTest(unittest.TestCase):
Cmd("git log -1 --format=%an rev4", "author4@chromium.org"),
])
self._state["last_push_bleeding_edge"] = "1234"
self._state["last_push_master"] = "1234"
self._state["push_hash"] = "push_hash"
self._state["version"] = "3.22.5"
self.RunStep(PushToTrunk, PrepareChangeLog)
self.RunStep(PushToCandidates, PrepareChangeLog)
actual_cl = FileToText(TEST_CONFIG["CHANGELOG_ENTRY_FILE"])
@ -611,7 +608,7 @@ class ScriptTest(unittest.TestCase):
Cmd("vi %s" % TEST_CONFIG["CHANGELOG_ENTRY_FILE"], ""),
])
self.RunStep(PushToTrunk, EditChangeLog)
self.RunStep(PushToCandidates, EditChangeLog)
self.assertEquals("New\n Lines",
FileToText(TEST_CONFIG["CHANGELOG_ENTRY_FILE"]))
@ -633,7 +630,7 @@ test_tag
"", cb=lambda: self.WriteFakeVersionFile(22, 6)),
])
self.RunStep(PushToTrunk, GetLatestVersion)
self.RunStep(PushToCandidates, GetLatestVersion)
self.assertEquals("3", self._state["latest_major"])
self.assertEquals("22", self._state["latest_minor"])
@ -652,7 +649,7 @@ test_tag
self._state["push_hash"] = "hash1"
self._state["date"] = "1999-11-11"
self.RunStep(PushToTrunk, SquashCommits)
self.RunStep(PushToCandidates, SquashCommits)
self.assertEquals(FileToText(TEST_CONFIG["COMMITMSG_FILE"]), expected_msg)
patch = FileToText(TEST_CONFIG["PATCH_FILE"])
@ -706,16 +703,16 @@ Performance and stability improvements on all platforms."""
])
FakeScript(fake_config, self).Run(["--work-dir", work_dir])
def _PushToTrunk(self, force=False, manual=False):
def _PushToCandidates(self, force=False, manual=False):
TextToFile("", os.path.join(TEST_CONFIG["DEFAULT_CWD"], ".git"))
# The version file on bleeding edge has build level 5, while the version
# file from trunk has build level 4.
# The version file on master has build level 5, while the version
# file from candidates has build level 4.
self.WriteFakeVersionFile(build=5)
TEST_CONFIG["CHANGELOG_ENTRY_FILE"] = self.MakeEmptyTempFile()
bleeding_edge_change_log = "2014-03-17: Sentinel\n"
TextToFile(bleeding_edge_change_log,
master_change_log = "2014-03-17: Sentinel\n"
TextToFile(master_change_log,
os.path.join(TEST_CONFIG["DEFAULT_CWD"], CHANGELOG_FILE))
os.environ["EDITOR"] = "vi"
@ -732,15 +729,16 @@ Log text 1 (issue 321).
Performance and stability improvements on all platforms."""
def ResetChangeLog():
"""On 'git co -b new_branch svn/trunk', and 'git checkout -- ChangeLog',
the ChangLog will be reset to its content on trunk."""
trunk_change_log = """1999-04-05: Version 3.22.4
"""On 'git co -b new_branch origin/candidates',
and 'git checkout -- ChangeLog',
the ChangLog will be reset to its content on candidates."""
candidates_change_log = """1999-04-05: Version 3.22.4
Performance and stability improvements on all platforms.\n"""
TextToFile(trunk_change_log,
TextToFile(candidates_change_log,
os.path.join(TEST_CONFIG["DEFAULT_CWD"], CHANGELOG_FILE))
def ResetToTrunk():
def ResetToCandidates():
ResetChangeLog()
self.WriteFakeVersionFile()
@ -755,7 +753,8 @@ Performance and stability improvements on all platforms."""
self.assertTrue(re.search(r"#define PATCH_LEVEL\s+0", version))
self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version))
# Check that the change log on the trunk branch got correctly modified.
# Check that the change log on the candidates branch got correctly
# modified.
change_log = FileToText(
os.path.join(TEST_CONFIG["DEFAULT_CWD"], CHANGELOG_FILE))
self.assertEquals(
@ -813,7 +812,7 @@ Performance and stability improvements on all platforms."""
Cmd("git checkout -f origin/master", ""),
Cmd("git diff origin/candidates push_hash", "patch content\n"),
Cmd(("git new-branch %s --upstream origin/candidates" %
TEST_CONFIG["TRUNKBRANCH"]), "", cb=ResetToTrunk),
TEST_CONFIG["CANDIDATESBRANCH"]), "", cb=ResetToCandidates),
Cmd("git apply --index --reject \"%s\"" % TEST_CONFIG["PATCH_FILE"], ""),
Cmd("git checkout -f origin/candidates -- ChangeLog", "",
cb=ResetChangeLog),
@ -827,9 +826,9 @@ Performance and stability improvements on all platforms."""
Cmd("git cl land -f --bypass-hooks", ""),
Cmd("git checkout -f master", ""),
Cmd("git fetch", ""),
Cmd("git branch -D %s" % TEST_CONFIG["TRUNKBRANCH"], ""),
Cmd("git branch -D %s" % TEST_CONFIG["CANDIDATESBRANCH"], ""),
Cmd(("git new-branch %s --upstream origin/candidates" %
TEST_CONFIG["TRUNKBRANCH"]), "", cb=ResetToTrunk),
TEST_CONFIG["CANDIDATESBRANCH"]), "", cb=ResetToCandidates),
Cmd("git commit -aF \"%s\"" % TEST_CONFIG["COMMITMSG_FILE"], "",
cb=CheckVersionCommit),
Cmd("git cl land -f --bypass-hooks", ""),
@ -841,7 +840,7 @@ Performance and stability improvements on all platforms."""
Cmd("git push origin 3.22.5", ""),
Cmd("git checkout -f some_branch", ""),
Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], ""),
Cmd("git branch -D %s" % TEST_CONFIG["TRUNKBRANCH"], ""),
Cmd("git branch -D %s" % TEST_CONFIG["CANDIDATESBRANCH"], ""),
]
self.Expect(expectations)
@ -849,7 +848,7 @@ Performance and stability improvements on all platforms."""
if force: args.append("-f")
if manual: args.append("-m")
else: args += ["-r", "reviewer@chromium.org"]
PushToTrunk(TEST_CONFIG, self).Run(args)
PushToCandidates(TEST_CONFIG, self).Run(args)
cl = FileToText(os.path.join(TEST_CONFIG["DEFAULT_CWD"], CHANGELOG_FILE))
self.assertTrue(re.search(r"^\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl))
@ -857,17 +856,16 @@ Performance and stability improvements on all platforms."""
self.assertTrue(re.search(r"1999\-04\-05: Version 3\.22\.4", cl))
# Note: The version file is on build number 5 again in the end of this test
# since the git command that merges to the bleeding edge branch is mocked
# out.
# since the git command that merges to master is mocked out.
def testPushToTrunkManual(self):
self._PushToTrunk(manual=True)
def testPushToCandidatesManual(self):
self._PushToCandidates(manual=True)
def testPushToTrunkSemiAutomatic(self):
self._PushToTrunk()
def testPushToCandidatesSemiAutomatic(self):
self._PushToCandidates()
def testPushToTrunkForced(self):
self._PushToTrunk(force=True)
def testPushToCandidatesForced(self):
self._PushToCandidates(force=True)
C_V8_22624_LOG = """V8 CL.
@ -959,14 +957,11 @@ def get_list():
def testAutoPush(self):
TextToFile("", os.path.join(TEST_CONFIG["DEFAULT_CWD"], ".git"))
TEST_CONFIG["SETTINGS_LOCATION"] = "~/.doesnotexist"
self.Expect([
Cmd("git status -s -uno", ""),
Cmd("git status -s -b -uno", "## some_branch\n"),
Cmd("git fetch", ""),
URL("https://v8-status.appspot.com/current?format=json",
"{\"message\": \"Tree is throttled\"}"),
Cmd("git fetch origin +refs/heads/candidate:refs/heads/candidate", ""),
Cmd("git show-ref -s refs/heads/candidate", "abc123\n"),
Cmd(("git log -1 --format=%H --grep=\""
@ -983,38 +978,6 @@ def get_list():
self.assertEquals("abc123", state["candidate"])
def testAutoPushStoppedBySettings(self):
TextToFile("", os.path.join(TEST_CONFIG["DEFAULT_CWD"], ".git"))
TEST_CONFIG["SETTINGS_LOCATION"] = self.MakeEmptyTempFile()
TextToFile("{\"enable_auto_push\": false}",
TEST_CONFIG["SETTINGS_LOCATION"])
self.Expect([
Cmd("git status -s -uno", ""),
Cmd("git status -s -b -uno", "## some_branch\n"),
Cmd("git fetch", ""),
])
def RunAutoPush():
auto_push.AutoPush(TEST_CONFIG, self).Run(AUTO_PUSH_ARGS)
self.assertRaises(Exception, RunAutoPush)
def testAutoPushStoppedByTreeStatus(self):
TextToFile("", os.path.join(TEST_CONFIG["DEFAULT_CWD"], ".git"))
TEST_CONFIG["SETTINGS_LOCATION"] = "~/.doesnotexist"
self.Expect([
Cmd("git status -s -uno", ""),
Cmd("git status -s -b -uno", "## some_branch\n"),
Cmd("git fetch", ""),
URL("https://v8-status.appspot.com/current?format=json",
"{\"message\": \"Tree is throttled (no push)\"}"),
])
def RunAutoPush():
auto_push.AutoPush(TEST_CONFIG, self).Run(AUTO_PUSH_ARGS)
self.assertRaises(Exception, RunAutoPush)
def testAutoRollExistingRoll(self):
self.Expect([
URL("https://codereview.chromium.org/search",
@ -1113,7 +1076,7 @@ BUG=123,234,345,456,567,v8:123
LOG=N
"""
def VerifySVNCommit():
def VerifyLand():
commit = FileToText(TEST_CONFIG["COMMITMSG_FILE"])
self.assertEquals(msg, commit)
version = FileToText(
@ -1186,7 +1149,7 @@ LOG=N
RL("LGTM"), # Enter LGTM for V8 CL.
Cmd("git cl presubmit", "Presubmit successfull\n"),
Cmd("git cl land -f --bypass-hooks", "Closing issue\n",
cb=VerifySVNCommit),
cb=VerifyLand),
Cmd("git fetch", ""),
Cmd("git log -1 --format=%H --grep=\""
"Version 3.22.5.1 (cherry-pick)"
@ -1411,95 +1374,6 @@ Cr-Commit-Position: refs/heads/candidates@{#345}
self.assertEquals(expected_json, json.loads(FileToText(json_output)))
def _bumpUpVersion(self):
self.WriteFakeVersionFile()
def ResetVersion(minor, build, patch=0):
return lambda: self.WriteFakeVersionFile(minor=minor,
build=build,
patch=patch)
return [
Cmd("git status -s -uno", ""),
Cmd("git checkout -f master", "", cb=ResetVersion(11, 4)),
Cmd("git pull", ""),
Cmd("git branch", ""),
Cmd("git checkout -f master", ""),
Cmd("git log -1 --format=%H", "latest_hash"),
Cmd("git diff --name-only latest_hash latest_hash^", ""),
URL("https://v8-status.appspot.com/lkgr", "12345"),
Cmd("git checkout -f master", ""),
Cmd(("git log --format=%H --grep="
"\"^git-svn-id: [^@]*@12345 [A-Za-z0-9-]*$\""),
"lkgr_hash"),
Cmd("git new-branch auto-bump-up-version --upstream lkgr_hash", ""),
Cmd("git checkout -f master", ""),
Cmd("git branch", "auto-bump-up-version\n* master"),
Cmd("git branch -D auto-bump-up-version", ""),
Cmd("git diff --name-only lkgr_hash lkgr_hash^", ""),
Cmd("git checkout -f candidates", "", cb=ResetVersion(11, 5)),
Cmd("git pull", ""),
URL("https://v8-status.appspot.com/current?format=json",
"{\"message\": \"Tree is open\"}"),
Cmd("git new-branch auto-bump-up-version --upstream master", "",
cb=ResetVersion(11, 4)),
Cmd("git commit -am \"[Auto-roll] Bump up version to 3.11.6.0\n\n"
"TBR=author@chromium.org\" "
"--author \"author@chromium.org <author@chromium.org>\"", ""),
]
def testBumpUpVersionGit(self):
expectations = self._bumpUpVersion()
expectations += [
Cmd("git cl upload --send-mail --email \"author@chromium.org\" -f "
"--bypass-hooks", ""),
Cmd("git cl land -f --bypass-hooks", ""),
Cmd("git checkout -f master", ""),
Cmd("git branch", "auto-bump-up-version\n* master"),
Cmd("git branch -D auto-bump-up-version", ""),
]
self.Expect(expectations)
BumpUpVersion(TEST_CONFIG, self).Run(["-a", "author@chromium.org"])
# Test that we bail out if the last change was a version change.
def testBumpUpVersionBailout1(self):
self._state["latest"] = "latest_hash"
self.Expect([
Cmd("git diff --name-only latest_hash latest_hash^", VERSION_FILE),
])
self.assertEquals(0,
self.RunStep(BumpUpVersion, LastChangeBailout, ["--dry_run"]))
# Test that we bail out if the lkgr was a version change.
def testBumpUpVersionBailout2(self):
self._state["lkgr"] = "lkgr_hash"
self.Expect([
Cmd("git diff --name-only lkgr_hash lkgr_hash^", VERSION_FILE),
])
self.assertEquals(0,
self.RunStep(BumpUpVersion, LKGRVersionUpToDateBailout, ["--dry_run"]))
# Test that we bail out if the last version is already newer than the lkgr's
# version.
def testBumpUpVersionBailout3(self):
self._state["lkgr"] = "lkgr_hash"
self._state["lkgr_version"] = "3.22.4.0"
self._state["latest_version"] = "3.22.5.0"
self.Expect([
Cmd("git diff --name-only lkgr_hash lkgr_hash^", ""),
])
self.assertEquals(0,
self.RunStep(BumpUpVersion, LKGRVersionUpToDateBailout, ["--dry_run"]))
class SystemTest(unittest.TestCase):
def testReload(self):
options = ScriptsBase(