Make chromium-roll script non-interactive.

BUG=408523
LOG=n
TBR=jarin@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23629 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 61805bd5
......@@ -95,7 +95,6 @@ class RollChromium(Step):
"--author", self._options.author,
"--reviewer", self._options.reviewer,
"--chromium", self._options.chromium,
"--force",
"--use-commit-queue",
]
if self._options.sheriff:
......
......@@ -37,25 +37,12 @@ class DetectLastPush(Step):
git_hash=self["last_push"])
class CheckChromium(Step):
MESSAGE = "Ask for chromium checkout."
def Run(self):
self["chrome_path"] = self._options.chromium
while not self["chrome_path"]:
self.DieNoManualMode("Please specify the path to a Chromium checkout in "
"forced mode.")
print ("Please specify the path to the chromium \"src\" directory: "),
self["chrome_path"] = self.ReadLine()
class SwitchChromium(Step):
MESSAGE = "Switch to Chromium checkout."
REQUIRES = "chrome_path"
def RunStep(self):
self["v8_path"] = os.getcwd()
os.chdir(self["chrome_path"])
os.chdir(self._options.chromium)
self.InitialEnvironmentChecks()
# Check for a clean workdir.
if not self.GitIsWorkdirClean(): # pragma: no cover
......@@ -67,57 +54,47 @@ class SwitchChromium(Step):
class UpdateChromiumCheckout(Step):
MESSAGE = "Update the checkout and create a new branch."
REQUIRES = "chrome_path"
def RunStep(self):
os.chdir(self["chrome_path"])
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["chrome_path"], "v8"))
os.chdir(os.path.join(self._options.chromium, "v8"))
self.GitFetchOrigin()
finally:
os.chdir(self["chrome_path"])
os.chdir(self._options.chromium)
self.GitCreateBranch("v8-roll-%s" % self["trunk_revision"])
class UploadCL(Step):
MESSAGE = "Create and upload CL."
REQUIRES = "chrome_path"
def RunStep(self):
os.chdir(self["chrome_path"])
os.chdir(self._options.chromium)
# Patch DEPS file.
if self._side_effect_handler.Command(
"roll-dep", "v8 %s" % self["trunk_revision"]) is None:
self.Die("Failed to create deps for %s" % self["trunk_revision"])
if self._options.reviewer and not self._options.manual:
print "Using account %s for review." % self._options.reviewer
rev = self._options.reviewer
else:
print "Please enter the email address of a reviewer for the roll CL: ",
self.DieNoManualMode("A reviewer must be specified in forced mode.")
rev = self.ReadLine()
commit_title = "Update V8 to %s." % self["push_title"].lower()
sheriff = ""
if self["sheriff"]:
sheriff = ("\n\nPlease reply to the V8 sheriff %s in case of problems."
% self["sheriff"])
self.GitCommit("%s%s\n\nTBR=%s" % (commit_title, sheriff, rev))
self.GitCommit("%s%s\n\nTBR=%s" %
(commit_title, sheriff, self._options.reviewer))
self.GitUpload(author=self._options.author,
force=self._options.force_upload,
force=True,
cq=self._options.use_commit_queue)
print "CL uploaded."
class SwitchV8(Step):
MESSAGE = "Returning to V8 checkout."
REQUIRES = "chrome_path"
def RunStep(self):
os.chdir(self["v8_path"])
......@@ -137,14 +114,7 @@ class CleanUp(Step):
class ChromiumRoll(ScriptsBase):
def _PrepareOptions(self, parser):
group = parser.add_mutually_exclusive_group()
group.add_argument("-f", "--force",
help="Don't prompt the user.",
default=False, action="store_true")
group.add_argument("-m", "--manual",
help="Prompt the user at every important step.",
default=False, action="store_true")
parser.add_argument("-c", "--chromium",
parser.add_argument("-c", "--chromium", required=True,
help=("The path to your Chromium src/ "
"directory to automate the V8 roll."))
parser.add_argument("-l", "--last-push",
......@@ -154,24 +124,19 @@ class ChromiumRoll(ScriptsBase):
default=False, action="store_true")
def _ProcessOptions(self, options): # pragma: no cover
if not options.manual and not options.reviewer:
print "A reviewer (-r) is required in (semi-)automatic mode."
return False
if not options.manual and not options.chromium:
print "A chromium checkout (-c) is required in (semi-)automatic mode."
return False
if not options.manual and not options.author:
print "Specify your chromium.org email with -a in (semi-)automatic mode."
if not options.author or not options.reviewer:
print "A reviewer (-r) and an author (-a) are required."
return False
options.tbr_commit = not options.manual
options.requires_editor = False
options.force = True
options.manual = False
return True
def _Steps(self):
return [
Preparation,
DetectLastPush,
CheckChromium,
DetermineV8Sheriff,
SwitchChromium,
UpdateChromiumCheckout,
......
......@@ -800,7 +800,7 @@ Performance and stability improvements on all platforms.""", commit)
def testPushToTrunkForced(self):
self._PushToTrunk(force=True)
def _ChromiumRoll(self, force=False, manual=False):
def testChromiumRoll(self):
googlers_mapping_py = "%s-mapping.py" % TEST_CONFIG[PERSISTFILE_BASENAME]
with open(googlers_mapping_py, "w") as f:
f.write("""
......@@ -820,8 +820,6 @@ def get_list():
TextToFile("Some line\n \"v8_revision\": \"123455\",\n some line",
TEST_CONFIG[DEPS_FILE])
os.environ["EDITOR"] = "vi"
force_flag = " -f" if not manual else ""
expectations = [
Cmd("git status -s -uno", ""),
Cmd("git status -s -b -uno", "## some_branch\n"),
......@@ -841,39 +839,23 @@ def get_list():
Cmd("git fetch origin", ""),
Cmd("git checkout -b v8-roll-123455", ""),
Cmd("roll-dep v8 123455", "rolled", cb=WriteDeps),
]
if manual:
expectations.append(RL("c_name@chromium.org")) # Chromium reviewer.
expectations += [
Cmd(("git commit -am \"Update V8 to version 3.22.5 "
"(based on bleeding_edge revision r123454).\n\n"
"Please reply to the V8 sheriff c_name@chromium.org in "
"case of problems.\n\nTBR=c_name@chromium.org\""),
""),
Cmd(("git cl upload --send-mail --email \"author@chromium.org\"%s"
% force_flag), ""),
Cmd("git cl upload --send-mail --email \"author@chromium.org\" -f", ""),
]
self.Expect(expectations)
args = ["-a", "author@chromium.org", "-c", TEST_CONFIG[CHROMIUM],
"--sheriff", "--googlers-mapping", googlers_mapping_py]
if force: args.append("-f")
if manual: args.append("-m")
else: args += ["-r", "reviewer@chromium.org"]
"--sheriff", "--googlers-mapping", googlers_mapping_py,
"-r", "reviewer@chromium.org"]
ChromiumRoll(TEST_CONFIG, self).Run(args)
deps = FileToText(TEST_CONFIG[DEPS_FILE])
self.assertTrue(re.search("\"v8_revision\": \"123455\"", deps))
def testChromiumRollManual(self):
self._ChromiumRoll(manual=True)
def testChromiumRollSemiAutomatic(self):
self._ChromiumRoll()
def testChromiumRollForced(self):
self._ChromiumRoll(force=True)
def testCheckLastPushRecently(self):
self.Expect([
Cmd(("git log -1 --format=%H --grep="
......
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