From 934dd88d3b2cee6d3952676fc89844c41b77adf2 Mon Sep 17 00:00:00 2001 From: machenbach Date: Fri, 6 Mar 2015 05:10:22 -0800 Subject: [PATCH] Make automated branch creation gnumbd-save. This makes now the same simplification as the chromium release scripts do. For creating branch B from a gnumbd'ed (aka real) commit X do: 1. Branch Y off the real X 2. Set refs/pending/heads/B to Y 3. Set refs/pending-tags/B to X 4. Set refs/heads/B to X The old algorithm tried to branch off the pending correspondent of X. That commit was determined by comparing tree objects of the real X and commits on pending. Unfortunately, multiple commits on one branch can refer to the same tree object, e.g., for commits P, Q, R with R being the revert of Q, P and R refer to the same tree object. TBR=tandrii@chromium.org NOTRY=true TEST=./script_test.py TEST=tools/release/create_release.py -a me -r you --dry-run Review URL: https://codereview.chromium.org/979243004 Cr-Commit-Position: refs/heads/master@{#27042} --- tools/release/create_release.py | 24 +++++------------------- tools/release/test_scripts.py | 7 ++----- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/tools/release/create_release.py b/tools/release/create_release.py index 44c10d9..3bbb50e 100755 --- a/tools/release/create_release.py +++ b/tools/release/create_release.py @@ -30,23 +30,10 @@ class PrepareBranchRevision(Step): MESSAGE = "Check from which revision to branch off." def RunStep(self): - if self._options.revision: - self["push_hash"], tree_object = self.GitLog( - n=1, format="\"%H %T\"", git_hash=self._options.revision).split(" ") - else: - self["push_hash"], tree_object = self.GitLog( - n=1, format="\"%H %T\"", branch="origin/master").split(" ") - print "Release revision %s" % self["push_hash"] + self["push_hash"] = (self._options.revision or + self.GitLog(n=1, format="%H", branch="origin/master")) assert self["push_hash"] - - pending_tuples = self.GitLog( - n=200, format="\"%H %T\"", branch="refs/pending/heads/master") - for hsh, tree in map(lambda s: s.split(" "), pending_tuples.splitlines()): - if tree == tree_object: - self["pending_hash"] = hsh - break - print "Pending release revision %s" % self["pending_hash"] - assert self["pending_hash"] + print "Release revision %s" % self["push_hash"] class IncrementVersion(Step): @@ -174,7 +161,7 @@ class MakeBranch(Step): def RunStep(self): self.Git("reset --hard origin/master") - self.Git("checkout -b work-branch %s" % self["pending_hash"]) + self.Git("checkout -b work-branch %s" % self["push_hash"]) self.GitCheckoutFile(CHANGELOG_FILE, self["latest_version"]) self.GitCheckoutFile(VERSION_FILE, self["latest_version"]) @@ -229,8 +216,7 @@ class PushBranch(Step): def RunStep(self): pushspecs = [ "refs/heads/work-branch:refs/pending/heads/%s" % self["version"], - "%s:refs/pending-tags/heads/%s" % - (self["pending_hash"], self["version"]), + "%s:refs/pending-tags/heads/%s" % (self["push_hash"], self["version"]), "%s:refs/heads/%s" % (self["push_hash"], self["version"]), ] cmd = "push origin %s" % " ".join(pushspecs) diff --git a/tools/release/test_scripts.py b/tools/release/test_scripts.py index aeb9c20..77d66b6 100644 --- a/tools/release/test_scripts.py +++ b/tools/release/test_scripts.py @@ -917,9 +917,6 @@ Performance and stability improvements on all platforms.""" "+refs/pending-tags/*:refs/pending-tags/*", ""), Cmd("git checkout -f origin/master", ""), Cmd("git branch", ""), - Cmd("git log -1 --format=\"%H %T\" push_hash", "push_hash tree_hash"), - Cmd("git log -200 --format=\"%H %T\" refs/pending/heads/master", - "not_right wrong\npending_hash tree_hash\nsome other\n"), Cmd("git fetch origin +refs/tags/*:refs/tags/*", ""), Cmd("git tag", self.TAGS), Cmd("git checkout -f origin/master -- include/v8-version.h", @@ -932,7 +929,7 @@ Performance and stability improvements on all platforms.""" Cmd("git log -1 --format=%B rev1", "Text\nLOG=YES\nBUG=v8:321\nText\n"), Cmd("git log -1 --format=%an rev1", "author1@chromium.org\n"), Cmd("git reset --hard origin/master", ""), - Cmd("git checkout -b work-branch pending_hash", ""), + Cmd("git checkout -b work-branch push_hash", ""), Cmd("git checkout -f 3.22.4 -- ChangeLog", "", cb=ResetChangeLog), Cmd("git checkout -f 3.22.4 -- include/v8-version.h", "", cb=self.WriteFakeVersionFile), @@ -940,7 +937,7 @@ Performance and stability improvements on all platforms.""" cb=CheckVersionCommit), Cmd("git push origin " "refs/heads/work-branch:refs/pending/heads/3.22.5 " - "pending_hash:refs/pending-tags/heads/3.22.5 " + "push_hash:refs/pending-tags/heads/3.22.5 " "push_hash:refs/heads/3.22.5", ""), Cmd("git fetch", ""), Cmd("git log -1 --format=%H --grep=" -- 2.7.4