Commit 88a93e8f authored by Michael Achenbach's avatar Michael Achenbach Committed by Commit Bot

[release] Deprecate v8rel

NOTRY=true

Change-Id: Ie97090587841830ed82097f5411131a9dc9ff5e6
Reviewed-on: https://chromium-review.googlesource.com/1009742
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: 's avatarMichael Hablich <hablich@chromium.org>
Reviewed-by: 's avatarSergiy Byelozyorov <sergiyb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52563}
parent 5fb562fc
#!/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.
# This script retrieves the history of all V8 branches and
# their corresponding Chromium revisions.
# Requires a chromium checkout with branch heads:
# gclient sync --with_branch_heads
# gclient fetch
import argparse
import csv
import itertools
import json
import os
import re
import sys
from common_includes import *
CONFIG = {
"BRANCHNAME": "retrieve-v8-releases",
"PERSISTFILE_BASENAME": "/tmp/v8-releases-tempfile",
}
# Expression for retrieving the bleeding edge revision from a commit message.
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]+)\)$")
# 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)
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]+)\.?$")
# 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)
# New git message for reverted CLs. One message per line.
ROLLBACK_MESSAGE_GIT_RE = re.compile(r"^Rollback of ([a-fA-F0-9]+)\.?$")
# Expression for retrieving the code review link.
REVIEW_LINK_RE = re.compile(r"^Review URL: (.+)$", re.M)
# Expression with three versions (historical) for extracting the v8 revision
# from the chromium DEPS file.
DEPS_RE = re.compile(r"""^\s*(?:["']v8_revision["']: ["']"""
"""|\(Var\("googlecode_url"\) % "v8"\) \+ "\/trunk@"""
"""|"http\:\/\/v8\.googlecode\.com\/svn\/trunk@)"""
"""([^"']+)["'].*$""", re.M)
# 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+)\)")
OMAHA_PROXY_URL = "http://omahaproxy.appspot.com/"
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.
cr_releases is a list of [cr_rev, v8_hsh] reverse-sorted by cr_rev.
"""
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.
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.
"""
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.
return dict((hsh, ", ".join(ran)) for hsh, ran in range_lists.iteritems())
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)
def GetMasterHashFromPush(self, title):
return MatchSafe(PUSH_MSG_GIT_RE.match(title))
def GetMergedPatches(self, body):
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
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)
def GetReleaseDict(
self, git_hash, master_position, master_hash, branch, version,
patches, cl_body):
revision = self.GetCommitPositionNumber(git_hash)
return {
# The cr commit position number on the branch.
"revision": revision,
# The git revision on the branch.
"revision_git": git_hash,
# The cr commit position number on master.
"master_position": master_position,
# The same for git.
"master_hash": master_hash,
# The branch name.
"branch": branch,
# The version for displaying in the form 3.26.3 or 3.26.3.12.
"version": version,
# The date of the commit.
"date": self.GitLog(n=1, format="%ci", git_hash=git_hash),
# Merged patches if available in the form 'r1234, r2345'.
"patches_merged": patches,
# Default for easier output formatting.
"chromium_revision": "",
# Default for easier output formatting.
"chromium_branch": "",
# 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"
% revision),
}
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"]
if CHERRY_PICK_TITLE_GIT_RE.match(body.splitlines()[0]):
patches = self.GetMergedPatchesGit(body)
else:
patches = self.GetMergedPatches(body)
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)
master_position = ""
if master_hash:
master_position = self.GetCommitPositionNumber(master_hash)
return self.GetReleaseDict(
git_hash, master_position, master_hash, branch, version,
patches, body), self["patch"]
def GetReleasesFromBranch(self, branch):
self.GitReset(self.vc.RemoteBranch(branch))
if branch == self.vc.MasterBranch():
return self.GetReleasesFromMaster()
releases = []
try:
for git_hash in self.GitLog(format="%H").splitlines():
if VERSION_FILE not in self.GitChangedFiles(git_hash):
continue
if self.ExceedsMax(releases):
break # pragma: no cover
if not self.GitCheckoutFileSafe(VERSION_FILE, git_hash):
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.
if branch != self.vc.CandidateBranch() and patch_level == "0":
break
# Allow Ctrl-C interrupt.
except (KeyboardInterrupt, SystemExit): # pragma: no cover
pass
# Clean up checked-out version file.
self.GitCheckoutFileSafe(VERSION_FILE, "HEAD")
return releases
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:
if b.startswith("origin/"):
branch = b.split("origin/")[1]
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
def RunStep(self):
self.GitCreateBranch(self._config["BRANCHNAME"])
releases = []
if self._options.branch == 'recent':
# List every release from the last 7 days.
revisions = self.GetRecentReleases(max_age=7 * DAY_IN_SECONDS)
for revision in revisions:
releases += self.GetReleaseFromRevision(revision)
elif self._options.branch == 'all': # pragma: no cover
# Retrieve the full release history.
for branch in self.vc.GetBranches():
releases += self.GetReleasesFromBranch(branch)
releases += self.GetReleasesFromBranch(self.vc.CandidateBranch())
releases += self.GetReleasesFromBranch(self.vc.MasterBranch())
else: # pragma: no cover
# Retrieve history for a specified branch.
assert self._options.branch in (self.vc.GetBranches() +
[self.vc.CandidateBranch(), self.vc.MasterBranch()])
releases += self.GetReleasesFromBranch(self._options.branch)
self["releases"] = sorted(releases,
key=lambda r: SortingKey(r["version"]),
reverse=True)
class UpdateChromiumCheckout(Step):
MESSAGE = "Update the chromium checkout."
def RunStep(self):
cwd = self._options.chromium
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"))
def ConvertToCommitNumber(step, revision):
# Simple check for git hashes.
if revision.isdigit() and len(revision) < 8:
return revision
return step.GetCommitPositionNumber(
revision, cwd=os.path.join(step._options.chromium, "v8"))
class RetrieveChromiumV8Releases(Step):
MESSAGE = "Retrieve V8 releases from Chromium DEPS."
def RunStep(self):
cwd = self._options.chromium
# All v8 revisions we are interested in.
releases_dict = dict((r["revision_git"], r) for r in self["releases"])
cr_releases = []
count_past_last_v8 = 0
try:
for git_hash in self.GitLog(
format="%H", grep="V8", branch="origin/master",
path="DEPS", cwd=cwd).splitlines():
deps = self.GitShowFile(git_hash, "DEPS", cwd=cwd)
match = DEPS_RE.search(deps)
if match:
cr_rev = self.GetCommitPositionNumber(git_hash, cwd=cwd)
if cr_rev:
v8_hsh = match.group(1)
cr_releases.append([cr_rev, v8_hsh])
if count_past_last_v8:
count_past_last_v8 += 1 # pragma: no cover
if count_past_last_v8 > 20:
break # pragma: no cover
# 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).
# Just iterate a few more times in case there were reverts.
if v8_hsh not in releases_dict:
count_past_last_v8 += 1 # pragma: no cover
# Allow Ctrl-C interrupt.
except (KeyboardInterrupt, SystemExit): # pragma: no cover
pass
# Add the chromium ranges to the v8 candidates and master releases.
all_ranges = BuildRevisionRanges(cr_releases)
for hsh, ranges in all_ranges.iteritems():
releases_dict.get(hsh, {})["chromium_revision"] = ranges
# TODO(machenbach): Unify common code with method above.
class RetrieveChromiumBranches(Step):
MESSAGE = "Retrieve Chromium branch information."
def RunStep(self):
cwd = self._options.chromium
# All v8 revisions we are interested in.
releases_dict = dict((r["revision_git"], r) for r in self["releases"])
# Filter out irrelevant branches.
branches = filter(lambda r: re.match(r"branch-heads/\d+", r),
self.GitRemotes(cwd=cwd))
# 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 = []
count_past_last_v8 = 0
try:
for branch in branches:
deps = self.GitShowFile(
"refs/branch-heads/%d" % branch, "DEPS", cwd=cwd)
match = DEPS_RE.search(deps)
if match:
v8_hsh = match.group(1)
cr_branches.append([str(branch), v8_hsh])
if count_past_last_v8:
count_past_last_v8 += 1 # pragma: no cover
if count_past_last_v8 > 20:
break # pragma: no cover
# 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).
# Just iterate a few more times in case there were reverts.
if v8_hsh not in releases_dict:
count_past_last_v8 += 1 # pragma: no cover
# Allow Ctrl-C interrupt.
except (KeyboardInterrupt, SystemExit): # pragma: no cover
pass
# Add the chromium branches to the v8 candidate releases.
all_ranges = BuildRevisionRanges(cr_branches)
for revision, ranges in all_ranges.iteritems():
releases_dict.get(revision, {})["chromium_branch"] = ranges
class RetrieveInformationOnChromeReleases(Step):
MESSAGE = 'Retrieves relevant information on the latest Chrome releases'
def Run(self):
params = None
result_raw = self.ReadURL(
OMAHA_PROXY_URL + "all.json",
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"]:
if current_version["channel"] != "canary":
continue
current_candidate = self._CreateCandidate(current_version)
canaries.append(current_candidate)
chrome_releases = {"canaries": canaries}
self["chrome_releases"] = chrome_releases
def _GetGitHashForV8Version(self, v8_version):
if v8_version == "N/A":
return ""
real_v8_version = v8_version
if v8_version.split(".")[3]== "0":
real_v8_version = v8_version[:-2]
try:
return self.GitGetHashOfTag(real_v8_version)
except GitFailedException:
return ""
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
class CleanUp(Step):
MESSAGE = "Clean up."
def RunStep(self):
self.CommonCleanup()
class WriteOutput(Step):
MESSAGE = "Print output."
def Run(self):
output = {
"releases": self["releases"],
"chrome_releases": self["chrome_releases"],
}
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:
f.write(json.dumps(output))
if not self._options.csv and not self._options.json:
print output # pragma: no cover
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) "
"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."))
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
options.force_readline_defaults = True
return True
def _Config(self):
return {
"BRANCHNAME": "retrieve-v8-releases",
"PERSISTFILE_BASENAME": "/tmp/v8-releases-tempfile",
}
def _Steps(self):
return [
Preparation,
RetrieveV8Releases,
UpdateChromiumCheckout,
RetrieveChromiumV8Releases,
RetrieveChromiumBranches,
RetrieveInformationOnChromeReleases,
CleanUp,
WriteOutput,
]
if __name__ == "__main__": # pragma: no cover
sys.exit(Releases().Run())
......@@ -43,8 +43,6 @@ import merge_to_branch
from merge_to_branch import MergeToBranch
import push_to_candidates
from push_to_candidates import *
import releases
from releases import Releases
from auto_tag import AutoTag
import roll_merge
from roll_merge import RollMerge
......@@ -97,38 +95,6 @@ class ToplevelTest(unittest.TestCase):
]
self.assertEquals(expected, NormalizeVersionTags(input))
def testSortBranches(self):
S = releases.SortBranches
self.assertEquals(["3.1", "2.25"], S(["2.25", "3.1"])[0:2])
self.assertEquals(["3.0", "2.25"], S(["2.25", "3.0", "2.24"])[0:2])
self.assertEquals(["3.11", "3.2"], S(["3.11", "3.2", "2.24"])[0:2])
def testFilterDuplicatesAndReverse(self):
F = releases.FilterDuplicatesAndReverse
self.assertEquals([], F([]))
self.assertEquals([["100", "10"]], F([["100", "10"]]))
self.assertEquals([["99", "9"], ["100", "10"]],
F([["100", "10"], ["99", "9"]]))
self.assertEquals([["98", "9"], ["100", "10"]],
F([["100", "10"], ["99", "9"], ["98", "9"]]))
self.assertEquals([["98", "9"], ["99", "10"]],
F([["100", "10"], ["99", "10"], ["98", "9"]]))
def testBuildRevisionRanges(self):
B = releases.BuildRevisionRanges
self.assertEquals({}, B([]))
self.assertEquals({"10": "100"}, B([["100", "10"]]))
self.assertEquals({"10": "100", "9": "99:99"},
B([["100", "10"], ["99", "9"]]))
self.assertEquals({"10": "100", "9": "97:99"},
B([["100", "10"], ["98", "9"], ["97", "9"]]))
self.assertEquals({"10": "100", "9": "99:99", "3": "91:98"},
B([["100", "10"], ["99", "9"], ["91", "3"]]))
self.assertEquals({"13": "101", "12": "100:100", "9": "94:97",
"3": "91:93, 98:99"},
B([["101", "13"], ["100", "12"], ["98", "3"],
["94", "9"], ["91", "3"]]))
def testMakeComment(self):
self.assertEquals("# Line 1\n# Line 2\n#",
MakeComment(" Line 1\n Line 2\n"))
......@@ -1308,251 +1274,6 @@ LOG=N
args += ["-s", "4"]
RollMerge(TEST_CONFIG, self).Run(args)
def testReleases(self):
c_hash1_commit_log = """Update V8 to Version 4.2.71.
Cr-Commit-Position: refs/heads/master@{#5678}
"""
c_hash2_commit_log = """Revert something.
BUG=12345
Reason:
> Some reason.
> Cr-Commit-Position: refs/heads/master@{#12345}
> git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12345 003-1c4
Review URL: https://codereview.chromium.org/12345
Cr-Commit-Position: refs/heads/master@{#4567}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4567 0039-1c4b
"""
c_hash3_commit_log = """Simple.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b
"""
c_hash_234_commit_log = """Version 3.3.1.1 (cherry-pick).
Merged abc12.
Review URL: fake.com
Cr-Commit-Position: refs/heads/candidates@{#234}
"""
c_hash_123_commit_log = """Version 3.3.1.0
git-svn-id: googlecode@123 0039-1c4b
"""
c_hash_345_commit_log = """Version 3.4.0.
Cr-Commit-Position: refs/heads/candidates@{#345}
"""
c_hash_456_commit_log = """Version 4.2.71.
Cr-Commit-Position: refs/heads/4.2.71@{#1}
"""
c_deps = "Line\n \"v8_revision\": \"%s\",\n line\n"
json_output = self.MakeEmptyTempFile()
csv_output = self.MakeEmptyTempFile()
self.WriteFakeVersionFile()
TEST_CONFIG["CHROMIUM"] = self.MakeEmptyTempDirectory()
chrome_dir = TEST_CONFIG["CHROMIUM"]
chrome_v8_dir = os.path.join(chrome_dir, "v8")
os.makedirs(chrome_v8_dir)
def ResetVersion(major, minor, build, patch=0):
return lambda: self.WriteFakeVersionFile(major=major,
minor=minor,
build=build,
patch=patch)
self.Expect([
Cmd("git status -s -uno", ""),
Cmd("git checkout -f origin/master", ""),
Cmd("git fetch", ""),
Cmd("git branch", " branch1\n* branch2\n"),
Cmd("git new-branch %s" % TEST_CONFIG["BRANCHNAME"], ""),
Cmd("git fetch origin +refs/tags/*:refs/tags/*", ""),
Cmd("git rev-list --max-age=395200 --tags",
"bad_tag\nhash_234\nhash_123\nhash_345\nhash_456\n"),
Cmd("git describe --tags bad_tag", "3.23.42-1-deadbeef"),
Cmd("git describe --tags hash_234", "3.3.1.1"),
Cmd("git describe --tags hash_123", "3.21.2"),
Cmd("git describe --tags hash_345", "3.22.3"),
Cmd("git describe --tags hash_456", "4.2.71"),
Cmd("git diff --name-only hash_234 hash_234^", VERSION_FILE),
Cmd("git checkout -f hash_234 -- %s" % VERSION_FILE, "",
cb=ResetVersion(3, 3, 1, 1)),
Cmd("git branch -r --contains hash_234", " branch-heads/3.3\n"),
Cmd("git log -1 --format=%B hash_234", c_hash_234_commit_log),
Cmd("git log -1 --format=%s hash_234", ""),
Cmd("git log -1 --format=%B hash_234", c_hash_234_commit_log),
Cmd("git log -1 --format=%ci hash_234", "18:15"),
Cmd("git checkout -f HEAD -- %s" % VERSION_FILE, "",
cb=ResetVersion(3, 22, 5)),
Cmd("git diff --name-only hash_123 hash_123^", VERSION_FILE),
Cmd("git checkout -f hash_123 -- %s" % VERSION_FILE, "",
cb=ResetVersion(3, 21, 2)),
Cmd("git branch -r --contains hash_123", " branch-heads/3.21\n"),
Cmd("git log -1 --format=%B hash_123", c_hash_123_commit_log),
Cmd("git log -1 --format=%s hash_123", ""),
Cmd("git log -1 --format=%B hash_123", c_hash_123_commit_log),
Cmd("git log -1 --format=%ci hash_123", "03:15"),
Cmd("git checkout -f HEAD -- %s" % VERSION_FILE, "",
cb=ResetVersion(3, 22, 5)),
Cmd("git diff --name-only hash_345 hash_345^", VERSION_FILE),
Cmd("git checkout -f hash_345 -- %s" % VERSION_FILE, "",
cb=ResetVersion(3, 22, 3)),
Cmd("git branch -r --contains hash_345", " origin/candidates\n"),
Cmd("git log -1 --format=%B hash_345", c_hash_345_commit_log),
Cmd("git log -1 --format=%s hash_345", ""),
Cmd("git log -1 --format=%B hash_345", c_hash_345_commit_log),
Cmd("git log -1 --format=%ci hash_345", ""),
Cmd("git checkout -f HEAD -- %s" % VERSION_FILE, "",
cb=ResetVersion(3, 22, 5)),
Cmd("git diff --name-only hash_456 hash_456^", VERSION_FILE),
Cmd("git checkout -f hash_456 -- %s" % VERSION_FILE, "",
cb=ResetVersion(4, 2, 71)),
Cmd("git branch -r --contains hash_456", " origin/4.2.71\n"),
Cmd("git log -1 --format=%B hash_456", c_hash_456_commit_log),
Cmd("git log -1 --format=%H 4.2.71", "hash_456"),
Cmd("git log -1 --format=%s hash_456", "Version 4.2.71"),
Cmd("git log -1 --format=%H hash_456^", "master_456"),
Cmd("git log -1 --format=%B master_456",
"Cr-Commit-Position: refs/heads/master@{#456}"),
Cmd("git log -1 --format=%B hash_456", c_hash_456_commit_log),
Cmd("git log -1 --format=%ci hash_456", "02:15"),
Cmd("git checkout -f HEAD -- %s" % VERSION_FILE, "",
cb=ResetVersion(3, 22, 5)),
Cmd("git fetch origin +refs/heads/*:refs/remotes/origin/* "
"+refs/branch-heads/*:refs/remotes/branch-heads/*", "",
cwd=chrome_dir),
Cmd("git fetch origin", "", cwd=chrome_v8_dir),
Cmd("git log --format=%H --grep=\"V8\" origin/master -- DEPS",
"c_hash1\nc_hash2\nc_hash3\n",
cwd=chrome_dir),
Cmd("git show c_hash1:DEPS", c_deps % "hash_456", cwd=chrome_dir),
Cmd("git log -1 --format=%B c_hash1", c_hash1_commit_log,
cwd=chrome_dir),
Cmd("git show c_hash2:DEPS", c_deps % "hash_345", cwd=chrome_dir),
Cmd("git log -1 --format=%B c_hash2", c_hash2_commit_log,
cwd=chrome_dir),
Cmd("git show c_hash3:DEPS", c_deps % "deadbeef", cwd=chrome_dir),
Cmd("git log -1 --format=%B c_hash3", c_hash3_commit_log,
cwd=chrome_dir),
Cmd("git branch -r", " weird/123\n branch-heads/7\n", cwd=chrome_dir),
Cmd("git show refs/branch-heads/7:DEPS", c_deps % "hash_345",
cwd=chrome_dir),
URL("http://omahaproxy.appspot.com/all.json", """[{
"os": "win",
"versions": [{
"version": "2.2.2.2",
"v8_version": "22.2.2.2",
"current_reldate": "04/09/15",
"os": "win",
"channel": "canary",
"previous_version": "1.1.1.0"
}]
}]"""),
URL("http://omahaproxy.appspot.com/v8.json?version=1.1.1.0", """{
"chromium_version": "1.1.1.0",
"v8_version": "11.1.1.0"
}"""),
Cmd("git rev-list -1 11.1.1", "v8_previous_version_hash"),
Cmd("git rev-list -1 22.2.2.2", "v8_version_hash"),
Cmd("git checkout -f origin/master", ""),
Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], "")
])
args = ["-c", TEST_CONFIG["CHROMIUM"],
"--json", json_output,
"--csv", csv_output,
"--max-releases", "1"]
Releases(TEST_CONFIG, self).Run(args)
# Check expected output.
csv = ("4.2.71,4.2.71,1,5678,\r\n"
"3.22.3,candidates,345,4567:5677,\r\n"
"3.21.2,3.21,123,,\r\n"
"3.3.1.1,3.3,234,,abc12\r\n")
self.assertEquals(csv, FileToText(csv_output))
expected_json = {"chrome_releases":{
"canaries": [
{
"chrome_version": "2.2.2.2",
"os": "win",
"release_date": "04/09/15",
"v8_version": "22.2.2.2",
"v8_version_hash": "v8_version_hash",
"v8_previous_version": "11.1.1.0",
"v8_previous_version_hash": "v8_previous_version_hash"
}]},
"releases":[
{
"revision": "1",
"revision_git": "hash_456",
"master_position": "456",
"master_hash": "master_456",
"patches_merged": "",
"version": "4.2.71",
"chromium_revision": "5678",
"branch": "4.2.71",
"review_link": "",
"date": "02:15",
"chromium_branch": "",
# FIXME(machenbach): Fix revisions link for git.
"revision_link": "https://code.google.com/p/v8/source/detail?r=1",
},
{
"revision": "345",
"revision_git": "hash_345",
"master_position": "",
"master_hash": "",
"patches_merged": "",
"version": "3.22.3",
"chromium_revision": "4567:5677",
"branch": "candidates",
"review_link": "",
"date": "",
"chromium_branch": "7",
"revision_link": "https://code.google.com/p/v8/source/detail?r=345",
},
{
"revision": "123",
"revision_git": "hash_123",
"patches_merged": "",
"master_position": "",
"master_hash": "",
"version": "3.21.2",
"chromium_revision": "",
"branch": "3.21",
"review_link": "",
"date": "03:15",
"chromium_branch": "",
"revision_link": "https://code.google.com/p/v8/source/detail?r=123",
},
{
"revision": "234",
"revision_git": "hash_234",
"patches_merged": "abc12",
"master_position": "",
"master_hash": "",
"version": "3.3.1.1",
"chromium_revision": "",
"branch": "3.3",
"review_link": "fake.com",
"date": "18:15",
"chromium_branch": "",
"revision_link": "https://code.google.com/p/v8/source/detail?r=234",
},],
}
self.assertEquals(expected_json, json.loads(FileToText(json_output)))
def testMergeToBranch(self):
TEST_CONFIG["ALREADY_MERGING_SENTINEL_FILE"] = self.MakeEmptyTempFile()
TextToFile("", os.path.join(TEST_CONFIG["DEFAULT_CWD"], ".git"))
......@@ -1678,250 +1399,5 @@ NOTREECHECKS=true
args += ["-s", "4"]
MergeToBranch(TEST_CONFIG, self).Run(args)
def testReleases(self):
c_hash1_commit_log = """Update V8 to Version 4.2.71.
Cr-Commit-Position: refs/heads/master@{#5678}
"""
c_hash2_commit_log = """Revert something.
BUG=12345
Reason:
> Some reason.
> Cr-Commit-Position: refs/heads/master@{#12345}
> git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12345 003-1c4
Review URL: https://codereview.chromium.org/12345
Cr-Commit-Position: refs/heads/master@{#4567}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4567 0039-1c4b
"""
c_hash3_commit_log = """Simple.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b
"""
c_hash_234_commit_log = """Version 3.3.1.1 (cherry-pick).
Merged abc12.
Review URL: fake.com
Cr-Commit-Position: refs/heads/candidates@{#234}
"""
c_hash_123_commit_log = """Version 3.3.1.0
git-svn-id: googlecode@123 0039-1c4b
"""
c_hash_345_commit_log = """Version 3.4.0.
Cr-Commit-Position: refs/heads/candidates@{#345}
"""
c_hash_456_commit_log = """Version 4.2.71.
Cr-Commit-Position: refs/heads/4.2.71@{#1}
"""
c_deps = "Line\n \"v8_revision\": \"%s\",\n line\n"
json_output = self.MakeEmptyTempFile()
csv_output = self.MakeEmptyTempFile()
self.WriteFakeVersionFile()
TEST_CONFIG["CHROMIUM"] = self.MakeEmptyTempDirectory()
chrome_dir = TEST_CONFIG["CHROMIUM"]
chrome_v8_dir = os.path.join(chrome_dir, "v8")
os.makedirs(chrome_v8_dir)
def ResetVersion(major, minor, build, patch=0):
return lambda: self.WriteFakeVersionFile(major=major,
minor=minor,
build=build,
patch=patch)
self.Expect([
Cmd("git status -s -uno", ""),
Cmd("git checkout -f origin/master", ""),
Cmd("git fetch", ""),
Cmd("git branch", " branch1\n* branch2\n"),
Cmd("git new-branch %s" % TEST_CONFIG["BRANCHNAME"], ""),
Cmd("git fetch origin +refs/tags/*:refs/tags/*", ""),
Cmd("git rev-list --max-age=395200 --tags",
"bad_tag\nhash_234\nhash_123\nhash_345\nhash_456\n"),
Cmd("git describe --tags bad_tag", "3.23.42-1-deadbeef"),
Cmd("git describe --tags hash_234", "3.3.1.1"),
Cmd("git describe --tags hash_123", "3.21.2"),
Cmd("git describe --tags hash_345", "3.22.3"),
Cmd("git describe --tags hash_456", "4.2.71"),
Cmd("git diff --name-only hash_234 hash_234^", VERSION_FILE),
Cmd("git checkout -f hash_234 -- %s" % VERSION_FILE, "",
cb=ResetVersion(3, 3, 1, 1)),
Cmd("git branch -r --contains hash_234", " branch-heads/3.3\n"),
Cmd("git log -1 --format=%B hash_234", c_hash_234_commit_log),
Cmd("git log -1 --format=%s hash_234", ""),
Cmd("git log -1 --format=%B hash_234", c_hash_234_commit_log),
Cmd("git log -1 --format=%ci hash_234", "18:15"),
Cmd("git checkout -f HEAD -- %s" % VERSION_FILE, "",
cb=ResetVersion(3, 22, 5)),
Cmd("git diff --name-only hash_123 hash_123^", VERSION_FILE),
Cmd("git checkout -f hash_123 -- %s" % VERSION_FILE, "",
cb=ResetVersion(3, 21, 2)),
Cmd("git branch -r --contains hash_123", " branch-heads/3.21\n"),
Cmd("git log -1 --format=%B hash_123", c_hash_123_commit_log),
Cmd("git log -1 --format=%s hash_123", ""),
Cmd("git log -1 --format=%B hash_123", c_hash_123_commit_log),
Cmd("git log -1 --format=%ci hash_123", "03:15"),
Cmd("git checkout -f HEAD -- %s" % VERSION_FILE, "",
cb=ResetVersion(3, 22, 5)),
Cmd("git diff --name-only hash_345 hash_345^", VERSION_FILE),
Cmd("git checkout -f hash_345 -- %s" % VERSION_FILE, "",
cb=ResetVersion(3, 22, 3)),
Cmd("git branch -r --contains hash_345", " origin/candidates\n"),
Cmd("git log -1 --format=%B hash_345", c_hash_345_commit_log),
Cmd("git log -1 --format=%s hash_345", ""),
Cmd("git log -1 --format=%B hash_345", c_hash_345_commit_log),
Cmd("git log -1 --format=%ci hash_345", ""),
Cmd("git checkout -f HEAD -- %s" % VERSION_FILE, "",
cb=ResetVersion(3, 22, 5)),
Cmd("git diff --name-only hash_456 hash_456^", VERSION_FILE),
Cmd("git checkout -f hash_456 -- %s" % VERSION_FILE, "",
cb=ResetVersion(4, 2, 71)),
Cmd("git branch -r --contains hash_456", " origin/4.2.71\n"),
Cmd("git log -1 --format=%B hash_456", c_hash_456_commit_log),
Cmd("git log -1 --format=%H 4.2.71", "hash_456"),
Cmd("git log -1 --format=%s hash_456", "Version 4.2.71"),
Cmd("git log -1 --format=%H hash_456^", "master_456"),
Cmd("git log -1 --format=%B master_456",
"Cr-Commit-Position: refs/heads/master@{#456}"),
Cmd("git log -1 --format=%B hash_456", c_hash_456_commit_log),
Cmd("git log -1 --format=%ci hash_456", "02:15"),
Cmd("git checkout -f HEAD -- %s" % VERSION_FILE, "",
cb=ResetVersion(3, 22, 5)),
Cmd("git fetch origin +refs/heads/*:refs/remotes/origin/* "
"+refs/branch-heads/*:refs/remotes/branch-heads/*", "",
cwd=chrome_dir),
Cmd("git fetch origin", "", cwd=chrome_v8_dir),
Cmd("git log --format=%H --grep=\"V8\" origin/master -- DEPS",
"c_hash1\nc_hash2\nc_hash3\n",
cwd=chrome_dir),
Cmd("git show c_hash1:DEPS", c_deps % "hash_456", cwd=chrome_dir),
Cmd("git log -1 --format=%B c_hash1", c_hash1_commit_log,
cwd=chrome_dir),
Cmd("git show c_hash2:DEPS", c_deps % "hash_345", cwd=chrome_dir),
Cmd("git log -1 --format=%B c_hash2", c_hash2_commit_log,
cwd=chrome_dir),
Cmd("git show c_hash3:DEPS", c_deps % "deadbeef", cwd=chrome_dir),
Cmd("git log -1 --format=%B c_hash3", c_hash3_commit_log,
cwd=chrome_dir),
Cmd("git branch -r", " weird/123\n branch-heads/7\n", cwd=chrome_dir),
Cmd("git show refs/branch-heads/7:DEPS", c_deps % "hash_345",
cwd=chrome_dir),
URL("http://omahaproxy.appspot.com/all.json", """[{
"os": "win",
"versions": [{
"version": "2.2.2.2",
"v8_version": "22.2.2.2",
"current_reldate": "04/09/15",
"os": "win",
"channel": "canary",
"previous_version": "1.1.1.0"
}]
}]"""),
URL("http://omahaproxy.appspot.com/v8.json?version=1.1.1.0", """{
"chromium_version": "1.1.1.0",
"v8_version": "11.1.1.0"
}"""),
Cmd("git rev-list -1 11.1.1", "v8_previous_version_hash"),
Cmd("git rev-list -1 22.2.2.2", "v8_version_hash"),
Cmd("git checkout -f origin/master", ""),
Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], "")
])
args = ["-c", TEST_CONFIG["CHROMIUM"],
"--json", json_output,
"--csv", csv_output,
"--max-releases", "1"]
Releases(TEST_CONFIG, self).Run(args)
# Check expected output.
csv = ("4.2.71,4.2.71,1,5678,\r\n"
"3.22.3,candidates,345,4567:5677,\r\n"
"3.21.2,3.21,123,,\r\n"
"3.3.1.1,3.3,234,,abc12\r\n")
self.assertEquals(csv, FileToText(csv_output))
expected_json = {"chrome_releases":{
"canaries": [
{
"chrome_version": "2.2.2.2",
"os": "win",
"release_date": "04/09/15",
"v8_version": "22.2.2.2",
"v8_version_hash": "v8_version_hash",
"v8_previous_version": "11.1.1.0",
"v8_previous_version_hash": "v8_previous_version_hash"
}]},
"releases":[
{
"revision": "1",
"revision_git": "hash_456",
"master_position": "456",
"master_hash": "master_456",
"patches_merged": "",
"version": "4.2.71",
"chromium_revision": "5678",
"branch": "4.2.71",
"review_link": "",
"date": "02:15",
"chromium_branch": "",
# FIXME(machenbach): Fix revisions link for git.
"revision_link": "https://code.google.com/p/v8/source/detail?r=1",
},
{
"revision": "345",
"revision_git": "hash_345",
"master_position": "",
"master_hash": "",
"patches_merged": "",
"version": "3.22.3",
"chromium_revision": "4567:5677",
"branch": "candidates",
"review_link": "",
"date": "",
"chromium_branch": "7",
"revision_link": "https://code.google.com/p/v8/source/detail?r=345",
},
{
"revision": "123",
"revision_git": "hash_123",
"patches_merged": "",
"master_position": "",
"master_hash": "",
"version": "3.21.2",
"chromium_revision": "",
"branch": "3.21",
"review_link": "",
"date": "03:15",
"chromium_branch": "",
"revision_link": "https://code.google.com/p/v8/source/detail?r=123",
},
{
"revision": "234",
"revision_git": "hash_234",
"patches_merged": "abc12",
"master_position": "",
"master_hash": "",
"version": "3.3.1.1",
"chromium_revision": "",
"branch": "3.3",
"review_link": "fake.com",
"date": "18:15",
"chromium_branch": "",
"revision_link": "https://code.google.com/p/v8/source/detail?r=234",
},],
}
self.assertEquals(expected_json, json.loads(FileToText(json_output)))
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment