From 3449e4f833590fd6f1548be53be8c1b84e187942 Mon Sep 17 00:00:00 2001 From: machenbach Date: Tue, 7 Apr 2015 12:42:32 -0700 Subject: [PATCH] [release-tools] Only read from the chromium checkout in v8rel. Don't create local branches or otherwise manipulate the checkout. This reads refs from remote branches and reads file contents using show. It is faster and requires less bootstrapping and cleanup. TBR=tandrii@chromium.org NOTRY=true Review URL: https://codereview.chromium.org/1060013003 Cr-Commit-Position: refs/heads/master@{#27640} --- tools/release/git_recipes.py | 13 ++++++-- tools/release/releases.py | 56 ++++++++--------------------------- tools/release/test_scripts.py | 46 ++++++---------------------- 3 files changed, 32 insertions(+), 83 deletions(-) diff --git a/tools/release/git_recipes.py b/tools/release/git_recipes.py index 3d2a9ef87d..1a57380b63 100644 --- a/tools/release/git_recipes.py +++ b/tools/release/git_recipes.py @@ -163,7 +163,7 @@ class GitRecipesMixin(object): @Strip def GitLog(self, n=0, format="", grep="", git_hash="", parent_hash="", - branch="", reverse=False, **kwargs): + branch="", path=None, reverse=False, **kwargs): assert not (git_hash and parent_hash) args = ["log"] if n > 0: @@ -179,8 +179,15 @@ class GitRecipesMixin(object): if parent_hash: args.append("%s^" % parent_hash) args.append(branch) + if path: + args.extend(["--", path]) return self.Git(MakeArgs(args), **kwargs) + def GitShowFile(self, refspec, path, **kwargs): + assert refspec + assert path + return self.Git(MakeArgs(["show", "%s:%s" % (refspec, path)]), **kwargs) + def GitGetPatch(self, git_hash, **kwargs): assert git_hash return self.Git(MakeArgs(["log", "-1", "-p", git_hash]), **kwargs) @@ -241,8 +248,8 @@ class GitRecipesMixin(object): def GitPull(self, **kwargs): self.Git("pull", **kwargs) - def GitFetchOrigin(self, **kwargs): - self.Git("fetch origin", **kwargs) + def GitFetchOrigin(self, *refspecs, **kwargs): + self.Git(MakeArgs(["fetch", "origin"] + list(refspecs)), **kwargs) @Strip # Copied from bot_update.py and modified for svn-like numbers only. diff --git a/tools/release/releases.py b/tools/release/releases.py index 2f152b6b27..5084aa6d0c 100755 --- a/tools/release/releases.py +++ b/tools/release/releases.py @@ -314,28 +314,16 @@ class RetrieveV8Releases(Step): reverse=True) -class SwitchChromium(Step): - MESSAGE = "Switch to Chromium checkout." - - def RunStep(self): - cwd = self._options.chromium - # Check for a clean workdir. - 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(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." + MESSAGE = "Update the chromium checkout." def RunStep(self): cwd = self._options.chromium - self.GitCheckout("master", cwd=cwd) - self.GitPull(cwd=cwd) - self.DeleteBranch(self.Config("BRANCHNAME"), cwd=cwd) - self.GitCreateBranch(self.Config("BRANCHNAME"), cwd=cwd) + self.GitFetchOrigin("+refs/heads/*:refs/remotes/origin/*", + "+refs/branch-heads/*:refs/remotes/branch-heads/*", + cwd=cwd) + # Update v8 checkout in chromium. + self.GitFetchOrigin(cwd=os.path.join(cwd, "v8")) def ConvertToCommitNumber(step, revision): @@ -352,9 +340,6 @@ class RetrieveChromiumV8Releases(Step): def RunStep(self): cwd = self._options.chromium - # Update v8 checkout in chromium. - self.GitFetchOrigin(cwd=os.path.join(cwd, "v8")) - # All v8 revisions we are interested in. releases_dict = dict((r["revision_git"], r) for r in self["releases"]) @@ -362,12 +347,9 @@ class RetrieveChromiumV8Releases(Step): count_past_last_v8 = 0 try: 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("DEPS", git_hash, cwd=cwd): - break # pragma: no cover - deps = FileToText(os.path.join(cwd, "DEPS")) + format="%H", grep="V8", branch="origin/master", + path="DEPS", cwd=cwd).splitlines(): + deps = self.GitShowFile(git_hash, "DEPS", cwd=cwd) match = DEPS_RE.search(deps) if match: cr_rev = self.GetCommitPositionNumber(git_hash, cwd=cwd) @@ -378,7 +360,7 @@ class RetrieveChromiumV8Releases(Step): if count_past_last_v8: count_past_last_v8 += 1 # pragma: no cover - if count_past_last_v8 > 10: + if count_past_last_v8 > 20: break # pragma: no cover # Stop as soon as we find a v8 revision that we didn't fetch in the @@ -391,9 +373,6 @@ class RetrieveChromiumV8Releases(Step): except (KeyboardInterrupt, SystemExit): # pragma: no cover pass - # Clean up. - self.GitCheckoutFileSafe("DEPS", "HEAD", cwd=cwd) - # Add the chromium ranges to the v8 candidates and master releases. all_ranges = BuildRevisionRanges(cr_releases) @@ -425,11 +404,8 @@ class RietrieveChromiumBranches(Step): count_past_last_v8 = 0 try: for branch in branches: - if not self.GitCheckoutFileSafe("DEPS", - "branch-heads/%d" % branch, - cwd=cwd): - break # pragma: no cover - deps = FileToText(os.path.join(cwd, "DEPS")) + deps = self.GitShowFile( + "refs/branch-heads/%d" % branch, "DEPS", cwd=cwd) match = DEPS_RE.search(deps) if match: v8_hsh = match.group(1) @@ -438,7 +414,7 @@ class RietrieveChromiumBranches(Step): if count_past_last_v8: count_past_last_v8 += 1 # pragma: no cover - if count_past_last_v8 > 10: + if count_past_last_v8 > 20: break # pragma: no cover # Stop as soon as we find a v8 revision that we didn't fetch in the @@ -451,9 +427,6 @@ class RietrieveChromiumBranches(Step): except (KeyboardInterrupt, SystemExit): # pragma: no cover pass - # Clean up. - self.GitCheckoutFileSafe("DEPS", "HEAD", cwd=cwd) - # Add the chromium branches to the v8 candidate releases. all_ranges = BuildRevisionRanges(cr_branches) for revision, ranges in all_ranges.iteritems(): @@ -464,8 +437,6 @@ 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() @@ -518,7 +489,6 @@ class Releases(ScriptsBase): return [ Preparation, RetrieveV8Releases, - SwitchChromium, UpdateChromiumCheckout, RetrieveChromiumV8Releases, RietrieveChromiumBranches, diff --git a/tools/release/test_scripts.py b/tools/release/test_scripts.py index 291ca38123..99f4339989 100644 --- a/tools/release/test_scripts.py +++ b/tools/release/test_scripts.py @@ -1322,6 +1322,7 @@ Cr-Commit-Position: refs/heads/candidates@{#345} Cr-Commit-Position: refs/heads/4.2.71@{#1} """ + c_deps = "Line\n \"v8_revision\": \"%s\",\n line\n" json_output = self.MakeEmptyTempFile() csv_output = self.MakeEmptyTempFile() @@ -1331,10 +1332,6 @@ Cr-Commit-Position: refs/heads/4.2.71@{#1} chrome_dir = TEST_CONFIG["CHROMIUM"] chrome_v8_dir = os.path.join(chrome_dir, "v8") os.makedirs(chrome_v8_dir) - def WriteDEPS(revision): - TextToFile("Line\n \"v8_revision\": \"%s\",\n line\n" % revision, - os.path.join(chrome_dir, "DEPS")) - WriteDEPS(567) def ResetVersion(major, minor, build, patch=0): return lambda: self.WriteFakeVersionFile(major=major, @@ -1342,9 +1339,6 @@ Cr-Commit-Position: refs/heads/4.2.71@{#1} build=build, patch=patch) - def ResetDEPS(revision): - return lambda: WriteDEPS(revision) - self.Expect([ Cmd("git status -s -uno", ""), Cmd("git checkout -f origin/master", ""), @@ -1403,47 +1397,25 @@ Cr-Commit-Position: refs/heads/4.2.71@{#1} Cmd("git log -1 --format=%ci hash_456", "02:15"), Cmd("git checkout -f HEAD -- %s" % VERSION_FILE, "", cb=ResetVersion(3, 22, 5)), - Cmd("git status -s -uno", "", cwd=chrome_dir), - Cmd("git checkout -f master", "", cwd=chrome_dir), - Cmd("git pull", "", cwd=chrome_dir), - Cmd("git branch", " branch1\n* %s" % TEST_CONFIG["BRANCHNAME"], - cwd=chrome_dir), - Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], "", - cwd=chrome_dir), - Cmd("git new-branch %s" % TEST_CONFIG["BRANCHNAME"], "", + Cmd("git fetch origin +refs/heads/*:refs/remotes/origin/* " + "+refs/branch-heads/*:refs/remotes/branch-heads/*", "", cwd=chrome_dir), Cmd("git fetch origin", "", cwd=chrome_v8_dir), - Cmd("git log --format=%H --grep=\"V8\"", - "c_hash0\nc_hash1\nc_hash2\nc_hash3\n", - cwd=chrome_dir), - Cmd("git diff --name-only c_hash0 c_hash0^", "", cwd=chrome_dir), - Cmd("git diff --name-only c_hash1 c_hash1^", "DEPS", cwd=chrome_dir), - Cmd("git checkout -f c_hash1 -- DEPS", "", - cb=ResetDEPS("hash_456"), + Cmd("git log --format=%H --grep=\"V8\" origin/master -- DEPS", + "c_hash1\nc_hash2\nc_hash3\n", cwd=chrome_dir), + Cmd("git show c_hash1:DEPS", c_deps % "hash_456", cwd=chrome_dir), Cmd("git log -1 --format=%B c_hash1", c_hash1_commit_log, cwd=chrome_dir), - Cmd("git diff --name-only c_hash2 c_hash2^", "DEPS", cwd=chrome_dir), - Cmd("git checkout -f c_hash2 -- DEPS", "", - cb=ResetDEPS("hash_345"), - cwd=chrome_dir), + Cmd("git show c_hash2:DEPS", c_deps % "hash_345", cwd=chrome_dir), Cmd("git log -1 --format=%B c_hash2", c_hash2_commit_log, cwd=chrome_dir), - Cmd("git diff --name-only c_hash3 c_hash3^", "DEPS", cwd=chrome_dir), - Cmd("git checkout -f c_hash3 -- DEPS", "", cb=ResetDEPS("deadbeef"), - cwd=chrome_dir), + Cmd("git show c_hash3:DEPS", c_deps % "deadbeef", cwd=chrome_dir), Cmd("git log -1 --format=%B c_hash3", c_hash3_commit_log, cwd=chrome_dir), - Cmd("git checkout -f HEAD -- DEPS", "", cb=ResetDEPS("hash_567"), - cwd=chrome_dir), Cmd("git branch -r", " weird/123\n branch-heads/7\n", cwd=chrome_dir), - Cmd("git checkout -f branch-heads/7 -- DEPS", "", - cb=ResetDEPS("hash_345"), + Cmd("git show refs/branch-heads/7:DEPS", c_deps % "hash_345", cwd=chrome_dir), - Cmd("git checkout -f HEAD -- DEPS", "", cb=ResetDEPS("hash_567"), - cwd=chrome_dir), - Cmd("git checkout -f master", "", cwd=chrome_dir), - Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], "", cwd=chrome_dir), Cmd("git checkout -f origin/master", ""), Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], ""), ])