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