Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1450)

Unified Diff: tools/push-to-trunk/merge_to_branch.py

Issue 702843002: Make merge_to_branch more git-friendly. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/push-to-trunk/releases.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/push-to-trunk/merge_to_branch.py
diff --git a/tools/push-to-trunk/merge_to_branch.py b/tools/push-to-trunk/merge_to_branch.py
index 927e504f7af7715a421960be8de8a87e8be86824..c4a5f4760890f1b4e7447ac2ff2171a42e499336 100755
--- a/tools/push-to-trunk/merge_to_branch.py
+++ b/tools/push-to-trunk/merge_to_branch.py
@@ -32,6 +32,9 @@ import sys
from common_includes import *
+def IsSvnNumber(rev):
+ return rev.isdigit() and len(rev) < 8
+
class Preparation(Step):
MESSAGE = "Preparation."
@@ -72,24 +75,21 @@ class SearchArchitecturePorts(Step):
self._options.revisions))
port_revision_list = []
for revision in self["full_revision_list"]:
- # Search for commits which matches the "Port rXXX" pattern.
+ # Search for commits which matches the "Port XXX" pattern.
git_hashes = self.GitLog(reverse=True, format="%H",
- grep="Port r%d" % int(revision),
+ grep="Port %s" % revision,
branch=self.vc.RemoteMasterBranch())
for git_hash in git_hashes.splitlines():
- svn_revision = self.vc.GitSvn(git_hash, self.vc.RemoteMasterBranch())
- if not svn_revision: # pragma: no cover
- self.Die("Cannot determine svn revision for %s" % git_hash)
revision_title = self.GitLog(n=1, format="%s", git_hash=git_hash)
# Is this revision included in the original revision list?
- if svn_revision in self["full_revision_list"]:
- print("Found port of r%s -> r%s (already included): %s"
- % (revision, svn_revision, revision_title))
+ if git_hash in self["full_revision_list"]:
+ print("Found port of %s -> %s (already included): %s"
+ % (revision, git_hash, revision_title))
else:
- print("Found port of r%s -> r%s: %s"
- % (revision, svn_revision, revision_title))
- port_revision_list.append(svn_revision)
+ print("Found port of %s -> %s: %s"
+ % (revision, git_hash, revision_title))
+ port_revision_list.append(git_hash)
# Do we find any port?
if len(port_revision_list) > 0:
@@ -99,16 +99,10 @@ class SearchArchitecturePorts(Step):
self["full_revision_list"].extend(port_revision_list)
-class FindGitRevisions(Step):
- MESSAGE = "Find the git revisions associated with the patches."
+class CreateCommitMessage(Step):
+ MESSAGE = "Create commit message."
def RunStep(self):
- self["patch_commit_hashes"] = []
- for revision in self["full_revision_list"]:
- next_hash = self.vc.SvnGit(revision, self.vc.RemoteMasterBranch())
- if not next_hash: # pragma: no cover
- self.Die("Cannot determine git hash for r%s" % revision)
- self["patch_commit_hashes"].append(next_hash)
# Stringify: [123, 234] -> "r123, r234"
self["revision_list"] = ", ".join(map(lambda s: "r%s" % s,
@@ -117,15 +111,21 @@ class FindGitRevisions(Step):
if not self["revision_list"]: # pragma: no cover
self.Die("Revision list is empty.")
+ if self._options.revert and not self._options.revert_bleeding_edge:
+ action_text = "Rollback of %s"
+ else:
+ action_text = "Merged %s"
# The commit message title is added below after the version is specified.
- self["new_commit_msg"] = ""
+ self["new_commit_msg"] = "\n".join(map(lambda s: action_text % s,
+ self["full_revision_list"]))
tandrii(chromium) 2014/11/05 12:59:15 I think this is shorter and more readable: join(ac
Michael Achenbach 2014/11/05 13:30:37 Done.
+ self["new_commit_msg"] += "\n\n"
- for commit_hash in self["patch_commit_hashes"]:
+ for commit_hash in self["full_revision_list"]:
patch_merge_desc = self.GitLog(n=1, format="%s", git_hash=commit_hash)
self["new_commit_msg"] += "%s\n\n" % patch_merge_desc
bugs = []
- for commit_hash in self["patch_commit_hashes"]:
+ for commit_hash in self["full_revision_list"]:
msg = self.GitLog(n=1, git_hash=commit_hash)
for bug in re.findall(r"^[ \t]*BUG[ \t]*=[ \t]*(.*?)[ \t]*$", msg,
re.M):
@@ -139,7 +139,7 @@ class ApplyPatches(Step):
MESSAGE = "Apply patches for selected revisions."
def RunStep(self):
- for commit_hash in self["patch_commit_hashes"]:
+ for commit_hash in self["full_revision_list"]:
print("Applying patch for %s to %s..."
% (commit_hash, self["merge_to_branch"]))
patch = self.GitGetPatch(commit_hash)
@@ -189,17 +189,14 @@ class CommitLocal(Step):
def RunStep(self):
# Add a commit message title.
- if self._options.revert:
- if not self._options.revert_bleeding_edge:
- title = ("Version %s (rollback of %s)"
- % (self["version"], self["revision_list"]))
- else:
- title = "Revert %s." % self["revision_list"]
+ if self._options.revert and self._options.revert_bleeding_edge:
+ # TODO(machenbach): Find a better convention if multiple patches are
+ # reverted in one CL.
+ self["commit_title"] = "Revert on master"
else:
- title = ("Version %s (merged %s)"
- % (self["version"], self["revision_list"]))
- self["commit_title"] = title
- self["new_commit_msg"] = "%s\n\n%s" % (title, self["new_commit_msg"])
+ self["commit_title"] = "Version %s (cherry-pick)" % self["version"]
+ self["new_commit_msg"] = "%s\n\n%s" % (self["commit_title"],
+ self["new_commit_msg"])
TextToFile(self["new_commit_msg"], self.Config("COMMITMSG_FILE"))
self.GitCommit(file_name=self.Config("COMMITMSG_FILE"))
@@ -275,6 +272,17 @@ class MergeToBranch(ScriptsBase):
options.bypass_upload_hooks = True
# CC ulan to make sure that fixes are merged to Google3.
options.cc = "ulan@chromium.org"
+
+ # Thd old git-svn workflow is deprecated for this script.
+ assert options.vc_interface != "git_svn"
+
+ # Make sure to use git hashes in the new workflows.
+ for revision in options.revisions:
+ if (IsSvnNumber(revision) or
+ (revision[0:1] == "r" and IsSvnNumber(revision[1:]))):
+ print "Please provide full git hashes of the patches to merge."
+ print "Got: %s" % revision
+ return False
return True
def _Config(self):
@@ -292,7 +300,7 @@ class MergeToBranch(ScriptsBase):
Preparation,
CreateBranch,
SearchArchitecturePorts,
- FindGitRevisions,
+ CreateCommitMessage,
ApplyPatches,
PrepareVersion,
IncrementVersion,
« no previous file with comments | « no previous file | tools/push-to-trunk/releases.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698