Commit 06bfc842 authored by hablich's avatar hablich Committed by Commit bot

[Release] Update merge script to leverage auto-tag bot

The auto-tag bot removes the need to handle version changes
in each merge individually. As a result this 'feature' is
removed.

BUG=v8:4408
R=machenbach@chromium.org
LOG=N
NOTRY=true

Review-Url: https://codereview.chromium.org/1398033003
Cr-Commit-Position: refs/heads/master@{#37972}
parent ba092fb0
...@@ -242,6 +242,10 @@ class GitRecipesMixin(object): ...@@ -242,6 +242,10 @@ class GitRecipesMixin(object):
self.Git( self.Git(
"cl land -f --bypass-hooks", retry_on=lambda x: x is None, **kwargs) "cl land -f --bypass-hooks", retry_on=lambda x: x is None, **kwargs)
def GitCLAddComment(self, message, **kwargs):
args = ["cl", "comments", "-a", Quoted(message)]
self.Git(MakeArgs(args), **kwargs)
def GitDiff(self, loc1, loc2, **kwargs): def GitDiff(self, loc1, loc2, **kwargs):
return self.Git(MakeArgs(["diff", loc1, loc2]), **kwargs) return self.Git(MakeArgs(["diff", loc1, loc2]), **kwargs)
......
...@@ -47,10 +47,8 @@ class Preparation(Step): ...@@ -47,10 +47,8 @@ class Preparation(Step):
open(self.Config("ALREADY_MERGING_SENTINEL_FILE"), "a").close() open(self.Config("ALREADY_MERGING_SENTINEL_FILE"), "a").close()
self.InitialEnvironmentChecks(self.default_cwd) self.InitialEnvironmentChecks(self.default_cwd)
if self._options.branch:
self["merge_to_branch"] = self._options.branch self["merge_to_branch"] = self._options.branch
else: # pragma: no cover
self.Die("Please specify a branch to merge to")
self.CommonPrepare() self.CommonPrepare()
self.PrepareBranch() self.PrepareBranch()
...@@ -74,7 +72,7 @@ class SearchArchitecturePorts(Step): ...@@ -74,7 +72,7 @@ class SearchArchitecturePorts(Step):
for revision in self["full_revision_list"]: for revision in self["full_revision_list"]:
# Search for commits which matches the "Port XXX" pattern. # Search for commits which matches the "Port XXX" pattern.
git_hashes = self.GitLog(reverse=True, format="%H", git_hashes = self.GitLog(reverse=True, format="%H",
grep="Port %s" % revision, grep="^[Pp]ort %s" % revision,
branch=self.vc.RemoteMasterBranch()) branch=self.vc.RemoteMasterBranch())
for git_hash in git_hashes.splitlines(): for git_hash in git_hashes.splitlines():
revision_title = self.GitLog(n=1, format="%s", git_hash=git_hash) revision_title = self.GitLog(n=1, format="%s", git_hash=git_hash)
...@@ -99,6 +97,12 @@ class SearchArchitecturePorts(Step): ...@@ -99,6 +97,12 @@ class SearchArchitecturePorts(Step):
class CreateCommitMessage(Step): class CreateCommitMessage(Step):
MESSAGE = "Create commit message." MESSAGE = "Create commit message."
def _create_commit_description(self, commit_hash):
patch_merge_desc = self.GitLog(n=1, format="%s", git_hash=commit_hash)
description = "Merged: " + patch_merge_desc + "\n"
description += "Revision: " + commit_hash + "\n\n"
return description
def RunStep(self): def RunStep(self):
# Stringify: ["abcde", "12345"] -> "abcde, 12345" # Stringify: ["abcde", "12345"] -> "abcde, 12345"
...@@ -107,17 +111,23 @@ class CreateCommitMessage(Step): ...@@ -107,17 +111,23 @@ class CreateCommitMessage(Step):
if not self["revision_list"]: # pragma: no cover if not self["revision_list"]: # pragma: no cover
self.Die("Revision list is empty.") self.Die("Revision list is empty.")
action_text = "Merged %s" msg_pieces = []
# The commit message title is added below after the version is specified.
msg_pieces = [
"\n".join(action_text % s for s in self["full_revision_list"]),
]
msg_pieces.append("\n\n")
if len(self["full_revision_list"]) > 1:
self["commit_title"] = "Merged: Squashed multiple commits."
for commit_hash in self["full_revision_list"]: for commit_hash in self["full_revision_list"]:
patch_merge_desc = self.GitLog(n=1, format="%s", git_hash=commit_hash) msg_pieces.append(self._create_commit_description(commit_hash))
msg_pieces.append("%s\n\n" % patch_merge_desc) else:
commit_hash = self["full_revision_list"][0]
full_description = self._create_commit_description(commit_hash).split("\n")
#Truncate title because of code review tool
title = full_description[0]
if len(title) > 100:
title = title[:96] + " ..."
self["commit_title"] = title
msg_pieces.append(full_description[1] + "\n\n")
bugs = [] bugs = []
for commit_hash in self["full_revision_list"]: for commit_hash in self["full_revision_list"]:
...@@ -128,6 +138,8 @@ class CreateCommitMessage(Step): ...@@ -128,6 +138,8 @@ class CreateCommitMessage(Step):
if bug_aggregate: if bug_aggregate:
msg_pieces.append("BUG=%s\nLOG=N\n" % bug_aggregate) msg_pieces.append("BUG=%s\nLOG=N\n" % bug_aggregate)
msg_pieces.append("NOTRY=true\nNOPRESUBMIT=true\nNOTREECHECKS=true\n")
self["new_commit_msg"] = "".join(msg_pieces) self["new_commit_msg"] = "".join(msg_pieces)
...@@ -144,49 +156,26 @@ class ApplyPatches(Step): ...@@ -144,49 +156,26 @@ class ApplyPatches(Step):
if self._options.patch: if self._options.patch:
self.ApplyPatch(self._options.patch) self.ApplyPatch(self._options.patch)
class PrepareVersion(Step):
MESSAGE = "Prepare version file."
def RunStep(self):
# This is used to calculate the patch level increment.
self.ReadAndPersistVersion()
class IncrementVersion(Step):
MESSAGE = "Increment version number."
def RunStep(self):
new_patch = str(int(self["patch"]) + 1)
if self.Confirm("Automatically increment V8_PATCH_LEVEL? (Saying 'n' will "
"fire up your EDITOR on %s so you can make arbitrary "
"changes. When you're done, save the file and exit your "
"EDITOR.)" % VERSION_FILE):
text = FileToText(os.path.join(self.default_cwd, VERSION_FILE))
text = MSub(r"(?<=#define V8_PATCH_LEVEL)(?P<space>\s+)\d*$",
r"\g<space>%s" % new_patch,
text)
TextToFile(text, os.path.join(self.default_cwd, VERSION_FILE))
else:
self.Editor(os.path.join(self.default_cwd, VERSION_FILE))
self.ReadAndPersistVersion("new_")
self["version"] = "%s.%s.%s.%s" % (self["new_major"],
self["new_minor"],
self["new_build"],
self["new_patch"])
class CommitLocal(Step): class CommitLocal(Step):
MESSAGE = "Commit to local branch." MESSAGE = "Commit to local branch."
def RunStep(self): def RunStep(self):
# Add a commit message title. # Add a commit message title.
self["commit_title"] = "Version %s (cherry-pick)" % self["version"]
self["new_commit_msg"] = "%s\n\n%s" % (self["commit_title"], self["new_commit_msg"] = "%s\n\n%s" % (self["commit_title"],
self["new_commit_msg"]) self["new_commit_msg"])
TextToFile(self["new_commit_msg"], self.Config("COMMITMSG_FILE")) TextToFile(self["new_commit_msg"], self.Config("COMMITMSG_FILE"))
self.GitCommit(file_name=self.Config("COMMITMSG_FILE")) self.GitCommit(file_name=self.Config("COMMITMSG_FILE"))
class AddInformationalComment(Step):
MESSAGE = 'Show additional information.'
def RunStep(self):
message = ("NOTE: This script will no longer automatically "
"update include/v8-version.h "
"and create a tag. This is done automatically by the autotag bot. "
"Please call the merge_to_branch.py with --help for more information.")
self.GitCLAddComment(message)
class CommitRepository(Step): class CommitRepository(Step):
MESSAGE = "Commit to the repository." MESSAGE = "Commit to the repository."
...@@ -197,24 +186,12 @@ class CommitRepository(Step): ...@@ -197,24 +186,12 @@ class CommitRepository(Step):
self.GitPresubmit() self.GitPresubmit()
self.vc.CLLand() self.vc.CLLand()
class TagRevision(Step):
MESSAGE = "Create the tag."
def RunStep(self):
print "Creating tag %s" % self["version"]
self.vc.Tag(self["version"],
self.vc.RemoteBranch(self["merge_to_branch"]),
self["commit_title"])
class CleanUp(Step): class CleanUp(Step):
MESSAGE = "Cleanup." MESSAGE = "Cleanup."
def RunStep(self): def RunStep(self):
self.CommonCleanup() self.CommonCleanup()
print "*** SUMMARY ***" print "*** SUMMARY ***"
print "version: %s" % self["version"]
print "branch: %s" % self["merge_to_branch"] print "branch: %s" % self["merge_to_branch"]
if self["revision_list"]: if self["revision_list"]:
print "patches: %s" % self["revision_list"] print "patches: %s" % self["revision_list"]
...@@ -223,7 +200,9 @@ class CleanUp(Step): ...@@ -223,7 +200,9 @@ class CleanUp(Step):
class MergeToBranch(ScriptsBase): class MergeToBranch(ScriptsBase):
def _Description(self): def _Description(self):
return ("Performs the necessary steps to merge revisions from " return ("Performs the necessary steps to merge revisions from "
"master to other branches, including candidates.") "master to release branches like 4.5. This script does not "
"version the commit. See http://goo.gl/9ke2Vw for more "
"information.")
def _PrepareOptions(self, parser): def _PrepareOptions(self, parser):
group = parser.add_mutually_exclusive_group(required=True) group = parser.add_mutually_exclusive_group(required=True)
...@@ -250,6 +229,11 @@ class MergeToBranch(ScriptsBase): ...@@ -250,6 +229,11 @@ class MergeToBranch(ScriptsBase):
# CC ulan to make sure that fixes are merged to Google3. # CC ulan to make sure that fixes are merged to Google3.
options.cc = "ulan@chromium.org" options.cc = "ulan@chromium.org"
if len(options.branch.split('.')) > 2:
print ("This script does not support merging to roll branches. "
"Please use tools/release/roll_merge.py for this use case.")
return False
# Make sure to use git hashes in the new workflows. # Make sure to use git hashes in the new workflows.
for revision in options.revisions: for revision in options.revisions:
if (IsSvnNumber(revision) or if (IsSvnNumber(revision) or
...@@ -276,12 +260,10 @@ class MergeToBranch(ScriptsBase): ...@@ -276,12 +260,10 @@ class MergeToBranch(ScriptsBase):
SearchArchitecturePorts, SearchArchitecturePorts,
CreateCommitMessage, CreateCommitMessage,
ApplyPatches, ApplyPatches,
PrepareVersion,
IncrementVersion,
CommitLocal, CommitLocal,
UploadStep, UploadStep,
AddInformationalComment,
CommitRepository, CommitRepository,
TagRevision,
CleanUp, CleanUp,
] ]
......
This diff is collapsed.
This diff is collapsed.
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