From ec0329e2d6a7444b5280b2c3ac77b65f2be91129 Mon Sep 17 00:00:00 2001 From: machenbach Date: Thu, 9 Apr 2015 14:37:33 -0700 Subject: [PATCH] [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} --- tools/release/chromium_roll.py | 39 ++++++++++++--------------------------- tools/release/test_scripts.py | 5 ++++- 2 files changed, 16 insertions(+), 28 deletions(-) diff --git a/tools/release/chromium_roll.py b/tools/release/chromium_roll.py index de0a569..fae3eb8 100755 --- a/tools/release/chromium_roll.py +++ b/tools/release/chromium_roll.py @@ -45,9 +45,7 @@ class SwitchChromium(Step): MESSAGE = "Switch to Chromium checkout." def RunStep(self): - self["v8_path"] = os.getcwd() cwd = self._options.chromium - os.chdir(cwd) self.InitialEnvironmentChecks(cwd) # Check for a clean workdir. if not self.GitIsWorkdirClean(cwd=cwd): # pragma: no cover @@ -61,25 +59,25 @@ class UpdateChromiumCheckout(Step): MESSAGE = "Update the checkout and create a new branch." def RunStep(self): - self.GitCheckout("master", cwd=self._options.chromium) - self.Command("gclient", "sync --nohooks", cwd=self._options.chromium) - self.GitPull(cwd=self._options.chromium) + cwd = self._options.chromium + self.GitCheckout("master", cwd=cwd) + self.DeleteBranch("work-branch", cwd=cwd) + self.Command("gclient", "sync --nohooks", cwd=cwd) + self.GitPull(cwd=cwd) # Update v8 remotes. self.GitFetchOrigin() - self.GitCreateBranch("v8-roll-%s" % self._options.roll, - cwd=self._options.chromium) + self.GitCreateBranch("work-branch", cwd=cwd) class UploadCL(Step): MESSAGE = "Create and upload CL." def RunStep(self): + cwd = self._options.chromium # Patch DEPS file. - if self.Command( - "roll-dep", "v8 %s" % self._options.roll, - cwd=self._options.chromium) is None: + if self.Command("roll-dep", "v8 %s" % self._options.roll, cwd=cwd) is None: self.Die("Failed to create deps for %s" % self._options.roll) message = [] @@ -91,30 +89,18 @@ class UploadCL(Step): message.append(ISSUE_MSG) message.append("TBR=%s" % self._options.reviewer) - self.GitCommit("\n\n".join(message), - author=self._options.author, - cwd=self._options.chromium) + self.GitCommit("\n\n".join(message), author=self._options.author, cwd=cwd) if not self._options.dry_run: self.GitUpload(author=self._options.author, force=True, cq=self._options.use_commit_queue, - cwd=self._options.chromium) + cwd=cwd) print "CL uploaded." 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." - -# 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." - - def RunStep(self): - os.chdir(self["v8_path"]) - + self.GitCheckout("master", cwd=cwd) + self.GitDeleteBranch("work-branch", cwd=cwd) class CleanUp(Step): MESSAGE = "Done!" @@ -164,7 +150,6 @@ class ChromiumRoll(ScriptsBase): SwitchChromium, UpdateChromiumCheckout, UploadCL, - SwitchV8, CleanUp, ] diff --git a/tools/release/test_scripts.py b/tools/release/test_scripts.py index 99f4339..bbbaee0 100644 --- a/tools/release/test_scripts.py +++ b/tools/release/test_scripts.py @@ -1014,10 +1014,11 @@ TBR=g_name@chromium.org,reviewer@chromium.org""" "document.write('g_name')"), Cmd("git status -s -uno", "", 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("git pull", "", cwd=chrome_dir), 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(("git commit -am \"%s\" " "--author \"author@chromium.org \"" % @@ -1025,6 +1026,8 @@ TBR=g_name@chromium.org,reviewer@chromium.org""" "", cwd=chrome_dir), Cmd("git cl upload --send-mail --email \"author@chromium.org\" -f", "", cwd=chrome_dir), + Cmd("git checkout -f master", "", cwd=chrome_dir), + Cmd("git branch -D work-branch", "", cwd=chrome_dir), ] self.Expect(expectations) -- 2.7.4