2014-04-09 14:30:02 +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.
|
|
|
|
|
2015-01-26 13:29:23 +00:00
|
|
|
# This script retrieves the history of all V8 branches and
|
2014-04-09 14:30:02 +00:00
|
|
|
# their corresponding Chromium revisions.
|
|
|
|
|
2014-04-25 11:33:19 +00:00
|
|
|
# Requires a chromium checkout with branch heads:
|
|
|
|
# gclient sync --with_branch_heads
|
|
|
|
# gclient fetch
|
|
|
|
|
2014-04-09 14:30:02 +00:00
|
|
|
import argparse
|
|
|
|
import csv
|
|
|
|
import itertools
|
|
|
|
import json
|
|
|
|
import os
|
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
|
|
|
|
from common_includes import *
|
|
|
|
|
|
|
|
CONFIG = {
|
2014-09-23 14:41:36 +00:00
|
|
|
"BRANCHNAME": "retrieve-v8-releases",
|
|
|
|
"PERSISTFILE_BASENAME": "/tmp/v8-releases-tempfile",
|
2014-04-09 14:30:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Expression for retrieving the bleeding edge revision from a commit message.
|
2014-10-30 15:05:11 +00:00
|
|
|
PUSH_MSG_SVN_RE = re.compile(r".* \(based on bleeding_edge revision r(\d+)\)$")
|
|
|
|
PUSH_MSG_GIT_RE = re.compile(r".* \(based on ([a-fA-F0-9]+)\)$")
|
2014-04-09 14:30:02 +00:00
|
|
|
|
|
|
|
# Expression for retrieving the merged patches from a merge commit message
|
|
|
|
# (old and new format).
|
|
|
|
MERGE_MESSAGE_RE = re.compile(r"^.*[M|m]erged (.+)(\)| into).*$", re.M)
|
|
|
|
|
2014-11-05 13:30:50 +00:00
|
|
|
CHERRY_PICK_TITLE_GIT_RE = re.compile(r"^.* \(cherry\-pick\)\.?$")
|
|
|
|
|
|
|
|
# New git message for cherry-picked CLs. One message per line.
|
|
|
|
MERGE_MESSAGE_GIT_RE = re.compile(r"^Merged ([a-fA-F0-9]+)\.?$")
|
|
|
|
|
2014-04-09 14:30:02 +00:00
|
|
|
# Expression for retrieving reverted patches from a commit message (old and
|
|
|
|
# new format).
|
|
|
|
ROLLBACK_MESSAGE_RE = re.compile(r"^.*[R|r]ollback of (.+)(\)| in).*$", re.M)
|
|
|
|
|
2014-11-05 13:30:50 +00:00
|
|
|
# New git message for reverted CLs. One message per line.
|
|
|
|
ROLLBACK_MESSAGE_GIT_RE = re.compile(r"^Rollback of ([a-fA-F0-9]+)\.?$")
|
|
|
|
|
2014-04-14 10:32:00 +00:00
|
|
|
# Expression for retrieving the code review link.
|
|
|
|
REVIEW_LINK_RE = re.compile(r"^Review URL: (.+)$", re.M)
|
|
|
|
|
2014-04-09 14:30:02 +00:00
|
|
|
# Expression with three versions (historical) for extracting the v8 revision
|
|
|
|
# from the chromium DEPS file.
|
2014-08-25 13:39:43 +00:00
|
|
|
DEPS_RE = re.compile(r"""^\s*(?:["']v8_revision["']: ["']"""
|
|
|
|
"""|\(Var\("googlecode_url"\) % "v8"\) \+ "\/trunk@"""
|
|
|
|
"""|"http\:\/\/v8\.googlecode\.com\/svn\/trunk@)"""
|
|
|
|
"""([^"']+)["'].*$""", re.M)
|
2014-04-09 14:30:02 +00:00
|
|
|
|
2014-07-28 13:49:07 +00:00
|
|
|
# Expression to pick tag and revision for bleeding edge tags. To be used with
|
|
|
|
# output of 'svn log'.
|
|
|
|
BLEEDING_EDGE_TAGS_RE = re.compile(
|
|
|
|
r"A \/tags\/([^\s]+) \(from \/branches\/bleeding_edge\:(\d+)\)")
|
|
|
|
|
2015-04-16 12:51:51 +00:00
|
|
|
OMAHA_PROXY_URL = "http://omahaproxy.appspot.com/"
|
2014-04-09 14:30:02 +00:00
|
|
|
|
|
|
|
def SortBranches(branches):
|
|
|
|
"""Sort branches with version number names."""
|
|
|
|
return sorted(branches, key=SortingKey, reverse=True)
|
|
|
|
|
|
|
|
|
|
|
|
def FilterDuplicatesAndReverse(cr_releases):
|
|
|
|
"""Returns the chromium releases in reverse order filtered by v8 revision
|
|
|
|
duplicates.
|
|
|
|
|
2015-02-16 17:00:44 +00:00
|
|
|
cr_releases is a list of [cr_rev, v8_hsh] reverse-sorted by cr_rev.
|
2014-04-09 14:30:02 +00:00
|
|
|
"""
|
|
|
|
last = ""
|
|
|
|
result = []
|
|
|
|
for release in reversed(cr_releases):
|
|
|
|
if last == release[1]:
|
|
|
|
continue
|
|
|
|
last = release[1]
|
|
|
|
result.append(release)
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
def BuildRevisionRanges(cr_releases):
|
|
|
|
"""Returns a mapping of v8 revision -> chromium ranges.
|
|
|
|
The ranges are comma-separated, each range has the form R1:R2. The newest
|
|
|
|
entry is the only one of the form R1, as there is no end range.
|
|
|
|
|
2015-02-16 17:00:44 +00:00
|
|
|
cr_releases is a list of [cr_rev, v8_hsh] reverse-sorted by cr_rev.
|
|
|
|
cr_rev either refers to a chromium commit position or a chromium branch
|
|
|
|
number.
|
2014-04-09 14:30:02 +00:00
|
|
|
"""
|
|
|
|
range_lists = {}
|
|
|
|
cr_releases = FilterDuplicatesAndReverse(cr_releases)
|
|
|
|
|
|
|
|
# Visit pairs of cr releases from oldest to newest.
|
|
|
|
for cr_from, cr_to in itertools.izip(
|
|
|
|
cr_releases, itertools.islice(cr_releases, 1, None)):
|
|
|
|
|
|
|
|
# Assume the chromium revisions are all different.
|
|
|
|
assert cr_from[0] != cr_to[0]
|
|
|
|
|
|
|
|
ran = "%s:%d" % (cr_from[0], int(cr_to[0]) - 1)
|
|
|
|
|
|
|
|
# Collect the ranges in lists per revision.
|
|
|
|
range_lists.setdefault(cr_from[1], []).append(ran)
|
|
|
|
|
|
|
|
# Add the newest revision.
|
|
|
|
if cr_releases:
|
|
|
|
range_lists.setdefault(cr_releases[-1][1], []).append(cr_releases[-1][0])
|
|
|
|
|
|
|
|
# Stringify and comma-separate the range lists.
|
2015-02-16 17:00:44 +00:00
|
|
|
return dict((hsh, ", ".join(ran)) for hsh, ran in range_lists.iteritems())
|
2014-04-09 14:30:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
def MatchSafe(match):
|
|
|
|
if match:
|
|
|
|
return match.group(1)
|
|
|
|
else:
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
|
|
class Preparation(Step):
|
|
|
|
MESSAGE = "Preparation."
|
|
|
|
|
|
|
|
def RunStep(self):
|
|
|
|
self.CommonPrepare()
|
|
|
|
self.PrepareBranch()
|
|
|
|
|
|
|
|
|
|
|
|
class RetrieveV8Releases(Step):
|
|
|
|
MESSAGE = "Retrieve all V8 releases."
|
|
|
|
|
|
|
|
def ExceedsMax(self, releases):
|
|
|
|
return (self._options.max_releases > 0
|
|
|
|
and len(releases) > self._options.max_releases)
|
|
|
|
|
2015-01-26 13:29:23 +00:00
|
|
|
def GetMasterHashFromPush(self, title):
|
2014-10-30 15:05:11 +00:00
|
|
|
return MatchSafe(PUSH_MSG_GIT_RE.match(title))
|
2014-04-09 14:30:02 +00:00
|
|
|
|
2014-04-14 10:32:00 +00:00
|
|
|
def GetMergedPatches(self, body):
|
2014-04-09 14:30:02 +00:00
|
|
|
patches = MatchSafe(MERGE_MESSAGE_RE.search(body))
|
|
|
|
if not patches:
|
|
|
|
patches = MatchSafe(ROLLBACK_MESSAGE_RE.search(body))
|
|
|
|
if patches:
|
|
|
|
# Indicate reverted patches with a "-".
|
|
|
|
patches = "-%s" % patches
|
|
|
|
return patches
|
|
|
|
|
2014-11-05 13:30:50 +00:00
|
|
|
def GetMergedPatchesGit(self, body):
|
|
|
|
patches = []
|
|
|
|
for line in body.splitlines():
|
|
|
|
patch = MatchSafe(MERGE_MESSAGE_GIT_RE.match(line))
|
|
|
|
if patch:
|
|
|
|
patches.append(patch)
|
|
|
|
patch = MatchSafe(ROLLBACK_MESSAGE_GIT_RE.match(line))
|
|
|
|
if patch:
|
|
|
|
patches.append("-%s" % patch)
|
|
|
|
return ", ".join(patches)
|
|
|
|
|
|
|
|
|
2014-07-28 13:49:07 +00:00
|
|
|
def GetReleaseDict(
|
2015-01-26 13:29:23 +00:00
|
|
|
self, git_hash, master_position, master_hash, branch, version,
|
2014-10-16 13:21:13 +00:00
|
|
|
patches, cl_body):
|
2014-11-12 17:54:11 +00:00
|
|
|
revision = self.GetCommitPositionNumber(git_hash)
|
2014-04-09 14:30:02 +00:00
|
|
|
return {
|
2014-11-12 17:54:11 +00:00
|
|
|
# The cr commit position number on the branch.
|
2014-04-14 10:32:00 +00:00
|
|
|
"revision": revision,
|
2014-10-16 13:21:13 +00:00
|
|
|
# The git revision on the branch.
|
|
|
|
"revision_git": git_hash,
|
2014-11-12 17:54:11 +00:00
|
|
|
# The cr commit position number on master.
|
2015-01-26 14:20:59 +00:00
|
|
|
"master_position": master_position,
|
2014-10-16 13:21:13 +00:00
|
|
|
# The same for git.
|
2015-01-26 14:20:59 +00:00
|
|
|
"master_hash": master_hash,
|
2014-04-09 14:30:02 +00:00
|
|
|
# The branch name.
|
|
|
|
"branch": branch,
|
|
|
|
# The version for displaying in the form 3.26.3 or 3.26.3.12.
|
|
|
|
"version": version,
|
2014-04-15 12:00:53 +00:00
|
|
|
# The date of the commit.
|
|
|
|
"date": self.GitLog(n=1, format="%ci", git_hash=git_hash),
|
2014-04-09 14:30:02 +00:00
|
|
|
# Merged patches if available in the form 'r1234, r2345'.
|
|
|
|
"patches_merged": patches,
|
2014-04-11 07:40:48 +00:00
|
|
|
# Default for easier output formatting.
|
|
|
|
"chromium_revision": "",
|
2014-04-25 11:33:19 +00:00
|
|
|
# Default for easier output formatting.
|
|
|
|
"chromium_branch": "",
|
2015-01-26 13:29:23 +00:00
|
|
|
# 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.
|
2014-07-28 13:49:07 +00:00
|
|
|
"review_link": MatchSafe(REVIEW_LINK_RE.search(cl_body)),
|
2014-04-14 10:32:00 +00:00
|
|
|
# Link to the commit message on google code.
|
|
|
|
"revision_link": ("https://code.google.com/p/v8/source/detail?r=%s"
|
|
|
|
% revision),
|
2014-07-28 13:49:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
def GetRelease(self, git_hash, branch):
|
|
|
|
self.ReadAndPersistVersion()
|
|
|
|
base_version = [self["major"], self["minor"], self["build"]]
|
|
|
|
version = ".".join(base_version)
|
|
|
|
body = self.GitLog(n=1, format="%B", git_hash=git_hash)
|
|
|
|
|
|
|
|
patches = ""
|
|
|
|
if self["patch"] != "0":
|
|
|
|
version += ".%s" % self["patch"]
|
2014-11-05 13:30:50 +00:00
|
|
|
if CHERRY_PICK_TITLE_GIT_RE.match(body.splitlines()[0]):
|
|
|
|
patches = self.GetMergedPatchesGit(body)
|
|
|
|
else:
|
|
|
|
patches = self.GetMergedPatches(body)
|
2014-07-28 13:49:07 +00:00
|
|
|
|
2015-02-16 17:00:44 +00:00
|
|
|
if SortingKey("4.2.69") <= SortingKey(version):
|
|
|
|
master_hash = self.GetLatestReleaseBase(version=version)
|
|
|
|
else:
|
|
|
|
# Legacy: Before version 4.2.69, the master revision was determined
|
|
|
|
# by commit message.
|
|
|
|
title = self.GitLog(n=1, format="%s", git_hash=git_hash)
|
|
|
|
master_hash = self.GetMasterHashFromPush(title)
|
2015-01-26 13:29:23 +00:00
|
|
|
master_position = ""
|
|
|
|
if master_hash:
|
|
|
|
master_position = self.GetCommitPositionNumber(master_hash)
|
2014-07-28 13:49:07 +00:00
|
|
|
return self.GetReleaseDict(
|
2015-01-26 13:29:23 +00:00
|
|
|
git_hash, master_position, master_hash, branch, version,
|
2014-07-28 13:49:07 +00:00
|
|
|
patches, body), self["patch"]
|
|
|
|
|
2014-04-09 14:30:02 +00:00
|
|
|
def GetReleasesFromBranch(self, branch):
|
2014-09-25 13:25:14 +00:00
|
|
|
self.GitReset(self.vc.RemoteBranch(branch))
|
2014-10-13 12:34:53 +00:00
|
|
|
if branch == self.vc.MasterBranch():
|
|
|
|
return self.GetReleasesFromMaster()
|
2014-07-28 13:49:07 +00:00
|
|
|
|
2014-04-09 14:30:02 +00:00
|
|
|
releases = []
|
|
|
|
try:
|
|
|
|
for git_hash in self.GitLog(format="%H").splitlines():
|
2014-09-23 09:35:49 +00:00
|
|
|
if VERSION_FILE not in self.GitChangedFiles(git_hash):
|
2014-04-09 14:30:02 +00:00
|
|
|
continue
|
|
|
|
if self.ExceedsMax(releases):
|
|
|
|
break # pragma: no cover
|
2014-09-23 09:35:49 +00:00
|
|
|
if not self.GitCheckoutFileSafe(VERSION_FILE, git_hash):
|
2014-04-09 14:30:02 +00:00
|
|
|
break # pragma: no cover
|
|
|
|
|
|
|
|
release, patch_level = self.GetRelease(git_hash, branch)
|
|
|
|
releases.append(release)
|
|
|
|
|
|
|
|
# Follow branches only until their creation point.
|
|
|
|
# TODO(machenbach): This omits patches if the version file wasn't
|
|
|
|
# manipulated correctly. Find a better way to detect the point where
|
|
|
|
# the parent of the branch head leads to the trunk branch.
|
2014-10-13 12:34:53 +00:00
|
|
|
if branch != self.vc.CandidateBranch() and patch_level == "0":
|
2014-04-09 14:30:02 +00:00
|
|
|
break
|
|
|
|
|
|
|
|
# Allow Ctrl-C interrupt.
|
|
|
|
except (KeyboardInterrupt, SystemExit): # pragma: no cover
|
|
|
|
pass
|
|
|
|
|
|
|
|
# Clean up checked-out version file.
|
2014-09-23 09:35:49 +00:00
|
|
|
self.GitCheckoutFileSafe(VERSION_FILE, "HEAD")
|
2014-04-09 14:30:02 +00:00
|
|
|
return releases
|
|
|
|
|
2015-01-29 14:21:31 +00:00
|
|
|
def GetReleaseFromRevision(self, revision):
|
|
|
|
releases = []
|
|
|
|
try:
|
|
|
|
if (VERSION_FILE not in self.GitChangedFiles(revision) or
|
|
|
|
not self.GitCheckoutFileSafe(VERSION_FILE, revision)):
|
|
|
|
print "Skipping revision %s" % revision
|
|
|
|
return [] # pragma: no cover
|
|
|
|
|
|
|
|
branches = map(
|
|
|
|
str.strip,
|
|
|
|
self.Git("branch -r --contains %s" % revision).strip().splitlines(),
|
|
|
|
)
|
|
|
|
branch = ""
|
|
|
|
for b in branches:
|
2015-02-16 17:00:44 +00:00
|
|
|
if b.startswith("origin/"):
|
|
|
|
branch = b.split("origin/")[1]
|
2015-01-29 14:21:31 +00:00
|
|
|
break
|
|
|
|
if b.startswith("branch-heads/"):
|
|
|
|
branch = b.split("branch-heads/")[1]
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
print "Could not determine branch for %s" % revision
|
|
|
|
|
|
|
|
release, _ = self.GetRelease(revision, branch)
|
|
|
|
releases.append(release)
|
|
|
|
|
|
|
|
# Allow Ctrl-C interrupt.
|
|
|
|
except (KeyboardInterrupt, SystemExit): # pragma: no cover
|
|
|
|
pass
|
|
|
|
|
|
|
|
# Clean up checked-out version file.
|
|
|
|
self.GitCheckoutFileSafe(VERSION_FILE, "HEAD")
|
|
|
|
return releases
|
|
|
|
|
|
|
|
|
2014-04-09 14:30:02 +00:00
|
|
|
def RunStep(self):
|
2014-09-23 14:41:36 +00:00
|
|
|
self.GitCreateBranch(self._config["BRANCHNAME"])
|
2014-04-09 14:30:02 +00:00
|
|
|
releases = []
|
|
|
|
if self._options.branch == 'recent':
|
2015-01-29 14:21:31 +00:00
|
|
|
# List every release from the last 7 days.
|
2015-03-05 10:50:00 +00:00
|
|
|
revisions = self.GetRecentReleases(max_age=7 * DAY_IN_SECONDS)
|
2015-01-29 14:21:31 +00:00
|
|
|
for revision in revisions:
|
|
|
|
releases += self.GetReleaseFromRevision(revision)
|
2014-04-09 14:30:02 +00:00
|
|
|
elif self._options.branch == 'all': # pragma: no cover
|
|
|
|
# Retrieve the full release history.
|
2015-01-29 14:21:31 +00:00
|
|
|
for branch in self.vc.GetBranches():
|
2014-04-09 14:30:02 +00:00
|
|
|
releases += self.GetReleasesFromBranch(branch)
|
2014-10-13 12:34:53 +00:00
|
|
|
releases += self.GetReleasesFromBranch(self.vc.CandidateBranch())
|
|
|
|
releases += self.GetReleasesFromBranch(self.vc.MasterBranch())
|
2014-04-09 14:30:02 +00:00
|
|
|
else: # pragma: no cover
|
|
|
|
# Retrieve history for a specified branch.
|
2015-01-29 14:21:31 +00:00
|
|
|
assert self._options.branch in (self.vc.GetBranches() +
|
2014-10-13 12:34:53 +00:00
|
|
|
[self.vc.CandidateBranch(), self.vc.MasterBranch()])
|
2014-04-09 14:30:02 +00:00
|
|
|
releases += self.GetReleasesFromBranch(self._options.branch)
|
|
|
|
|
|
|
|
self["releases"] = sorted(releases,
|
|
|
|
key=lambda r: SortingKey(r["version"]),
|
|
|
|
reverse=True)
|
|
|
|
|
|
|
|
|
|
|
|
class UpdateChromiumCheckout(Step):
|
2015-04-07 19:42:32 +00:00
|
|
|
MESSAGE = "Update the chromium checkout."
|
2014-04-09 14:30:02 +00:00
|
|
|
|
|
|
|
def RunStep(self):
|
2014-09-05 09:19:48 +00:00
|
|
|
cwd = self._options.chromium
|
2015-04-07 19:42:32 +00:00
|
|
|
self.GitFetchOrigin("+refs/heads/*:refs/remotes/origin/*",
|
|
|
|
"+refs/branch-heads/*:refs/remotes/branch-heads/*",
|
|
|
|
cwd=cwd)
|
|
|
|
# Update v8 checkout in chromium.
|
|
|
|
self.GitFetchOrigin(cwd=os.path.join(cwd, "v8"))
|
2014-04-09 14:30:02 +00:00
|
|
|
|
|
|
|
|
2014-08-25 13:39:43 +00:00
|
|
|
def ConvertToCommitNumber(step, revision):
|
|
|
|
# Simple check for git hashes.
|
|
|
|
if revision.isdigit() and len(revision) < 8:
|
|
|
|
return revision
|
2014-11-14 08:38:57 +00:00
|
|
|
return step.GetCommitPositionNumber(
|
2014-09-05 09:19:48 +00:00
|
|
|
revision, cwd=os.path.join(step._options.chromium, "v8"))
|
2014-08-25 13:39:43 +00:00
|
|
|
|
|
|
|
|
2014-04-09 14:30:02 +00:00
|
|
|
class RetrieveChromiumV8Releases(Step):
|
|
|
|
MESSAGE = "Retrieve V8 releases from Chromium DEPS."
|
|
|
|
|
|
|
|
def RunStep(self):
|
2014-09-05 09:19:48 +00:00
|
|
|
cwd = self._options.chromium
|
2014-04-09 14:30:02 +00:00
|
|
|
|
2015-02-16 17:00:44 +00:00
|
|
|
# All v8 revisions we are interested in.
|
|
|
|
releases_dict = dict((r["revision_git"], r) for r in self["releases"])
|
2014-04-09 14:30:02 +00:00
|
|
|
|
|
|
|
cr_releases = []
|
2015-04-07 11:28:18 +00:00
|
|
|
count_past_last_v8 = 0
|
2014-04-09 14:30:02 +00:00
|
|
|
try:
|
2014-09-05 09:19:48 +00:00
|
|
|
for git_hash in self.GitLog(
|
2015-04-07 19:42:32 +00:00
|
|
|
format="%H", grep="V8", branch="origin/master",
|
|
|
|
path="DEPS", cwd=cwd).splitlines():
|
|
|
|
deps = self.GitShowFile(git_hash, "DEPS", cwd=cwd)
|
2014-04-09 14:30:02 +00:00
|
|
|
match = DEPS_RE.search(deps)
|
|
|
|
if match:
|
2014-09-05 09:19:48 +00:00
|
|
|
cr_rev = self.GetCommitPositionNumber(git_hash, cwd=cwd)
|
2014-08-22 14:30:37 +00:00
|
|
|
if cr_rev:
|
2015-02-16 17:00:44 +00:00
|
|
|
v8_hsh = match.group(1)
|
|
|
|
cr_releases.append([cr_rev, v8_hsh])
|
2014-04-09 14:30:02 +00:00
|
|
|
|
2015-04-07 11:28:18 +00:00
|
|
|
if count_past_last_v8:
|
|
|
|
count_past_last_v8 += 1 # pragma: no cover
|
|
|
|
|
2015-04-07 19:42:32 +00:00
|
|
|
if count_past_last_v8 > 20:
|
2015-04-07 11:28:18 +00:00
|
|
|
break # pragma: no cover
|
|
|
|
|
2015-02-16 17:00:44 +00:00
|
|
|
# Stop as soon as we find a v8 revision that we didn't fetch in the
|
|
|
|
# v8-revision-retrieval part above (i.e. a revision that's too old).
|
2015-04-07 11:28:18 +00:00
|
|
|
# Just iterate a few more times in case there were reverts.
|
2015-02-16 17:00:44 +00:00
|
|
|
if v8_hsh not in releases_dict:
|
2015-04-07 11:28:18 +00:00
|
|
|
count_past_last_v8 += 1 # pragma: no cover
|
2014-04-09 14:30:02 +00:00
|
|
|
|
|
|
|
# Allow Ctrl-C interrupt.
|
|
|
|
except (KeyboardInterrupt, SystemExit): # pragma: no cover
|
|
|
|
pass
|
|
|
|
|
2015-01-26 13:29:23 +00:00
|
|
|
# Add the chromium ranges to the v8 candidates and master releases.
|
2014-04-09 14:30:02 +00:00
|
|
|
all_ranges = BuildRevisionRanges(cr_releases)
|
2015-02-16 17:00:44 +00:00
|
|
|
|
|
|
|
for hsh, ranges in all_ranges.iteritems():
|
|
|
|
releases_dict.get(hsh, {})["chromium_revision"] = ranges
|
2014-04-09 14:30:02 +00:00
|
|
|
|
2014-04-25 11:33:19 +00:00
|
|
|
|
|
|
|
# TODO(machenbach): Unify common code with method above.
|
2015-04-15 12:25:28 +00:00
|
|
|
class RetrieveChromiumBranches(Step):
|
2014-04-25 11:33:19 +00:00
|
|
|
MESSAGE = "Retrieve Chromium branch information."
|
|
|
|
|
|
|
|
def RunStep(self):
|
2014-09-05 09:19:48 +00:00
|
|
|
cwd = self._options.chromium
|
2014-04-25 11:33:19 +00:00
|
|
|
|
2015-02-16 17:00:44 +00:00
|
|
|
# All v8 revisions we are interested in.
|
|
|
|
releases_dict = dict((r["revision_git"], r) for r in self["releases"])
|
2014-04-25 11:33:19 +00:00
|
|
|
|
|
|
|
# Filter out irrelevant branches.
|
|
|
|
branches = filter(lambda r: re.match(r"branch-heads/\d+", r),
|
2014-09-05 09:19:48 +00:00
|
|
|
self.GitRemotes(cwd=cwd))
|
2014-04-25 11:33:19 +00:00
|
|
|
|
|
|
|
# Transform into pure branch numbers.
|
|
|
|
branches = map(lambda r: int(re.match(r"branch-heads/(\d+)", r).group(1)),
|
|
|
|
branches)
|
|
|
|
|
|
|
|
branches = sorted(branches, reverse=True)
|
|
|
|
|
|
|
|
cr_branches = []
|
2015-04-07 11:28:18 +00:00
|
|
|
count_past_last_v8 = 0
|
2014-04-25 11:33:19 +00:00
|
|
|
try:
|
|
|
|
for branch in branches:
|
2015-04-07 19:42:32 +00:00
|
|
|
deps = self.GitShowFile(
|
|
|
|
"refs/branch-heads/%d" % branch, "DEPS", cwd=cwd)
|
2014-04-25 11:33:19 +00:00
|
|
|
match = DEPS_RE.search(deps)
|
|
|
|
if match:
|
2015-02-16 17:00:44 +00:00
|
|
|
v8_hsh = match.group(1)
|
|
|
|
cr_branches.append([str(branch), v8_hsh])
|
2014-04-25 11:33:19 +00:00
|
|
|
|
2015-04-07 11:28:18 +00:00
|
|
|
if count_past_last_v8:
|
|
|
|
count_past_last_v8 += 1 # pragma: no cover
|
|
|
|
|
2015-04-07 19:42:32 +00:00
|
|
|
if count_past_last_v8 > 20:
|
2015-04-07 11:28:18 +00:00
|
|
|
break # pragma: no cover
|
|
|
|
|
2015-02-16 17:00:44 +00:00
|
|
|
# Stop as soon as we find a v8 revision that we didn't fetch in the
|
|
|
|
# v8-revision-retrieval part above (i.e. a revision that's too old).
|
2015-04-07 11:28:18 +00:00
|
|
|
# Just iterate a few more times in case there were reverts.
|
2015-02-16 17:00:44 +00:00
|
|
|
if v8_hsh not in releases_dict:
|
2015-04-07 11:28:18 +00:00
|
|
|
count_past_last_v8 += 1 # pragma: no cover
|
2014-04-25 11:33:19 +00:00
|
|
|
|
|
|
|
# Allow Ctrl-C interrupt.
|
|
|
|
except (KeyboardInterrupt, SystemExit): # pragma: no cover
|
|
|
|
pass
|
|
|
|
|
2015-01-26 13:29:23 +00:00
|
|
|
# Add the chromium branches to the v8 candidate releases.
|
2014-04-25 11:33:19 +00:00
|
|
|
all_ranges = BuildRevisionRanges(cr_branches)
|
|
|
|
for revision, ranges in all_ranges.iteritems():
|
2015-02-16 17:00:44 +00:00
|
|
|
releases_dict.get(revision, {})["chromium_branch"] = ranges
|
2014-04-25 11:33:19 +00:00
|
|
|
|
|
|
|
|
2015-04-15 12:25:28 +00:00
|
|
|
class RetrieveInformationOnChromeReleases(Step):
|
|
|
|
MESSAGE = 'Retrieves relevant information on the latest Chrome releases'
|
|
|
|
|
|
|
|
def Run(self):
|
|
|
|
|
|
|
|
params = None
|
|
|
|
result_raw = self.ReadURL(
|
2015-04-16 12:51:51 +00:00
|
|
|
OMAHA_PROXY_URL + "all.json",
|
2015-04-15 12:25:28 +00:00
|
|
|
params,
|
|
|
|
wait_plan=[5, 20]
|
|
|
|
)
|
|
|
|
recent_releases = json.loads(result_raw)
|
|
|
|
|
|
|
|
canaries = []
|
|
|
|
|
|
|
|
for current_os in recent_releases:
|
|
|
|
for current_version in current_os["versions"]:
|
2015-04-16 12:51:51 +00:00
|
|
|
if current_version["channel"] != "canary":
|
|
|
|
continue
|
2015-04-15 12:25:28 +00:00
|
|
|
|
2015-04-16 12:51:51 +00:00
|
|
|
current_candidate = self._CreateCandidate(current_version)
|
|
|
|
canaries.append(current_candidate)
|
2015-04-15 12:25:28 +00:00
|
|
|
|
|
|
|
chrome_releases = {"canaries": canaries}
|
|
|
|
self["chrome_releases"] = chrome_releases
|
|
|
|
|
2015-04-16 12:51:51 +00:00
|
|
|
def _GetGitHashForV8Version(self, v8_version):
|
2015-04-27 11:32:29 +00:00
|
|
|
if v8_version == "N/A":
|
|
|
|
return ""
|
2015-12-03 09:20:44 +00:00
|
|
|
|
|
|
|
real_v8_version = v8_version
|
2015-04-16 12:51:51 +00:00
|
|
|
if v8_version.split(".")[3]== "0":
|
2015-12-03 09:20:44 +00:00
|
|
|
real_v8_version = v8_version[:-2]
|
2015-04-16 12:51:51 +00:00
|
|
|
|
2015-12-03 09:20:44 +00:00
|
|
|
try:
|
|
|
|
return self.GitGetHashOfTag(real_v8_version)
|
|
|
|
except GitFailedException:
|
|
|
|
return ""
|
2015-04-16 12:51:51 +00:00
|
|
|
|
|
|
|
def _CreateCandidate(self, current_version):
|
|
|
|
params = None
|
|
|
|
url_to_call = (OMAHA_PROXY_URL + "v8.json?version="
|
|
|
|
+ current_version["previous_version"])
|
|
|
|
result_raw = self.ReadURL(
|
|
|
|
url_to_call,
|
|
|
|
params,
|
|
|
|
wait_plan=[5, 20]
|
|
|
|
)
|
|
|
|
previous_v8_version = json.loads(result_raw)["v8_version"]
|
|
|
|
v8_previous_version_hash = self._GetGitHashForV8Version(previous_v8_version)
|
|
|
|
|
|
|
|
current_v8_version = current_version["v8_version"]
|
|
|
|
v8_version_hash = self._GetGitHashForV8Version(current_v8_version)
|
|
|
|
|
|
|
|
current_candidate = {
|
|
|
|
"chrome_version": current_version["version"],
|
|
|
|
"os": current_version["os"],
|
|
|
|
"release_date": current_version["current_reldate"],
|
|
|
|
"v8_version": current_v8_version,
|
|
|
|
"v8_version_hash": v8_version_hash,
|
|
|
|
"v8_previous_version": previous_v8_version,
|
|
|
|
"v8_previous_version_hash": v8_previous_version_hash,
|
|
|
|
}
|
|
|
|
return current_candidate
|
|
|
|
|
2015-04-15 12:25:28 +00:00
|
|
|
|
2014-04-09 14:30:02 +00:00
|
|
|
class CleanUp(Step):
|
|
|
|
MESSAGE = "Clean up."
|
|
|
|
|
|
|
|
def RunStep(self):
|
|
|
|
self.CommonCleanup()
|
|
|
|
|
|
|
|
|
|
|
|
class WriteOutput(Step):
|
|
|
|
MESSAGE = "Print output."
|
|
|
|
|
|
|
|
def Run(self):
|
2015-04-15 12:25:28 +00:00
|
|
|
|
|
|
|
output = {
|
|
|
|
"releases": self["releases"],
|
|
|
|
"chrome_releases": self["chrome_releases"],
|
|
|
|
}
|
|
|
|
|
2014-04-09 14:30:02 +00:00
|
|
|
if self._options.csv:
|
|
|
|
with open(self._options.csv, "w") as f:
|
|
|
|
writer = csv.DictWriter(f,
|
|
|
|
["version", "branch", "revision",
|
|
|
|
"chromium_revision", "patches_merged"],
|
|
|
|
restval="",
|
|
|
|
extrasaction="ignore")
|
|
|
|
for release in self["releases"]:
|
|
|
|
writer.writerow(release)
|
|
|
|
if self._options.json:
|
|
|
|
with open(self._options.json, "w") as f:
|
2015-04-15 12:25:28 +00:00
|
|
|
f.write(json.dumps(output))
|
2014-04-09 14:30:02 +00:00
|
|
|
if not self._options.csv and not self._options.json:
|
2015-04-15 12:25:28 +00:00
|
|
|
print output # pragma: no cover
|
2014-04-09 14:30:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Releases(ScriptsBase):
|
|
|
|
def _PrepareOptions(self, parser):
|
|
|
|
parser.add_argument("-b", "--branch", default="recent",
|
|
|
|
help=("The branch to analyze. If 'all' is specified, "
|
|
|
|
"analyze all branches. If 'recent' (default) "
|
2015-01-26 13:29:23 +00:00
|
|
|
"is specified, track beta, stable and "
|
|
|
|
"candidates."))
|
2014-04-09 14:30:02 +00:00
|
|
|
parser.add_argument("-c", "--chromium",
|
|
|
|
help=("The path to your Chromium src/ "
|
|
|
|
"directory to automate the V8 roll."))
|
|
|
|
parser.add_argument("--csv", help="Path to a CSV file for export.")
|
|
|
|
parser.add_argument("-m", "--max-releases", type=int, default=0,
|
|
|
|
help="The maximum number of releases to track.")
|
|
|
|
parser.add_argument("--json", help="Path to a JSON file for export.")
|
|
|
|
|
|
|
|
def _ProcessOptions(self, options): # pragma: no cover
|
2015-03-14 02:04:33 +00:00
|
|
|
options.force_readline_defaults = True
|
2014-04-09 14:30:02 +00:00
|
|
|
return True
|
|
|
|
|
2014-09-23 14:41:36 +00:00
|
|
|
def _Config(self):
|
|
|
|
return {
|
|
|
|
"BRANCHNAME": "retrieve-v8-releases",
|
|
|
|
"PERSISTFILE_BASENAME": "/tmp/v8-releases-tempfile",
|
|
|
|
}
|
|
|
|
|
2014-04-09 14:30:02 +00:00
|
|
|
def _Steps(self):
|
2015-04-15 12:25:28 +00:00
|
|
|
|
2014-04-09 14:30:02 +00:00
|
|
|
return [
|
|
|
|
Preparation,
|
|
|
|
RetrieveV8Releases,
|
|
|
|
UpdateChromiumCheckout,
|
|
|
|
RetrieveChromiumV8Releases,
|
2015-04-15 12:25:28 +00:00
|
|
|
RetrieveChromiumBranches,
|
|
|
|
RetrieveInformationOnChromeReleases,
|
2014-04-09 14:30:02 +00:00
|
|
|
CleanUp,
|
|
|
|
WriteOutput,
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": # pragma: no cover
|
2014-09-23 14:41:36 +00:00
|
|
|
sys.exit(Releases().Run())
|