Add cwd to all shell commands in auto roll scripts.

The v8 root directory is assumed to be the default cwd. All
commands executed in another directory (e.g. the chromium
checkout) need an explicit specification (also in the
tests).

This also fixes several small testing and robustness bugs:
- Get rid of all 'rm ...' shell calls
- Don't leak tmp files/dirs
- Add some forgotten shell calls to the test expectations
- Hardcode the DEPS location (must always be
chromium_dir/DEPS)
- Expect correct return code when terminating gracefully

BUG=chromium:408523
LOG=n
TBR=jarin@chromium.org
TEST=script_test.py

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23719 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 5042b23b
......@@ -9,13 +9,11 @@ import sys
from common_includes import *
DEPS_FILE = "DEPS_FILE"
CHROMIUM = "CHROMIUM"
CONFIG = {
PERSISTFILE_BASENAME: "/tmp/v8-chromium-roll-tempfile",
DOT_GIT_LOCATION: ".git",
DEPS_FILE: "DEPS",
}
......@@ -43,13 +41,14 @@ class SwitchChromium(Step):
def RunStep(self):
self["v8_path"] = os.getcwd()
os.chdir(self._options.chromium)
cwd = self._options.chromium
os.chdir(cwd)
self.InitialEnvironmentChecks()
# Check for a clean workdir.
if not self.GitIsWorkdirClean(): # pragma: no cover
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(self.Config(DEPS_FILE)): # pragma: no cover
if not os.path.exists(os.path.join(cwd, "DEPS")): # pragma: no cover
self.Die("DEPS file not present.")
......@@ -57,28 +56,25 @@ class UpdateChromiumCheckout(Step):
MESSAGE = "Update the checkout and create a new branch."
def RunStep(self):
os.chdir(self._options.chromium)
self.GitCheckout("master")
self._side_effect_handler.Command("gclient", "sync --nohooks")
self.GitPull()
try:
# TODO(machenbach): Add cwd to git calls.
os.chdir(os.path.join(self._options.chromium, "v8"))
self.GitFetchOrigin()
finally:
os.chdir(self._options.chromium)
self.GitCreateBranch("v8-roll-%s" % self["trunk_revision"])
self.GitCheckout("master", cwd=self._options.chromium)
self.Command("gclient", "sync --nohooks", cwd=self._options.chromium)
self.GitPull(cwd=self._options.chromium)
# Update v8 remotes.
self.GitFetchOrigin()
self.GitCreateBranch("v8-roll-%s" % self["trunk_revision"],
cwd=self._options.chromium)
class UploadCL(Step):
MESSAGE = "Create and upload CL."
def RunStep(self):
os.chdir(self._options.chromium)
# Patch DEPS file.
if self._side_effect_handler.Command(
"roll-dep", "v8 %s" % self["trunk_revision"]) is None:
if self.Command(
"roll-dep", "v8 %s" % self["trunk_revision"],
cwd=self._options.chromium) is None:
self.Die("Failed to create deps for %s" % self["trunk_revision"])
commit_title = "Update V8 to %s." % self["push_title"].lower()
......@@ -88,18 +84,23 @@ class UploadCL(Step):
% self["sheriff"])
self.GitCommit("%s%s\n\nTBR=%s" %
(commit_title, sheriff, self._options.reviewer),
author=self._options.author)
author=self._options.author,
cwd=self._options.chromium)
if not self._options.dry_run:
self.GitUpload(author=self._options.author,
force=True,
cq=self._options.use_commit_queue)
cq=self._options.use_commit_queue,
cwd=self._options.chromium)
print "CL uploaded."
else:
self.GitCheckout("master")
self.GitDeleteBranch("v8-roll-%s" % self["trunk_revision"])
self.GitCheckout("master", cwd=self._options.chromium)
self.GitDeleteBranch("v8-roll-%s" % self["trunk_revision"],
cwd=self._options.chromium)
print "Dry run - don't upload."
# TODO(machenbach): Make this obsolete. We are only in the chromium chechout
# for the initial .git check.
class SwitchV8(Step):
MESSAGE = "Returning to V8 checkout."
......
......@@ -29,10 +29,12 @@
import argparse
import datetime
import httplib
import glob
import imp
import json
import os
import re
import shutil
import subprocess
import sys
import textwrap
......@@ -52,6 +54,10 @@ CHANGELOG_ENTRY_FILE = "CHANGELOG_ENTRY_FILE"
COMMITMSG_FILE = "COMMITMSG_FILE"
PATCH_FILE = "PATCH_FILE"
# V8 base directory.
DEFAULT_CWD = os.path.dirname(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
def TextToFile(text, file_name):
with open(file_name, "w") as f:
......@@ -183,16 +189,18 @@ def SortingKey(version):
# Some commands don't like the pipe, e.g. calling vi from within the script or
# from subscripts like git cl upload.
def Command(cmd, args="", prefix="", pipe=True):
def Command(cmd, args="", prefix="", pipe=True, cwd=None):
cwd = cwd or os.getcwd()
# TODO(machenbach): Use timeout.
cmd_line = "%s %s %s" % (prefix, cmd, args)
print "Command: %s" % cmd_line
print "in %s" % cwd
sys.stdout.flush()
try:
if pipe:
return subprocess.check_output(cmd_line, shell=True)
return subprocess.check_output(cmd_line, shell=True, cwd=cwd)
else:
return subprocess.check_call(cmd_line, shell=True)
return subprocess.check_call(cmd_line, shell=True, cwd=cwd)
except subprocess.CalledProcessError:
return None
finally:
......@@ -205,8 +213,8 @@ class SideEffectHandler(object): # pragma: no cover
def Call(self, fun, *args, **kwargs):
return fun(*args, **kwargs)
def Command(self, cmd, args="", prefix="", pipe=True):
return Command(cmd, args, prefix, pipe)
def Command(self, cmd, args="", prefix="", pipe=True, cwd=None):
return Command(cmd, args, prefix, pipe, cwd=cwd)
def ReadLine(self):
return sys.stdin.readline().strip()
......@@ -263,6 +271,10 @@ class Step(GitRecipesMixin):
self._state = state
self._options = options
self._side_effect_handler = handler
# The testing configuration might set a different default cwd.
self.default_cwd = self._config.get("DEFAULT_CWD") or DEFAULT_CWD
assert self._number >= 0
assert self._config is not None
assert self._state is not None
......@@ -341,21 +353,31 @@ class Step(GitRecipesMixin):
else:
return self._side_effect_handler.ReadLine()
def Git(self, args="", prefix="", pipe=True, retry_on=None):
cmd = lambda: self._side_effect_handler.Command("git", args, prefix, pipe)
def Command(self, name, args, cwd=None):
cmd = lambda: self._side_effect_handler.Command(
name, args, "", True, cwd=cwd or self.default_cwd)
return self.Retry(cmd, None, [5])
def Git(self, args="", prefix="", pipe=True, retry_on=None, cwd=None):
cmd = lambda: self._side_effect_handler.Command(
"git", args, prefix, pipe, cwd=cwd or self.default_cwd)
result = self.Retry(cmd, retry_on, [5, 30])
if result is None:
raise GitFailedException("'git %s' failed." % args)
return result
def SVN(self, args="", prefix="", pipe=True, retry_on=None):
cmd = lambda: self._side_effect_handler.Command("svn", args, prefix, pipe)
def SVN(self, args="", prefix="", pipe=True, retry_on=None, cwd=None):
cmd = lambda: self._side_effect_handler.Command(
"svn", args, prefix, pipe, cwd=cwd or self.default_cwd)
return self.Retry(cmd, retry_on, [5, 30])
def Editor(self, args):
if self._options.requires_editor:
return self._side_effect_handler.Command(os.environ["EDITOR"], args,
pipe=False)
return self._side_effect_handler.Command(
os.environ["EDITOR"],
args,
pipe=False,
cwd=self.default_cwd)
def ReadURL(self, url, params=None, retry_on=None, wait_plan=None):
wait_plan = wait_plan or [3, 60, 600]
......@@ -399,7 +421,8 @@ class Step(GitRecipesMixin):
# Cancel if EDITOR is unset or not executable.
if (self._options.requires_editor and (not os.environ.get("EDITOR") or
Command("which", os.environ["EDITOR"]) is None)): # pragma: no cover
self.Command(
"which", os.environ["EDITOR"]) is None)): # pragma: no cover
self.Die("Please set your EDITOR environment variable, you'll need it.")
def CommonPrepare(self):
......@@ -423,7 +446,11 @@ class Step(GitRecipesMixin):
self.GitDeleteBranch(self._config[BRANCHNAME])
# Clean up all temporary files.
Command("rm", "-f %s*" % self._config[PERSISTFILE_BASENAME])
for f in glob.iglob("%s*" % self._config[PERSISTFILE_BASENAME]):
if os.path.isfile(f):
os.remove(f)
if os.path.isdir(f):
shutil.rmtree(f)
def ReadAndPersistVersion(self, prefix=""):
def ReadAndPersist(var_name, def_name):
......@@ -607,7 +634,6 @@ class ScriptsBase(object):
parser.add_argument("-s", "--step",
help="Specify the step where to start work. Default: 0.",
default=0, type=int)
self._PrepareOptions(parser)
if args is None: # pragma: no cover
......
......@@ -94,54 +94,55 @@ def Quoted(s):
class GitRecipesMixin(object):
def GitIsWorkdirClean(self):
return self.Git("status -s -uno").strip() == ""
def GitIsWorkdirClean(self, **kwargs):
return self.Git("status -s -uno", **kwargs).strip() == ""
@Strip
def GitBranch(self):
return self.Git("branch")
def GitBranch(self, **kwargs):
return self.Git("branch", **kwargs)
def GitCreateBranch(self, name, branch=""):
def GitCreateBranch(self, name, branch="", **kwargs):
assert name
self.Git(MakeArgs(["checkout -b", name, branch]))
self.Git(MakeArgs(["checkout -b", name, branch]), **kwargs)
def GitDeleteBranch(self, name):
def GitDeleteBranch(self, name, **kwargs):
assert name
self.Git(MakeArgs(["branch -D", name]))
self.Git(MakeArgs(["branch -D", name]), **kwargs)
def GitReset(self, name):
def GitReset(self, name, **kwargs):
assert name
self.Git(MakeArgs(["reset --hard", name]))
self.Git(MakeArgs(["reset --hard", name]), **kwargs)
def GitStash(self):
self.Git(MakeArgs(["stash"]))
def GitStash(self, **kwargs):
self.Git(MakeArgs(["stash"]), **kwargs)
def GitRemotes(self):
return map(str.strip, self.Git(MakeArgs(["branch -r"])).splitlines())
def GitRemotes(self, **kwargs):
return map(str.strip,
self.Git(MakeArgs(["branch -r"]), **kwargs).splitlines())
def GitCheckout(self, name):
def GitCheckout(self, name, **kwargs):
assert name
self.Git(MakeArgs(["checkout -f", name]))
self.Git(MakeArgs(["checkout -f", name]), **kwargs)
def GitCheckoutFile(self, name, branch_or_hash):
def GitCheckoutFile(self, name, branch_or_hash, **kwargs):
assert name
assert branch_or_hash
self.Git(MakeArgs(["checkout -f", branch_or_hash, "--", name]))
self.Git(MakeArgs(["checkout -f", branch_or_hash, "--", name]), **kwargs)
def GitCheckoutFileSafe(self, name, branch_or_hash):
def GitCheckoutFileSafe(self, name, branch_or_hash, **kwargs):
try:
self.GitCheckoutFile(name, branch_or_hash)
self.GitCheckoutFile(name, branch_or_hash, **kwargs)
except GitFailedException: # pragma: no cover
# The file doesn't exist in that revision.
return False
return True
def GitChangedFiles(self, git_hash):
def GitChangedFiles(self, git_hash, **kwargs):
assert git_hash
try:
files = self.Git(MakeArgs(["diff --name-only",
git_hash,
"%s^" % git_hash]))
"%s^" % git_hash]), **kwargs)
return map(str.strip, files.splitlines())
except GitFailedException: # pragma: no cover
# Git fails using "^" at branch roots.
......@@ -149,15 +150,15 @@ class GitRecipesMixin(object):
@Strip
def GitCurrentBranch(self):
for line in self.Git("status -s -b -uno").strip().splitlines():
def GitCurrentBranch(self, **kwargs):
for line in self.Git("status -s -b -uno", **kwargs).strip().splitlines():
match = re.match(r"^## (.+)", line)
if match: return match.group(1)
raise Exception("Couldn't find curent branch.") # pragma: no cover
@Strip
def GitLog(self, n=0, format="", grep="", git_hash="", parent_hash="",
branch="", reverse=False):
branch="", reverse=False, **kwargs):
assert not (git_hash and parent_hash)
args = ["log"]
if n > 0:
......@@ -173,27 +174,27 @@ class GitRecipesMixin(object):
if parent_hash:
args.append("%s^" % parent_hash)
args.append(branch)
return self.Git(MakeArgs(args))
return self.Git(MakeArgs(args), **kwargs)
def GitGetPatch(self, git_hash):
def GitGetPatch(self, git_hash, **kwargs):
assert git_hash
return self.Git(MakeArgs(["log", "-1", "-p", git_hash]))
return self.Git(MakeArgs(["log", "-1", "-p", git_hash]), **kwargs)
# TODO(machenbach): Unused? Remove.
def GitAdd(self, name):
def GitAdd(self, name, **kwargs):
assert name
self.Git(MakeArgs(["add", Quoted(name)]))
self.Git(MakeArgs(["add", Quoted(name)]), **kwargs)
def GitApplyPatch(self, patch_file, reverse=False):
def GitApplyPatch(self, patch_file, reverse=False, **kwargs):
assert patch_file
args = ["apply --index --reject"]
if reverse:
args.append("--reverse")
args.append(Quoted(patch_file))
self.Git(MakeArgs(args))
self.Git(MakeArgs(args), **kwargs)
def GitUpload(self, reviewer="", author="", force=False, cq=False,
bypass_hooks=False):
bypass_hooks=False, **kwargs):
args = ["cl upload --send-mail"]
if author:
args += ["--email", Quoted(author)]
......@@ -207,9 +208,9 @@ class GitRecipesMixin(object):
args.append("--bypass-hooks")
# TODO(machenbach): Check output in forced mode. Verify that all required
# base files were uploaded, if not retry.
self.Git(MakeArgs(args), pipe=False)
self.Git(MakeArgs(args), pipe=False, **kwargs)
def GitCommit(self, message="", file_name="", author=None):
def GitCommit(self, message="", file_name="", author=None, **kwargs):
assert message or file_name
args = ["commit"]
if file_name:
......@@ -218,28 +219,29 @@ class GitRecipesMixin(object):
args += ["-am", Quoted(message)]
if author:
args += ["--author", "\"%s <%s>\"" % (author, author)]
self.Git(MakeArgs(args))
self.Git(MakeArgs(args), **kwargs)
def GitPresubmit(self):
self.Git("cl presubmit", "PRESUBMIT_TREE_CHECK=\"skip\"")
def GitPresubmit(self, **kwargs):
self.Git("cl presubmit", "PRESUBMIT_TREE_CHECK=\"skip\"", **kwargs)
def GitDCommit(self):
self.Git("cl dcommit -f --bypass-hooks", retry_on=lambda x: x is None)
def GitDCommit(self, **kwargs):
self.Git(
"cl dcommit -f --bypass-hooks", retry_on=lambda x: x is None, **kwargs)
def GitDiff(self, loc1, loc2):
return self.Git(MakeArgs(["diff", loc1, loc2]))
def GitDiff(self, loc1, loc2, **kwargs):
return self.Git(MakeArgs(["diff", loc1, loc2]), **kwargs)
def GitPull(self):
self.Git("pull")
def GitPull(self, **kwargs):
self.Git("pull", **kwargs)
def GitFetchOrigin(self):
self.Git("fetch origin")
def GitFetchOrigin(self, **kwargs):
self.Git("fetch origin", **kwargs)
def GitConvertToSVNRevision(self, git_hash):
result = self.Git(MakeArgs(["rev-list", "-n", "1", git_hash]))
def GitConvertToSVNRevision(self, git_hash, **kwargs):
result = self.Git(MakeArgs(["rev-list", "-n", "1", git_hash]), **kwargs)
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)
log = self.GitLog(n=1, format="%B", git_hash=git_hash, **kwargs)
for line in reversed(log.splitlines()):
match = ROLL_DEPS_GIT_SVN_ID_RE.match(line.strip())
if match:
......@@ -248,7 +250,7 @@ class GitRecipesMixin(object):
@Strip
# Copied from bot_update.py and modified for svn-like numbers only.
def GetCommitPositionNumber(self, git_hash):
def GetCommitPositionNumber(self, git_hash, **kwargs):
"""Dumps the 'git' log for a specific revision and parses out the commit
position number.
......@@ -257,7 +259,7 @@ class GitRecipesMixin(object):
Otherwise, we will search for a 'git-svn' metadata entry. If one is found,
its SVN revision value is returned.
"""
git_log = self.GitLog(format='%B', n=1, git_hash=git_hash)
git_log = self.GitLog(format='%B', n=1, git_hash=git_hash, **kwargs)
footer_map = GetCommitMessageFooterMap(git_log)
# Search for commit position metadata
......@@ -277,29 +279,31 @@ class GitRecipesMixin(object):
### Git svn stuff
def GitSVNFetch(self):
self.Git("svn fetch")
def GitSVNFetch(self, **kwargs):
self.Git("svn fetch", **kwargs)
def GitSVNRebase(self):
self.Git("svn rebase")
def GitSVNRebase(self, **kwargs):
self.Git("svn rebase", **kwargs)
# TODO(machenbach): Unused? Remove.
@Strip
def GitSVNLog(self):
return self.Git("svn log -1 --oneline")
def GitSVNLog(self, **kwargs):
return self.Git("svn log -1 --oneline", **kwargs)
@Strip
def GitSVNFindGitHash(self, revision, branch=""):
def GitSVNFindGitHash(self, revision, branch="", **kwargs):
assert revision
return self.Git(MakeArgs(["svn find-rev", "r%s" % revision, branch]))
return self.Git(
MakeArgs(["svn find-rev", "r%s" % revision, branch]), **kwargs)
@Strip
def GitSVNFindSVNRev(self, git_hash, branch=""):
return self.Git(MakeArgs(["svn find-rev", git_hash, branch]))
def GitSVNFindSVNRev(self, git_hash, branch="", **kwargs):
return self.Git(MakeArgs(["svn find-rev", git_hash, branch]), **kwargs)
def GitSVNDCommit(self):
return self.Git("svn dcommit 2>&1", retry_on=lambda x: x is None)
def GitSVNDCommit(self, **kwargs):
return self.Git("svn dcommit 2>&1", retry_on=lambda x: x is None, **kwargs)
def GitSVNTag(self, version):
def GitSVNTag(self, version, **kwargs):
self.Git(("svn tag %s -m \"Tagging version %s\"" % (version, version)),
retry_on=lambda x: x is None)
retry_on=lambda x: x is None,
**kwargs)
......@@ -27,6 +27,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import argparse
import os
import sys
import tempfile
import urllib2
......@@ -312,7 +313,7 @@ class ApplyChanges(Step):
def RunStep(self):
self.ApplyPatch(self.Config(PATCH_FILE))
Command("rm", "-f %s*" % self.Config(PATCH_FILE))
os.remove(self.Config(PATCH_FILE))
class AddChangeLog(Step):
......@@ -345,7 +346,7 @@ class CommitTrunk(Step):
def RunStep(self):
self.GitCommit(file_name = self.Config(COMMITMSG_FILE))
Command("rm", "-f %s*" % self.Config(COMMITMSG_FILE))
os.remove(self.Config(COMMITMSG_FILE))
class SanityCheck(Step):
......
......@@ -20,7 +20,6 @@ import sys
from common_includes import *
DEPS_FILE = "DEPS_FILE"
CHROMIUM = "CHROMIUM"
CONFIG = {
......@@ -28,7 +27,6 @@ CONFIG = {
PERSISTFILE_BASENAME: "/tmp/v8-releases-tempfile",
DOT_GIT_LOCATION: ".git",
VERSION_FILE: "src/version.cc",
DEPS_FILE: "DEPS",
}
# Expression for retrieving the bleeding edge revision from a commit message.
......@@ -268,60 +266,42 @@ class RetrieveV8Releases(Step):
reverse=True)
# TODO(machenbach): Parts of the Chromium setup are c/p from the chromium_roll
# script -> unify.
class CheckChromium(Step):
MESSAGE = "Check the chromium checkout."
def Run(self):
self["chrome_path"] = self._options.chromium
class SwitchChromium(Step):
MESSAGE = "Switch to Chromium checkout."
REQUIRES = "chrome_path"
def RunStep(self):
self["v8_path"] = os.getcwd()
os.chdir(self["chrome_path"])
cwd = self._options.chromium
# Check for a clean workdir.
if not self.GitIsWorkdirClean(): # pragma: no cover
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(self.Config(DEPS_FILE)): # pragma: no cover
if not os.path.exists(os.path.join(cwd, "DEPS")): # pragma: no cover
self.Die("DEPS file not present.")
class UpdateChromiumCheckout(Step):
MESSAGE = "Update the checkout and create a new branch."
REQUIRES = "chrome_path"
def RunStep(self):
os.chdir(self["chrome_path"])
self.GitCheckout("master")
self.GitPull()
self.GitCreateBranch(self.Config(BRANCHNAME))
cwd = self._options.chromium
self.GitCheckout("master", cwd=cwd)
self.GitPull(cwd=cwd)
self.GitCreateBranch(self.Config(BRANCHNAME), cwd=cwd)
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"])
return step.GitConvertToSVNRevision(
revision, cwd=os.path.join(step._options.chromium, "v8"))
class RetrieveChromiumV8Releases(Step):
MESSAGE = "Retrieve V8 releases from Chromium DEPS."
REQUIRES = "chrome_path"
def RunStep(self):
os.chdir(self["chrome_path"])
cwd = self._options.chromium
releases = filter(
lambda r: r["branch"] in ["trunk", "bleeding_edge"], self["releases"])
if not releases: # pragma: no cover
......@@ -329,26 +309,22 @@ class RetrieveChromiumV8Releases(Step):
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"])
self.GitFetchOrigin(cwd=os.path.join(cwd, "v8"))
oldest_v8_rev = int(releases[-1]["revision"])
cr_releases = []
try:
for git_hash in self.GitLog(format="%H", grep="V8").splitlines():
if self._config[DEPS_FILE] not in self.GitChangedFiles(git_hash):
for git_hash in self.GitLog(
format="%H", grep="V8", cwd=cwd).splitlines():
if "DEPS" not in self.GitChangedFiles(git_hash, cwd=cwd):
continue
if not self.GitCheckoutFileSafe(self._config[DEPS_FILE], git_hash):
if not self.GitCheckoutFileSafe("DEPS", git_hash, cwd=cwd):
break # pragma: no cover
deps = FileToText(self.Config(DEPS_FILE))
deps = FileToText(os.path.join(cwd, "DEPS"))
match = DEPS_RE.search(deps)
if match:
cr_rev = self.GetCommitPositionNumber(git_hash)
cr_rev = self.GetCommitPositionNumber(git_hash, cwd=cwd)
if cr_rev:
v8_rev = ConvertToCommitNumber(self, match.group(1))
cr_releases.append([cr_rev, v8_rev])
......@@ -364,7 +340,7 @@ class RetrieveChromiumV8Releases(Step):
pass
# Clean up.
self.GitCheckoutFileSafe(self._config[DEPS_FILE], "HEAD")
self.GitCheckoutFileSafe("DEPS", "HEAD", cwd=cwd)
# Add the chromium ranges to the v8 trunk and bleeding_edge releases.
all_ranges = BuildRevisionRanges(cr_releases)
......@@ -376,11 +352,9 @@ class RetrieveChromiumV8Releases(Step):
# TODO(machenbach): Unify common code with method above.
class RietrieveChromiumBranches(Step):
MESSAGE = "Retrieve Chromium branch information."
REQUIRES = "chrome_path"
def RunStep(self):
os.chdir(self["chrome_path"])
cwd = self._options.chromium
trunk_releases = filter(lambda r: r["branch"] == "trunk", self["releases"])
if not trunk_releases: # pragma: no cover
print "No trunk releases detected. Skipping chromium history."
......@@ -390,7 +364,7 @@ class RietrieveChromiumBranches(Step):
# Filter out irrelevant branches.
branches = filter(lambda r: re.match(r"branch-heads/\d+", r),
self.GitRemotes())
self.GitRemotes(cwd=cwd))
# Transform into pure branch numbers.
branches = map(lambda r: int(re.match(r"branch-heads/(\d+)", r).group(1)),
......@@ -401,10 +375,11 @@ class RietrieveChromiumBranches(Step):
cr_branches = []
try:
for branch in branches:
if not self.GitCheckoutFileSafe(self._config[DEPS_FILE],
"branch-heads/%d" % branch):
if not self.GitCheckoutFileSafe("DEPS",
"branch-heads/%d" % branch,
cwd=cwd):
break # pragma: no cover
deps = FileToText(self.Config(DEPS_FILE))
deps = FileToText(os.path.join(cwd, "DEPS"))
match = DEPS_RE.search(deps)
if match:
v8_rev = ConvertToCommitNumber(self, match.group(1))
......@@ -421,7 +396,7 @@ class RietrieveChromiumBranches(Step):
pass
# Clean up.
self.GitCheckoutFileSafe(self._config[DEPS_FILE], "HEAD")
self.GitCheckoutFileSafe("DEPS", "HEAD", cwd=cwd)
# Add the chromium branches to the v8 trunk releases.
all_ranges = BuildRevisionRanges(cr_branches)
......@@ -430,20 +405,12 @@ class RietrieveChromiumBranches(Step):
trunk_dict.get(revision, {})["chromium_branch"] = ranges
class SwitchV8(Step):
MESSAGE = "Returning to V8 checkout."
REQUIRES = "chrome_path"
def RunStep(self):
self.GitCheckout("master")
self.GitDeleteBranch(self.Config(BRANCHNAME))
os.chdir(self["v8_path"])
class CleanUp(Step):
MESSAGE = "Clean up."
def RunStep(self):
self.GitCheckout("master", cwd=self._options.chromium)
self.GitDeleteBranch(self.Config(BRANCHNAME), cwd=self._options.chromium)
self.CommonCleanup()
......@@ -488,12 +455,10 @@ class Releases(ScriptsBase):
return [
Preparation,
RetrieveV8Releases,
CheckChromium,
SwitchChromium,
UpdateChromiumCheckout,
RetrieveChromiumV8Releases,
RietrieveChromiumBranches,
SwitchV8,
CleanUp,
WriteOutput,
]
......
This diff is collapsed.
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