Teach v8rel script to read git hashes from DEPS.

The chromium DEPS file can refer to v8 git hashes now. These
are converted back into svn revision numbers for the v8
releases spreadsheet.

The DEPS file's quotation mark policy changed which affects
the regexp for retrieving the v8 revision ("->').

TEST=script_test.py
TEST=tools/push-to-trunk/releases.py -c /path/to/chromium/src --branch recent
R=hinoka@google.com

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23357 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 4cf2cfad
......@@ -28,6 +28,9 @@
import re
SHA1_RE = re.compile('^[a-fA-F0-9]{40}$')
GIT_SVN_ID_RE = re.compile('^git-svn-id: .*@([0-9]+) .*$')
class GitFailedException(Exception):
pass
......@@ -185,6 +188,20 @@ class GitRecipesMixin(object):
def GitPull(self):
self.Git("pull")
def GitFetchOrigin(self):
self.Git("fetch origin")
def GitConvertToSVNRevision(self, git_hash):
result = self.Git(MakeArgs(["rev-list", "-n", "1", git_hash]))
if not result or not SHA1_RE.match(result):
raise GitFailedException("Git hash %s is unknown." % git_hash)
log = self.GitLog(n=1, format="%B", git_hash=git_hash)
for line in reversed(log.splitlines()):
match = GIT_SVN_ID_RE.match(line.strip())
if match:
return match.group(1)
raise GitFailedException("Couldn't convert %s to SVN." % git_hash)
def GitSVNFetch(self):
self.Git("svn fetch")
......
......@@ -47,10 +47,10 @@ 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@)'
'([0-9]+)".*$', re.M)
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'.
......@@ -374,6 +374,18 @@ class UpdateChromiumCheckout(Step):
self.GitCreateBranch(self.Config(BRANCHNAME))
def ConvertToCommitNumber(step, revision):
# Simple check for git hashes.
if revision.isdigit() and len(revision) < 8:
return revision
try:
# TODO(machenbach): Add cwd to git calls.
os.chdir(os.path.join(step["chrome_path"], "v8"))
return step.GitConvertToSVNRevision(revision)
finally:
os.chdir(step["chrome_path"])
class RetrieveChromiumV8Releases(Step):
MESSAGE = "Retrieve V8 releases from Chromium DEPS."
REQUIRES = "chrome_path"
......@@ -387,6 +399,14 @@ class RetrieveChromiumV8Releases(Step):
print "No releases detected. Skipping chromium history."
return True
# Update v8 checkout in chromium.
try:
# TODO(machenbach): Add cwd to git calls.
os.chdir(os.path.join(self["chrome_path"], "v8"))
self.GitFetchOrigin()
finally:
os.chdir(self["chrome_path"])
oldest_v8_rev = int(releases[-1]["revision"])
cr_releases = []
......@@ -401,7 +421,7 @@ class RetrieveChromiumV8Releases(Step):
if match:
cr_rev = GetCommitPositionNumber(self, git_hash)
if cr_rev:
v8_rev = match.group(1)
v8_rev = ConvertToCommitNumber(self, match.group(1))
cr_releases.append([cr_rev, v8_rev])
# Stop after reaching beyond the last v8 revision we want to update.
......@@ -458,7 +478,7 @@ class RietrieveChromiumBranches(Step):
deps = FileToText(self.Config(DEPS_FILE))
match = DEPS_RE.search(deps)
if match:
v8_rev = match.group(1)
v8_rev = ConvertToCommitNumber(self, match.group(1))
cr_branches.append([str(branch), v8_rev])
# Stop after reaching beyond the last v8 revision we want to update.
......
......@@ -1213,6 +1213,11 @@ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4567 0039-1c4b
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b
"""
c_v8_22624_log = """V8 CL.
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22624 123
"""
json_output = self.MakeEmptyTempFile()
csv_output = self.MakeEmptyTempFile()
......@@ -1222,6 +1227,8 @@ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b
TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
if not os.path.exists(TEST_CONFIG[CHROMIUM]):
os.makedirs(TEST_CONFIG[CHROMIUM])
if not os.path.exists(os.path.join(TEST_CONFIG[CHROMIUM], "v8")):
os.makedirs(os.path.join(TEST_CONFIG[CHROMIUM], "v8"))
def WriteDEPS(revision):
TextToFile("Line\n \"v8_revision\": \"%s\",\n line\n" % revision,
TEST_CONFIG[DEPS_FILE])
......@@ -1290,12 +1297,17 @@ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b
Git("checkout -f master", ""),
Git("pull", ""),
Git("checkout -b %s" % TEST_CONFIG[BRANCHNAME], ""),
Git("fetch origin", ""),
Git("log --format=%H --grep=\"V8\"", "c_hash1\nc_hash2\nc_hash3\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(22624)),
cb=ResetDEPS("0123456789012345678901234567890123456789")),
Git("log -1 --format=%B c_hash2", c_hash2_commit_log),
Git("rev-list -n 1 0123456789012345678901234567890123456789",
"0123456789012345678901234567890123456789"),
Git("log -1 --format=%B 0123456789012345678901234567890123456789",
c_v8_22624_log),
Git("diff --name-only c_hash3 c_hash3^", TEST_CONFIG[DEPS_FILE]),
Git("checkout -f c_hash3 -- %s" % TEST_CONFIG[DEPS_FILE], "",
cb=ResetDEPS(345)),
......
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