Add V8 releases script.

This script retrieves the history of all V8 branches and trunk revisions and their corresponding Chromium revisions.

TEST=tools/push-to-trunk/releases.py -c <chrome path> --csv test.csv

BUG=
R=jarin@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20629 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 41b6c8a0
......@@ -39,6 +39,7 @@ import time
import urllib2
from git_recipes import GitRecipesMixin
from git_recipes import GitFailedException
PERSISTFILE_BASENAME = "PERSISTFILE_BASENAME"
TEMP_BRANCH = "TEMP_BRANCH"
......@@ -216,10 +217,6 @@ class NoRetryException(Exception):
pass
class GitFailedException(Exception):
pass
class Step(GitRecipesMixin):
def __init__(self, text, requires, number, config, state, options, handler):
self._text = text
......
......@@ -28,6 +28,11 @@
import re
class GitFailedException(Exception):
pass
def Strip(f):
def new_f(*args, **kwargs):
return f(*args, **kwargs).strip()
......@@ -59,6 +64,13 @@ class GitRecipesMixin(object):
assert name
self.Git(MakeArgs(["branch -D", name]))
def GitReset(self, name):
assert name
self.Git(MakeArgs(["reset --hard", name]))
def GitRemotes(self):
return map(str.strip, self.Git(MakeArgs(["branch -r"])).splitlines())
def GitCheckout(self, name):
assert name
self.Git(MakeArgs(["checkout -f", name]))
......@@ -68,6 +80,26 @@ class GitRecipesMixin(object):
assert branch_or_hash
self.Git(MakeArgs(["checkout -f", branch_or_hash, "--", name]))
def GitCheckoutFileSafe(self, name, branch_or_hash):
try:
self.GitCheckoutFile(name, branch_or_hash)
except GitFailedException: # pragma: no cover
# The file doesn't exist in that revision.
return False
return True
def GitChangedFiles(self, git_hash):
assert git_hash
try:
files = self.Git(MakeArgs(["diff --name-only",
git_hash,
"%s^" % git_hash]))
return map(str.strip, files.splitlines())
except GitFailedException: # pragma: no cover
# Git fails using "^" at branch roots.
return []
@Strip
def GitCurrentBranch(self):
for line in self.Git("status -s -b -uno").strip().splitlines():
......@@ -99,6 +131,7 @@ class GitRecipesMixin(object):
assert git_hash
return self.Git(MakeArgs(["log", "-1", "-p", git_hash]))
# TODO(machenbach): Unused? Remove.
def GitAdd(self, name):
assert name
self.Git(MakeArgs(["add", Quoted(name)]))
......@@ -147,6 +180,7 @@ class GitRecipesMixin(object):
def GitSVNFetch(self):
self.Git("svn fetch")
# TODO(machenbach): Unused? Remove.
@Strip
def GitSVNLog(self):
return self.Git("svn log -1 --oneline")
......
This diff is collapsed.
......@@ -45,6 +45,8 @@ import chromium_roll
from chromium_roll import CHROMIUM
from chromium_roll import DEPS_FILE
from chromium_roll import ChromiumRoll
import releases
from releases import Releases
TEST_CONFIG = {
......@@ -75,6 +77,38 @@ AUTO_PUSH_ARGS = [
class ToplevelTest(unittest.TestCase):
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"))
......@@ -297,14 +331,14 @@ class ScriptTest(unittest.TestCase):
self._tmp_files.append(name)
return name
def WriteFakeVersionFile(self, build=4):
def WriteFakeVersionFile(self, minor=22, build=4, patch=0):
with open(TEST_CONFIG[VERSION_FILE], "w") as f:
f.write(" // Some line...\n")
f.write("\n")
f.write("#define MAJOR_VERSION 3\n")
f.write("#define MINOR_VERSION 22\n")
f.write("#define MINOR_VERSION %s\n" % minor)
f.write("#define BUILD_NUMBER %s\n" % build)
f.write("#define PATCH_LEVEL 0\n")
f.write("#define PATCH_LEVEL %s\n" % patch)
f.write(" // Some line...\n")
f.write("#define IS_CANDIDATE_VERSION 0\n")
......@@ -1116,6 +1150,107 @@ LOG=N
args += ["-s", "3"]
MergeToBranch(TEST_CONFIG, self).Run(args)
def testReleases(self):
json_output = self.MakeEmptyTempFile()
csv_output = self.MakeEmptyTempFile()
TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile()
self.WriteFakeVersionFile()
TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
if not os.path.exists(TEST_CONFIG[CHROMIUM]):
os.makedirs(TEST_CONFIG[CHROMIUM])
def WriteDEPS(revision):
TextToFile("Line\n \"v8_revision\": \"%s\",\n line\n" % revision,
TEST_CONFIG[DEPS_FILE])
WriteDEPS(567)
def ResetVersion(minor, build, patch=0):
return lambda: self.WriteFakeVersionFile(minor=minor,
build=build,
patch=patch)
def ResetDEPS(revision):
return lambda: WriteDEPS(revision)
self.ExpectGit([
Git("status -s -uno", ""),
Git("status -s -b -uno", "## some_branch\n"),
Git("svn fetch", ""),
Git("branch", " branch1\n* branch2\n"),
Git("checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""),
Git("branch", " branch1\n* branch2\n"),
Git("checkout -b %s" % TEST_CONFIG[BRANCHNAME], ""),
Git("branch -r", " svn/3.21\n svn/3.3\n"),
Git("reset --hard svn/3.3", ""),
Git("log --format=%H", "hash1\nhash2"),
Git("diff --name-only hash1 hash1^", ""),
Git("diff --name-only hash2 hash2^", TEST_CONFIG[VERSION_FILE]),
Git("checkout -f hash2 -- %s" % TEST_CONFIG[VERSION_FILE], "",
cb=ResetVersion(3, 1, 1)),
Git("log -1 --format=%B hash2", "Version 3.3.1.1 (merged 12)"),
Git("log -1 --format=%s hash2", ""),
Git("svn find-rev hash2", "234"),
Git("checkout -f HEAD -- %s" % TEST_CONFIG[VERSION_FILE], "",
cb=ResetVersion(22, 5)),
Git("reset --hard svn/3.21", ""),
Git("log --format=%H", "hash3\nhash4\nhash5\n"),
Git("diff --name-only hash3 hash3^", TEST_CONFIG[VERSION_FILE]),
Git("checkout -f hash3 -- %s" % TEST_CONFIG[VERSION_FILE], "",
cb=ResetVersion(21, 2)),
Git("log -1 --format=%s hash3", ""),
Git("svn find-rev hash3", "123"),
Git("checkout -f HEAD -- %s" % TEST_CONFIG[VERSION_FILE], "",
cb=ResetVersion(22, 5)),
Git("reset --hard svn/trunk", ""),
Git("log --format=%H", "hash6\n"),
Git("diff --name-only hash6 hash6^", TEST_CONFIG[VERSION_FILE]),
Git("checkout -f hash6 -- %s" % TEST_CONFIG[VERSION_FILE], "",
cb=ResetVersion(22, 3)),
Git("log -1 --format=%s hash6", ""),
Git("svn find-rev hash6", "345"),
Git("checkout -f HEAD -- %s" % TEST_CONFIG[VERSION_FILE], "",
cb=ResetVersion(22, 5)),
Git("status -s -uno", ""),
Git("checkout -f master", ""),
Git("pull", ""),
Git("checkout -b %s" % TEST_CONFIG[BRANCHNAME], ""),
Git("log --format=%H --grep=\"V8\"", "c_hash1\nc_hash2\n"),
Git("diff --name-only c_hash1 c_hash1^", ""),
Git("diff --name-only c_hash2 c_hash2^", TEST_CONFIG[DEPS_FILE]),
Git("checkout -f c_hash2 -- %s" % TEST_CONFIG[DEPS_FILE], "",
cb=ResetDEPS(345)),
Git("svn find-rev c_hash2", "4567"),
Git("checkout -f HEAD -- %s" % TEST_CONFIG[DEPS_FILE], "",
cb=ResetDEPS(567)),
Git("checkout -f master", ""),
Git("branch -D %s" % TEST_CONFIG[BRANCHNAME], ""),
Git("checkout -f some_branch", ""),
Git("branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""),
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 = ("3.22.3,trunk,345,4567,\r\n"
"3.21.2,3.21,123,,\r\n"
"3.3.1.1,3.3,234,,12\r\n")
self.assertEquals(csv, FileToText(csv_output))
expected_json = [
{"bleeding_edge": "", "patches_merged": "", "version": "3.22.3",
"chromium_revision": "4567", "branch": "trunk", "revision": "345"},
{"patches_merged": "", "bleeding_edge": "", "version": "3.21.2",
"branch": "3.21", "revision": "123"},
{"patches_merged": "12", "bleeding_edge": "", "version": "3.3.1.1",
"branch": "3.3", "revision": "234"}
]
self.assertEquals(expected_json, json.loads(FileToText(json_output)))
class SystemTest(unittest.TestCase):
def testReload(self):
......
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