Allow to push arbitrary revisions when pushing to trunk.

BUG=
R=jkummerow@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20132 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent bd69f653
...@@ -72,6 +72,18 @@ class FreshBranch(Step): ...@@ -72,6 +72,18 @@ class FreshBranch(Step):
self.GitCreateBranch(self.Config(BRANCHNAME), "svn/bleeding_edge") self.GitCreateBranch(self.Config(BRANCHNAME), "svn/bleeding_edge")
class PreparePushRevision(Step):
MESSAGE = "Check which revision to push."
def RunStep(self):
if self._options.revision:
self["push_hash"] = self.GitSVNFindGitHash(self._options.revision)
else:
self["push_hash"] = self.GitLog(n=1, format="%H", git_hash="HEAD")
if not self["push_hash"]: # pragma: no cover
self.Die("Could not determine the git hash for the push.")
class DetectLastPush(Step): class DetectLastPush(Step):
MESSAGE = "Detect commit ID of last push to trunk." MESSAGE = "Detect commit ID of last push to trunk."
...@@ -105,6 +117,9 @@ class DetectLastPush(Step): ...@@ -105,6 +117,9 @@ class DetectLastPush(Step):
self["last_push_trunk"] = last_push self["last_push_trunk"] = last_push
# This points to the last bleeding_edge revision that went into the last # This points to the last bleeding_edge revision that went into the last
# push. # push.
# TODO(machenbach): Do we need a check to make sure we're not pushing a
# revision older than the last push? If we do this, the output of the
# current change log preparation won't make much sense.
self["last_push_bleeding_edge"] = last_push_bleeding_edge self["last_push_bleeding_edge"] = last_push_bleeding_edge
...@@ -161,9 +176,9 @@ class PrepareChangeLog(Step): ...@@ -161,9 +176,9 @@ class PrepareChangeLog(Step):
self["date"] = self.GetDate() self["date"] = self.GetDate()
output = "%s: Version %s\n\n" % (self["date"], self["version"]) output = "%s: Version %s\n\n" % (self["date"], self["version"])
TextToFile(output, self.Config(CHANGELOG_ENTRY_FILE)) TextToFile(output, self.Config(CHANGELOG_ENTRY_FILE))
# TODO(machenbach): Retrieve the push hash also from a command-line option.
commits = self.GitLog(format="%H", commits = self.GitLog(format="%H",
git_hash="%s..HEAD" % self["last_push_bleeding_edge"]) git_hash="%s..%s" % (self["last_push_bleeding_edge"],
self["push_hash"]))
# Cache raw commit messages. # Cache raw commit messages.
commit_messages = [ commit_messages = [
...@@ -219,8 +234,6 @@ class StragglerCommits(Step): ...@@ -219,8 +234,6 @@ class StragglerCommits(Step):
def RunStep(self): def RunStep(self):
self.GitSVNFetch() self.GitSVNFetch()
self.GitCheckout("svn/bleeding_edge") self.GitCheckout("svn/bleeding_edge")
# TODO(machenbach): Retrieve the push hash also from a command-line option.
self["push_hash"] = self.GitLog(n=1, format="%H", git_hash="HEAD")
class SquashCommits(Step): class SquashCommits(Step):
...@@ -478,6 +491,8 @@ class PushToTrunk(ScriptsBase): ...@@ -478,6 +491,8 @@ class PushToTrunk(ScriptsBase):
"directory to automate the V8 roll.")) "directory to automate the V8 roll."))
parser.add_argument("-l", "--last-push", parser.add_argument("-l", "--last-push",
help="The git commit ID of the last push to trunk.") help="The git commit ID of the last push to trunk.")
parser.add_argument("-R", "--revision",
help="The svn revision to push (defaults to HEAD).")
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.manual and not options.reviewer:
...@@ -489,6 +504,10 @@ class PushToTrunk(ScriptsBase): ...@@ -489,6 +504,10 @@ class PushToTrunk(ScriptsBase):
if not options.manual and not options.author: if not options.manual and not options.author:
print "Specify your chromium.org email with -a in (semi-)automatic mode." print "Specify your chromium.org email with -a in (semi-)automatic mode."
return False return False
if options.revision and not int(options.revision) > 0:
print("The --revision flag must be a positiv integer pointing to a "
"valid svn revision.")
return False
options.tbr_commit = not options.manual options.tbr_commit = not options.manual
return True return True
...@@ -497,6 +516,7 @@ class PushToTrunk(ScriptsBase): ...@@ -497,6 +516,7 @@ class PushToTrunk(ScriptsBase):
return [ return [
Preparation, Preparation,
FreshBranch, FreshBranch,
PreparePushRevision,
DetectLastPush, DetectLastPush,
IncrementVersion, IncrementVersion,
PrepareChangeLog, PrepareChangeLog,
......
...@@ -469,13 +469,22 @@ class ScriptTest(unittest.TestCase): ...@@ -469,13 +469,22 @@ class ScriptTest(unittest.TestCase):
r"\g<space>3", r"\g<space>3",
"//\n#define BUILD_NUMBER 321\n")) "//\n#define BUILD_NUMBER 321\n"))
def testPreparePushRevision(self):
# Tests the default push hash used when the --revision option is not set.
self.ExpectGit([
Git("log -1 --format=%H HEAD", "push_hash")
])
self.RunStep(PushToTrunk, PreparePushRevision)
self.assertEquals("push_hash", self._state["push_hash"])
def testPrepareChangeLog(self): def testPrepareChangeLog(self):
TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile()
self.WriteFakeVersionFile() self.WriteFakeVersionFile()
TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile()
self.ExpectGit([ self.ExpectGit([
Git("log --format=%H 1234..HEAD", "rev1\nrev2\nrev3\nrev4"), Git("log --format=%H 1234..push_hash", "rev1\nrev2\nrev3\nrev4"),
Git("log -1 --format=%s rev1", "Title text 1"), Git("log -1 --format=%s rev1", "Title text 1"),
Git("log -1 --format=%B rev1", "Title\n\nBUG=\nLOG=y\n"), Git("log -1 --format=%B rev1", "Title\n\nBUG=\nLOG=y\n"),
Git("log -1 --format=%an rev1", "author1@chromium.org"), Git("log -1 --format=%an rev1", "author1@chromium.org"),
...@@ -499,6 +508,7 @@ class ScriptTest(unittest.TestCase): ...@@ -499,6 +508,7 @@ class ScriptTest(unittest.TestCase):
]) ])
self._state["last_push_bleeding_edge"] = "1234" self._state["last_push_bleeding_edge"] = "1234"
self._state["push_hash"] = "push_hash"
self._state["version"] = "3.22.5" self._state["version"] = "3.22.5"
self.RunStep(PushToTrunk, PrepareChangeLog) self.RunStep(PushToTrunk, PrepareChangeLog)
...@@ -636,13 +646,6 @@ Performance and stability improvements on all platforms.""" ...@@ -636,13 +646,6 @@ Performance and stability improvements on all platforms."""
TEST_CONFIG[DEPS_FILE]) TEST_CONFIG[DEPS_FILE])
os.environ["EDITOR"] = "vi" os.environ["EDITOR"] = "vi"
def CheckPreparePush():
self.assertEquals(bleeding_edge_change_log,
FileToText(TEST_CONFIG[CHANGELOG_FILE]))
version = FileToText(TEST_CONFIG[VERSION_FILE])
self.assertTrue(re.search(r"#define BUILD_NUMBER\s+6", version))
def ResetChangeLog(): def ResetChangeLog():
"""On 'git co -b new_branch svn/trunk', and 'git checkout -- ChangeLog', """On 'git co -b new_branch svn/trunk', and 'git checkout -- ChangeLog',
the ChangLog will be reset to its content on trunk.""" the ChangLog will be reset to its content on trunk."""
...@@ -696,6 +699,7 @@ Performance and stability improvements on all platforms.""", commit) ...@@ -696,6 +699,7 @@ Performance and stability improvements on all platforms.""", commit)
Git("branch", " branch1\n* branch2\n"), Git("branch", " branch1\n* branch2\n"),
Git("branch", " branch1\n* branch2\n"), Git("branch", " branch1\n* branch2\n"),
Git("checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""), Git("checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""),
Git("svn find-rev r123455", "push_hash\n"),
Git(("log -1 --format=%H --grep=" Git(("log -1 --format=%H --grep="
"\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" " "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" "
"svn/trunk"), "hash2\n"), "svn/trunk"), "hash2\n"),
...@@ -705,13 +709,12 @@ Performance and stability improvements on all platforms.""", commit) ...@@ -705,13 +709,12 @@ Performance and stability improvements on all platforms.""", commit)
Git("svn find-rev r1234", "hash3\n"), Git("svn find-rev r1234", "hash3\n"),
Git("checkout -f hash2 -- %s" % TEST_CONFIG[VERSION_FILE], "", Git("checkout -f hash2 -- %s" % TEST_CONFIG[VERSION_FILE], "",
cb=self.WriteFakeVersionFile), cb=self.WriteFakeVersionFile),
Git("log --format=%H hash3..HEAD", "rev1\n"), Git("log --format=%H hash3..push_hash", "rev1\n"),
Git("log -1 --format=%s rev1", "Log text 1.\n"), Git("log -1 --format=%s rev1", "Log text 1.\n"),
Git("log -1 --format=%B rev1", "Text\nLOG=YES\nBUG=v8:321\nText\n"), Git("log -1 --format=%B rev1", "Text\nLOG=YES\nBUG=v8:321\nText\n"),
Git("log -1 --format=%an rev1", "author1@chromium.org\n"), Git("log -1 --format=%an rev1", "author1@chromium.org\n"),
Git("svn fetch", "fetch result\n"), Git("svn fetch", "fetch result\n"),
Git("checkout -f svn/bleeding_edge", ""), Git("checkout -f svn/bleeding_edge", ""),
Git("log -1 --format=%H HEAD", "push_hash\n"),
Git("diff svn/trunk push_hash", "patch content\n"), Git("diff svn/trunk push_hash", "patch content\n"),
Git("svn find-rev push_hash", "123455\n"), Git("svn find-rev push_hash", "123455\n"),
Git("checkout -b %s svn/trunk" % TEST_CONFIG[TRUNKBRANCH], "", Git("checkout -b %s svn/trunk" % TEST_CONFIG[TRUNKBRANCH], "",
...@@ -755,7 +758,8 @@ Performance and stability improvements on all platforms.""", commit) ...@@ -755,7 +758,8 @@ Performance and stability improvements on all platforms.""", commit)
if not manual: if not manual:
self.ExpectReadline([]) self.ExpectReadline([])
args = ["-a", "author@chromium.org", "-c", TEST_CONFIG[CHROMIUM]] args = ["-a", "author@chromium.org", "-c", TEST_CONFIG[CHROMIUM],
"--revision", "123455"]
if force: args.append("-f") if force: args.append("-f")
if manual: args.append("-m") if manual: args.append("-m")
else: args += ["-r", "reviewer@chromium.org"] else: args += ["-r", "reviewer@chromium.org"]
......
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