Commit 3449e4f8 authored by machenbach's avatar machenbach Committed by Commit bot

[release-tools] Only read from the chromium checkout in v8rel.

Don't create local branches or otherwise manipulate the
checkout. This reads refs from remote branches and
reads file contents using show. It is faster and requires
less bootstrapping and cleanup.

TBR=tandrii@chromium.org
NOTRY=true

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

Cr-Commit-Position: refs/heads/master@{#27640}
parent 1fb76f05
...@@ -163,7 +163,7 @@ class GitRecipesMixin(object): ...@@ -163,7 +163,7 @@ class GitRecipesMixin(object):
@Strip @Strip
def GitLog(self, n=0, format="", grep="", git_hash="", parent_hash="", def GitLog(self, n=0, format="", grep="", git_hash="", parent_hash="",
branch="", reverse=False, **kwargs): branch="", path=None, reverse=False, **kwargs):
assert not (git_hash and parent_hash) assert not (git_hash and parent_hash)
args = ["log"] args = ["log"]
if n > 0: if n > 0:
...@@ -179,8 +179,15 @@ class GitRecipesMixin(object): ...@@ -179,8 +179,15 @@ class GitRecipesMixin(object):
if parent_hash: if parent_hash:
args.append("%s^" % parent_hash) args.append("%s^" % parent_hash)
args.append(branch) args.append(branch)
if path:
args.extend(["--", path])
return self.Git(MakeArgs(args), **kwargs) return self.Git(MakeArgs(args), **kwargs)
def GitShowFile(self, refspec, path, **kwargs):
assert refspec
assert path
return self.Git(MakeArgs(["show", "%s:%s" % (refspec, path)]), **kwargs)
def GitGetPatch(self, git_hash, **kwargs): def GitGetPatch(self, git_hash, **kwargs):
assert git_hash assert git_hash
return self.Git(MakeArgs(["log", "-1", "-p", git_hash]), **kwargs) return self.Git(MakeArgs(["log", "-1", "-p", git_hash]), **kwargs)
...@@ -241,8 +248,8 @@ class GitRecipesMixin(object): ...@@ -241,8 +248,8 @@ class GitRecipesMixin(object):
def GitPull(self, **kwargs): def GitPull(self, **kwargs):
self.Git("pull", **kwargs) self.Git("pull", **kwargs)
def GitFetchOrigin(self, **kwargs): def GitFetchOrigin(self, *refspecs, **kwargs):
self.Git("fetch origin", **kwargs) self.Git(MakeArgs(["fetch", "origin"] + list(refspecs)), **kwargs)
@Strip @Strip
# Copied from bot_update.py and modified for svn-like numbers only. # Copied from bot_update.py and modified for svn-like numbers only.
......
...@@ -314,28 +314,16 @@ class RetrieveV8Releases(Step): ...@@ -314,28 +314,16 @@ class RetrieveV8Releases(Step):
reverse=True) reverse=True)
class SwitchChromium(Step):
MESSAGE = "Switch to Chromium checkout."
def RunStep(self):
cwd = self._options.chromium
# Check for a clean workdir.
if not self.GitIsWorkdirClean(cwd=cwd): # pragma: no cover
self.Die("Workspace is not clean. Please commit or undo your changes.")
# Assert that the DEPS file is there.
if not os.path.exists(os.path.join(cwd, "DEPS")): # pragma: no cover
self.Die("DEPS file not present.")
class UpdateChromiumCheckout(Step): class UpdateChromiumCheckout(Step):
MESSAGE = "Update the checkout and create a new branch." MESSAGE = "Update the chromium checkout."
def RunStep(self): def RunStep(self):
cwd = self._options.chromium cwd = self._options.chromium
self.GitCheckout("master", cwd=cwd) self.GitFetchOrigin("+refs/heads/*:refs/remotes/origin/*",
self.GitPull(cwd=cwd) "+refs/branch-heads/*:refs/remotes/branch-heads/*",
self.DeleteBranch(self.Config("BRANCHNAME"), cwd=cwd) cwd=cwd)
self.GitCreateBranch(self.Config("BRANCHNAME"), cwd=cwd) # Update v8 checkout in chromium.
self.GitFetchOrigin(cwd=os.path.join(cwd, "v8"))
def ConvertToCommitNumber(step, revision): def ConvertToCommitNumber(step, revision):
...@@ -352,9 +340,6 @@ class RetrieveChromiumV8Releases(Step): ...@@ -352,9 +340,6 @@ class RetrieveChromiumV8Releases(Step):
def RunStep(self): def RunStep(self):
cwd = self._options.chromium cwd = self._options.chromium
# Update v8 checkout in chromium.
self.GitFetchOrigin(cwd=os.path.join(cwd, "v8"))
# All v8 revisions we are interested in. # All v8 revisions we are interested in.
releases_dict = dict((r["revision_git"], r) for r in self["releases"]) releases_dict = dict((r["revision_git"], r) for r in self["releases"])
...@@ -362,12 +347,9 @@ class RetrieveChromiumV8Releases(Step): ...@@ -362,12 +347,9 @@ class RetrieveChromiumV8Releases(Step):
count_past_last_v8 = 0 count_past_last_v8 = 0
try: try:
for git_hash in self.GitLog( for git_hash in self.GitLog(
format="%H", grep="V8", cwd=cwd).splitlines(): format="%H", grep="V8", branch="origin/master",
if "DEPS" not in self.GitChangedFiles(git_hash, cwd=cwd): path="DEPS", cwd=cwd).splitlines():
continue deps = self.GitShowFile(git_hash, "DEPS", cwd=cwd)
if not self.GitCheckoutFileSafe("DEPS", git_hash, cwd=cwd):
break # pragma: no cover
deps = FileToText(os.path.join(cwd, "DEPS"))
match = DEPS_RE.search(deps) match = DEPS_RE.search(deps)
if match: if match:
cr_rev = self.GetCommitPositionNumber(git_hash, cwd=cwd) cr_rev = self.GetCommitPositionNumber(git_hash, cwd=cwd)
...@@ -378,7 +360,7 @@ class RetrieveChromiumV8Releases(Step): ...@@ -378,7 +360,7 @@ class RetrieveChromiumV8Releases(Step):
if count_past_last_v8: if count_past_last_v8:
count_past_last_v8 += 1 # pragma: no cover count_past_last_v8 += 1 # pragma: no cover
if count_past_last_v8 > 10: if count_past_last_v8 > 20:
break # pragma: no cover break # pragma: no cover
# Stop as soon as we find a v8 revision that we didn't fetch in the # Stop as soon as we find a v8 revision that we didn't fetch in the
...@@ -391,9 +373,6 @@ class RetrieveChromiumV8Releases(Step): ...@@ -391,9 +373,6 @@ class RetrieveChromiumV8Releases(Step):
except (KeyboardInterrupt, SystemExit): # pragma: no cover except (KeyboardInterrupt, SystemExit): # pragma: no cover
pass pass
# Clean up.
self.GitCheckoutFileSafe("DEPS", "HEAD", cwd=cwd)
# Add the chromium ranges to the v8 candidates and master releases. # Add the chromium ranges to the v8 candidates and master releases.
all_ranges = BuildRevisionRanges(cr_releases) all_ranges = BuildRevisionRanges(cr_releases)
...@@ -425,11 +404,8 @@ class RietrieveChromiumBranches(Step): ...@@ -425,11 +404,8 @@ class RietrieveChromiumBranches(Step):
count_past_last_v8 = 0 count_past_last_v8 = 0
try: try:
for branch in branches: for branch in branches:
if not self.GitCheckoutFileSafe("DEPS", deps = self.GitShowFile(
"branch-heads/%d" % branch, "refs/branch-heads/%d" % branch, "DEPS", cwd=cwd)
cwd=cwd):
break # pragma: no cover
deps = FileToText(os.path.join(cwd, "DEPS"))
match = DEPS_RE.search(deps) match = DEPS_RE.search(deps)
if match: if match:
v8_hsh = match.group(1) v8_hsh = match.group(1)
...@@ -438,7 +414,7 @@ class RietrieveChromiumBranches(Step): ...@@ -438,7 +414,7 @@ class RietrieveChromiumBranches(Step):
if count_past_last_v8: if count_past_last_v8:
count_past_last_v8 += 1 # pragma: no cover count_past_last_v8 += 1 # pragma: no cover
if count_past_last_v8 > 10: if count_past_last_v8 > 20:
break # pragma: no cover break # pragma: no cover
# Stop as soon as we find a v8 revision that we didn't fetch in the # Stop as soon as we find a v8 revision that we didn't fetch in the
...@@ -451,9 +427,6 @@ class RietrieveChromiumBranches(Step): ...@@ -451,9 +427,6 @@ class RietrieveChromiumBranches(Step):
except (KeyboardInterrupt, SystemExit): # pragma: no cover except (KeyboardInterrupt, SystemExit): # pragma: no cover
pass pass
# Clean up.
self.GitCheckoutFileSafe("DEPS", "HEAD", cwd=cwd)
# Add the chromium branches to the v8 candidate releases. # Add the chromium branches to the v8 candidate releases.
all_ranges = BuildRevisionRanges(cr_branches) all_ranges = BuildRevisionRanges(cr_branches)
for revision, ranges in all_ranges.iteritems(): for revision, ranges in all_ranges.iteritems():
...@@ -464,8 +437,6 @@ class CleanUp(Step): ...@@ -464,8 +437,6 @@ class CleanUp(Step):
MESSAGE = "Clean up." MESSAGE = "Clean up."
def RunStep(self): def RunStep(self):
self.GitCheckout("master", cwd=self._options.chromium)
self.GitDeleteBranch(self.Config("BRANCHNAME"), cwd=self._options.chromium)
self.CommonCleanup() self.CommonCleanup()
...@@ -518,7 +489,6 @@ class Releases(ScriptsBase): ...@@ -518,7 +489,6 @@ class Releases(ScriptsBase):
return [ return [
Preparation, Preparation,
RetrieveV8Releases, RetrieveV8Releases,
SwitchChromium,
UpdateChromiumCheckout, UpdateChromiumCheckout,
RetrieveChromiumV8Releases, RetrieveChromiumV8Releases,
RietrieveChromiumBranches, RietrieveChromiumBranches,
......
...@@ -1322,6 +1322,7 @@ Cr-Commit-Position: refs/heads/candidates@{#345} ...@@ -1322,6 +1322,7 @@ Cr-Commit-Position: refs/heads/candidates@{#345}
Cr-Commit-Position: refs/heads/4.2.71@{#1} Cr-Commit-Position: refs/heads/4.2.71@{#1}
""" """
c_deps = "Line\n \"v8_revision\": \"%s\",\n line\n"
json_output = self.MakeEmptyTempFile() json_output = self.MakeEmptyTempFile()
csv_output = self.MakeEmptyTempFile() csv_output = self.MakeEmptyTempFile()
...@@ -1331,10 +1332,6 @@ Cr-Commit-Position: refs/heads/4.2.71@{#1} ...@@ -1331,10 +1332,6 @@ Cr-Commit-Position: refs/heads/4.2.71@{#1}
chrome_dir = TEST_CONFIG["CHROMIUM"] chrome_dir = TEST_CONFIG["CHROMIUM"]
chrome_v8_dir = os.path.join(chrome_dir, "v8") chrome_v8_dir = os.path.join(chrome_dir, "v8")
os.makedirs(chrome_v8_dir) os.makedirs(chrome_v8_dir)
def WriteDEPS(revision):
TextToFile("Line\n \"v8_revision\": \"%s\",\n line\n" % revision,
os.path.join(chrome_dir, "DEPS"))
WriteDEPS(567)
def ResetVersion(major, minor, build, patch=0): def ResetVersion(major, minor, build, patch=0):
return lambda: self.WriteFakeVersionFile(major=major, return lambda: self.WriteFakeVersionFile(major=major,
...@@ -1342,9 +1339,6 @@ Cr-Commit-Position: refs/heads/4.2.71@{#1} ...@@ -1342,9 +1339,6 @@ Cr-Commit-Position: refs/heads/4.2.71@{#1}
build=build, build=build,
patch=patch) patch=patch)
def ResetDEPS(revision):
return lambda: WriteDEPS(revision)
self.Expect([ self.Expect([
Cmd("git status -s -uno", ""), Cmd("git status -s -uno", ""),
Cmd("git checkout -f origin/master", ""), Cmd("git checkout -f origin/master", ""),
...@@ -1403,47 +1397,25 @@ Cr-Commit-Position: refs/heads/4.2.71@{#1} ...@@ -1403,47 +1397,25 @@ Cr-Commit-Position: refs/heads/4.2.71@{#1}
Cmd("git log -1 --format=%ci hash_456", "02:15"), Cmd("git log -1 --format=%ci hash_456", "02:15"),
Cmd("git checkout -f HEAD -- %s" % VERSION_FILE, "", Cmd("git checkout -f HEAD -- %s" % VERSION_FILE, "",
cb=ResetVersion(3, 22, 5)), cb=ResetVersion(3, 22, 5)),
Cmd("git status -s -uno", "", cwd=chrome_dir), Cmd("git fetch origin +refs/heads/*:refs/remotes/origin/* "
Cmd("git checkout -f master", "", cwd=chrome_dir), "+refs/branch-heads/*:refs/remotes/branch-heads/*", "",
Cmd("git pull", "", cwd=chrome_dir),
Cmd("git branch", " branch1\n* %s" % TEST_CONFIG["BRANCHNAME"],
cwd=chrome_dir),
Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], "",
cwd=chrome_dir),
Cmd("git new-branch %s" % TEST_CONFIG["BRANCHNAME"], "",
cwd=chrome_dir), cwd=chrome_dir),
Cmd("git fetch origin", "", cwd=chrome_v8_dir), Cmd("git fetch origin", "", cwd=chrome_v8_dir),
Cmd("git log --format=%H --grep=\"V8\"", Cmd("git log --format=%H --grep=\"V8\" origin/master -- DEPS",
"c_hash0\nc_hash1\nc_hash2\nc_hash3\n", "c_hash1\nc_hash2\nc_hash3\n",
cwd=chrome_dir),
Cmd("git diff --name-only c_hash0 c_hash0^", "", cwd=chrome_dir),
Cmd("git diff --name-only c_hash1 c_hash1^", "DEPS", cwd=chrome_dir),
Cmd("git checkout -f c_hash1 -- DEPS", "",
cb=ResetDEPS("hash_456"),
cwd=chrome_dir), 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, Cmd("git log -1 --format=%B c_hash1", c_hash1_commit_log,
cwd=chrome_dir), cwd=chrome_dir),
Cmd("git diff --name-only c_hash2 c_hash2^", "DEPS", cwd=chrome_dir), Cmd("git show c_hash2:DEPS", c_deps % "hash_345", cwd=chrome_dir),
Cmd("git checkout -f c_hash2 -- DEPS", "",
cb=ResetDEPS("hash_345"),
cwd=chrome_dir),
Cmd("git log -1 --format=%B c_hash2", c_hash2_commit_log, Cmd("git log -1 --format=%B c_hash2", c_hash2_commit_log,
cwd=chrome_dir), cwd=chrome_dir),
Cmd("git diff --name-only c_hash3 c_hash3^", "DEPS", cwd=chrome_dir), Cmd("git show c_hash3:DEPS", c_deps % "deadbeef", cwd=chrome_dir),
Cmd("git checkout -f c_hash3 -- DEPS", "", cb=ResetDEPS("deadbeef"),
cwd=chrome_dir),
Cmd("git log -1 --format=%B c_hash3", c_hash3_commit_log, Cmd("git log -1 --format=%B c_hash3", c_hash3_commit_log,
cwd=chrome_dir), cwd=chrome_dir),
Cmd("git checkout -f HEAD -- DEPS", "", cb=ResetDEPS("hash_567"),
cwd=chrome_dir),
Cmd("git branch -r", " weird/123\n branch-heads/7\n", cwd=chrome_dir), Cmd("git branch -r", " weird/123\n branch-heads/7\n", cwd=chrome_dir),
Cmd("git checkout -f branch-heads/7 -- DEPS", "", Cmd("git show refs/branch-heads/7:DEPS", c_deps % "hash_345",
cb=ResetDEPS("hash_345"),
cwd=chrome_dir),
Cmd("git checkout -f HEAD -- DEPS", "", cb=ResetDEPS("hash_567"),
cwd=chrome_dir), cwd=chrome_dir),
Cmd("git checkout -f master", "", cwd=chrome_dir),
Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], "", cwd=chrome_dir),
Cmd("git checkout -f origin/master", ""), Cmd("git checkout -f origin/master", ""),
Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], ""), Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], ""),
]) ])
......
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