Commit ec0329e2 authored by machenbach's avatar machenbach Committed by Commit bot

[release-tools] Make chromium roll more robust after failing rolls.

Always use the same branch name (the old version leaked
branches). Always try to delete a possibly existing branch
on start-up and also clean up in the end.

NOTRY=true
TBR=tandrii@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#27722}
parent 1f7a7b32
...@@ -45,9 +45,7 @@ class SwitchChromium(Step): ...@@ -45,9 +45,7 @@ class SwitchChromium(Step):
MESSAGE = "Switch to Chromium checkout." MESSAGE = "Switch to Chromium checkout."
def RunStep(self): def RunStep(self):
self["v8_path"] = os.getcwd()
cwd = self._options.chromium cwd = self._options.chromium
os.chdir(cwd)
self.InitialEnvironmentChecks(cwd) self.InitialEnvironmentChecks(cwd)
# Check for a clean workdir. # Check for a clean workdir.
if not self.GitIsWorkdirClean(cwd=cwd): # pragma: no cover if not self.GitIsWorkdirClean(cwd=cwd): # pragma: no cover
...@@ -61,25 +59,25 @@ class UpdateChromiumCheckout(Step): ...@@ -61,25 +59,25 @@ class UpdateChromiumCheckout(Step):
MESSAGE = "Update the checkout and create a new branch." MESSAGE = "Update the checkout and create a new branch."
def RunStep(self): def RunStep(self):
self.GitCheckout("master", cwd=self._options.chromium) cwd = self._options.chromium
self.Command("gclient", "sync --nohooks", cwd=self._options.chromium) self.GitCheckout("master", cwd=cwd)
self.GitPull(cwd=self._options.chromium) self.DeleteBranch("work-branch", cwd=cwd)
self.Command("gclient", "sync --nohooks", cwd=cwd)
self.GitPull(cwd=cwd)
# Update v8 remotes. # Update v8 remotes.
self.GitFetchOrigin() self.GitFetchOrigin()
self.GitCreateBranch("v8-roll-%s" % self._options.roll, self.GitCreateBranch("work-branch", cwd=cwd)
cwd=self._options.chromium)
class UploadCL(Step): class UploadCL(Step):
MESSAGE = "Create and upload CL." MESSAGE = "Create and upload CL."
def RunStep(self): def RunStep(self):
cwd = self._options.chromium
# Patch DEPS file. # Patch DEPS file.
if self.Command( if self.Command("roll-dep", "v8 %s" % self._options.roll, cwd=cwd) is None:
"roll-dep", "v8 %s" % self._options.roll,
cwd=self._options.chromium) is None:
self.Die("Failed to create deps for %s" % self._options.roll) self.Die("Failed to create deps for %s" % self._options.roll)
message = [] message = []
...@@ -91,30 +89,18 @@ class UploadCL(Step): ...@@ -91,30 +89,18 @@ class UploadCL(Step):
message.append(ISSUE_MSG) message.append(ISSUE_MSG)
message.append("TBR=%s" % self._options.reviewer) message.append("TBR=%s" % self._options.reviewer)
self.GitCommit("\n\n".join(message), self.GitCommit("\n\n".join(message), author=self._options.author, cwd=cwd)
author=self._options.author,
cwd=self._options.chromium)
if not self._options.dry_run: if not self._options.dry_run:
self.GitUpload(author=self._options.author, self.GitUpload(author=self._options.author,
force=True, force=True,
cq=self._options.use_commit_queue, cq=self._options.use_commit_queue,
cwd=self._options.chromium) cwd=cwd)
print "CL uploaded." print "CL uploaded."
else: else:
self.GitCheckout("master", cwd=self._options.chromium)
self.GitDeleteBranch("v8-roll-%s" % self._options.roll,
cwd=self._options.chromium)
print "Dry run - don't upload." print "Dry run - don't upload."
self.GitCheckout("master", cwd=cwd)
# TODO(machenbach): Make this obsolete. We are only in the chromium chechout self.GitDeleteBranch("work-branch", cwd=cwd)
# for the initial .git check.
class SwitchV8(Step):
MESSAGE = "Returning to V8 checkout."
def RunStep(self):
os.chdir(self["v8_path"])
class CleanUp(Step): class CleanUp(Step):
MESSAGE = "Done!" MESSAGE = "Done!"
...@@ -164,7 +150,6 @@ class ChromiumRoll(ScriptsBase): ...@@ -164,7 +150,6 @@ class ChromiumRoll(ScriptsBase):
SwitchChromium, SwitchChromium,
UpdateChromiumCheckout, UpdateChromiumCheckout,
UploadCL, UploadCL,
SwitchV8,
CleanUp, CleanUp,
] ]
......
...@@ -1014,10 +1014,11 @@ TBR=g_name@chromium.org,reviewer@chromium.org""" ...@@ -1014,10 +1014,11 @@ TBR=g_name@chromium.org,reviewer@chromium.org"""
"document.write('g_name')"), "document.write('g_name')"),
Cmd("git status -s -uno", "", cwd=chrome_dir), Cmd("git status -s -uno", "", cwd=chrome_dir),
Cmd("git checkout -f master", "", cwd=chrome_dir), Cmd("git checkout -f master", "", cwd=chrome_dir),
Cmd("git branch", "", cwd=chrome_dir),
Cmd("gclient sync --nohooks", "syncing...", cwd=chrome_dir), Cmd("gclient sync --nohooks", "syncing...", cwd=chrome_dir),
Cmd("git pull", "", cwd=chrome_dir), Cmd("git pull", "", cwd=chrome_dir),
Cmd("git fetch origin", ""), Cmd("git fetch origin", ""),
Cmd("git new-branch v8-roll-roll_hsh", "", cwd=chrome_dir), Cmd("git new-branch work-branch", "", cwd=chrome_dir),
Cmd("roll-dep v8 roll_hsh", "rolled", cb=WriteDeps, cwd=chrome_dir), Cmd("roll-dep v8 roll_hsh", "rolled", cb=WriteDeps, cwd=chrome_dir),
Cmd(("git commit -am \"%s\" " Cmd(("git commit -am \"%s\" "
"--author \"author@chromium.org <author@chromium.org>\"" % "--author \"author@chromium.org <author@chromium.org>\"" %
...@@ -1025,6 +1026,8 @@ TBR=g_name@chromium.org,reviewer@chromium.org""" ...@@ -1025,6 +1026,8 @@ TBR=g_name@chromium.org,reviewer@chromium.org"""
"", cwd=chrome_dir), "", cwd=chrome_dir),
Cmd("git cl upload --send-mail --email \"author@chromium.org\" -f", "", Cmd("git cl upload --send-mail --email \"author@chromium.org\" -f", "",
cwd=chrome_dir), cwd=chrome_dir),
Cmd("git checkout -f master", "", cwd=chrome_dir),
Cmd("git branch -D work-branch", "", cwd=chrome_dir),
] ]
self.Expect(expectations) self.Expect(expectations)
......
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