Index: tools/push-to-trunk/push_to_trunk.py |
diff --git a/tools/push-to-trunk/push_to_trunk.py b/tools/push-to-trunk/push_to_trunk.py |
index 433688062ba1cb71e80c53c4a5a768804cd3681b..8a9629e6021449c6b4dbcb98bd4753b68ba0981b 100755 |
--- a/tools/push-to-trunk/push_to_trunk.py |
+++ b/tools/push-to-trunk/push_to_trunk.py |
@@ -34,18 +34,6 @@ import urllib2 |
from common_includes import * |
-TRUNKBRANCH = "TRUNKBRANCH" |
- |
-CONFIG = { |
- BRANCHNAME: "prepare-push", |
- TRUNKBRANCH: "trunk-push", |
- PERSISTFILE_BASENAME: "/tmp/v8-push-to-trunk-tempfile", |
- CHANGELOG_FILE: "ChangeLog", |
- CHANGELOG_ENTRY_FILE: "/tmp/v8-push-to-trunk-tempfile-changelog-entry", |
- PATCH_FILE: "/tmp/v8-push-to-trunk-tempfile-patch-file", |
- COMMITMSG_FILE: "/tmp/v8-push-to-trunk-tempfile-commitmsg", |
-} |
- |
PUSH_MESSAGE_SUFFIX = " (based on bleeding_edge revision r%d)" |
PUSH_MESSAGE_RE = re.compile(r".* \(based on bleeding_edge revision r(\d+)\)$") |
@@ -56,19 +44,19 @@ class Preparation(Step): |
self.InitialEnvironmentChecks(self.default_cwd) |
self.CommonPrepare() |
- if(self["current_branch"] == self.Config(TRUNKBRANCH) |
- or self["current_branch"] == self.Config(BRANCHNAME)): |
+ if(self["current_branch"] == self.Config("TRUNKBRANCH") |
+ or self["current_branch"] == self.Config("BRANCHNAME")): |
print "Warning: Script started on branch %s" % self["current_branch"] |
self.PrepareBranch() |
- self.DeleteBranch(self.Config(TRUNKBRANCH)) |
+ self.DeleteBranch(self.Config("TRUNKBRANCH")) |
class FreshBranch(Step): |
MESSAGE = "Create a fresh branch." |
def RunStep(self): |
- self.GitCreateBranch(self.Config(BRANCHNAME), "svn/bleeding_edge") |
+ self.GitCreateBranch(self.Config("BRANCHNAME"), "svn/bleeding_edge") |
class PreparePushRevision(Step): |
@@ -204,7 +192,7 @@ class PrepareChangeLog(Step): |
def RunStep(self): |
self["date"] = self.GetDate() |
output = "%s: Version %s\n\n" % (self["date"], self["version"]) |
- TextToFile(output, self.Config(CHANGELOG_ENTRY_FILE)) |
+ TextToFile(output, self.Config("CHANGELOG_ENTRY_FILE")) |
commits = self.GitLog(format="%H", |
git_hash="%s..%s" % (self["last_push_bleeding_edge"], |
self["push_hash"])) |
@@ -220,17 +208,17 @@ class PrepareChangeLog(Step): |
# Auto-format commit messages. |
body = MakeChangeLogBody(commit_messages, auto_format=True) |
- AppendToFile(body, self.Config(CHANGELOG_ENTRY_FILE)) |
+ AppendToFile(body, self.Config("CHANGELOG_ENTRY_FILE")) |
msg = (" Performance and stability improvements on all platforms." |
"\n#\n# The change log above is auto-generated. Please review if " |
"all relevant\n# commit messages from the list below are included." |
"\n# All lines starting with # will be stripped.\n#\n") |
- AppendToFile(msg, self.Config(CHANGELOG_ENTRY_FILE)) |
+ AppendToFile(msg, self.Config("CHANGELOG_ENTRY_FILE")) |
# Include unformatted commit messages as a reference in a comment. |
comment_body = MakeComment(MakeChangeLogBody(commit_messages)) |
- AppendToFile(comment_body, self.Config(CHANGELOG_ENTRY_FILE)) |
+ AppendToFile(comment_body, self.Config("CHANGELOG_ENTRY_FILE")) |
class EditChangeLog(Step): |
@@ -241,10 +229,10 @@ class EditChangeLog(Step): |
"entry, then edit its contents to your liking. When you're done, " |
"save the file and exit your EDITOR. ") |
self.ReadLine(default="") |
- self.Editor(self.Config(CHANGELOG_ENTRY_FILE)) |
+ self.Editor(self.Config("CHANGELOG_ENTRY_FILE")) |
# Strip comments and reformat with correct indentation. |
- changelog_entry = FileToText(self.Config(CHANGELOG_ENTRY_FILE)).rstrip() |
+ changelog_entry = FileToText(self.Config("CHANGELOG_ENTRY_FILE")).rstrip() |
changelog_entry = StripComments(changelog_entry) |
changelog_entry = "\n".join(map(Fill80, changelog_entry.splitlines())) |
changelog_entry = changelog_entry.lstrip() |
@@ -253,7 +241,7 @@ class EditChangeLog(Step): |
self.Die("Empty ChangeLog entry.") |
# Safe new change log for adding it later to the trunk patch. |
- TextToFile(changelog_entry, self.Config(CHANGELOG_ENTRY_FILE)) |
+ TextToFile(changelog_entry, self.Config("CHANGELOG_ENTRY_FILE")) |
class StragglerCommits(Step): |
@@ -272,10 +260,10 @@ class SquashCommits(Step): |
# Instead of relying on "git rebase -i", we'll just create a diff, because |
# that's easier to automate. |
TextToFile(self.GitDiff("svn/trunk", self["push_hash"]), |
- self.Config(PATCH_FILE)) |
+ self.Config("PATCH_FILE")) |
# Convert the ChangeLog entry to commit message format. |
- text = FileToText(self.Config(CHANGELOG_ENTRY_FILE)) |
+ text = FileToText(self.Config("CHANGELOG_ENTRY_FILE")) |
# Remove date and trailing white space. |
text = re.sub(r"^%s: " % self["date"], "", text.rstrip()) |
@@ -295,22 +283,22 @@ class SquashCommits(Step): |
if not text: # pragma: no cover |
self.Die("Commit message editing failed.") |
- TextToFile(text, self.Config(COMMITMSG_FILE)) |
+ TextToFile(text, self.Config("COMMITMSG_FILE")) |
class NewBranch(Step): |
MESSAGE = "Create a new branch from trunk." |
def RunStep(self): |
- self.GitCreateBranch(self.Config(TRUNKBRANCH), "svn/trunk") |
+ self.GitCreateBranch(self.Config("TRUNKBRANCH"), "svn/trunk") |
class ApplyChanges(Step): |
MESSAGE = "Apply squashed changes." |
def RunStep(self): |
- self.ApplyPatch(self.Config(PATCH_FILE)) |
- os.remove(self.Config(PATCH_FILE)) |
+ self.ApplyPatch(self.Config("PATCH_FILE")) |
+ os.remove(self.Config("PATCH_FILE")) |
class AddChangeLog(Step): |
@@ -320,12 +308,12 @@ class AddChangeLog(Step): |
# The change log has been modified by the patch. Reset it to the version |
# on trunk and apply the exact changes determined by this PrepareChangeLog |
# step above. |
- self.GitCheckoutFile(self.Config(CHANGELOG_FILE), "svn/trunk") |
- changelog_entry = FileToText(self.Config(CHANGELOG_ENTRY_FILE)) |
- old_change_log = FileToText(self.Config(CHANGELOG_FILE)) |
+ self.GitCheckoutFile(self.Config("CHANGELOG_FILE"), "svn/trunk") |
+ changelog_entry = FileToText(self.Config("CHANGELOG_ENTRY_FILE")) |
+ old_change_log = FileToText(self.Config("CHANGELOG_FILE")) |
new_change_log = "%s\n\n\n%s" % (changelog_entry, old_change_log) |
- TextToFile(new_change_log, self.Config(CHANGELOG_FILE)) |
- os.remove(self.Config(CHANGELOG_ENTRY_FILE)) |
+ TextToFile(new_change_log, self.Config("CHANGELOG_FILE")) |
+ os.remove(self.Config("CHANGELOG_ENTRY_FILE")) |
class SetVersion(Step): |
@@ -342,8 +330,8 @@ class CommitTrunk(Step): |
MESSAGE = "Commit to local trunk branch." |
def RunStep(self): |
- self.GitCommit(file_name = self.Config(COMMITMSG_FILE)) |
- os.remove(self.Config(COMMITMSG_FILE)) |
+ self.GitCommit(file_name = self.Config("COMMITMSG_FILE")) |
+ os.remove(self.Config("COMMITMSG_FILE")) |
class SanityCheck(Step): |
@@ -400,8 +388,8 @@ class CleanUp(Step): |
print "%s\ttrunk\t%s" % (self["version"], self["trunk_revision"]) |
self.CommonCleanup() |
- if self.Config(TRUNKBRANCH) != self["current_branch"]: |
- self.GitDeleteBranch(self.Config(TRUNKBRANCH)) |
+ if self.Config("TRUNKBRANCH") != self["current_branch"]: |
+ self.GitDeleteBranch(self.Config("TRUNKBRANCH")) |
class PushToTrunk(ScriptsBase): |
@@ -437,6 +425,17 @@ class PushToTrunk(ScriptsBase): |
options.tbr_commit = not options.manual |
return True |
+ def _Config(self): |
+ return { |
+ "BRANCHNAME": "prepare-push", |
+ "TRUNKBRANCH": "trunk-push", |
+ "PERSISTFILE_BASENAME": "/tmp/v8-push-to-trunk-tempfile", |
+ "CHANGELOG_FILE": "ChangeLog", |
+ "CHANGELOG_ENTRY_FILE": "/tmp/v8-push-to-trunk-tempfile-changelog-entry", |
+ "PATCH_FILE": "/tmp/v8-push-to-trunk-tempfile-patch-file", |
+ "COMMITMSG_FILE": "/tmp/v8-push-to-trunk-tempfile-commitmsg", |
+ } |
+ |
def _Steps(self): |
return [ |
Preparation, |
@@ -462,4 +461,4 @@ class PushToTrunk(ScriptsBase): |
if __name__ == "__main__": # pragma: no cover |
- sys.exit(PushToTrunk(CONFIG).Run()) |
+ sys.exit(PushToTrunk().Run()) |