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

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

Issue 112863002: Merge bleeding_edge 18021:18297 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years 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 | « tools/push-to-trunk/common_includes.py ('k') | tools/push-to-trunk/test_scripts.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 24dfb676805a29cbdca11166c3fdfe71e9c338b5..58e2cb924d74f7b83d8a0541b891b5ffe9c83146 100755
--- a/tools/push-to-trunk/push_to_trunk.py
+++ b/tools/push-to-trunk/push_to_trunk.py
@@ -26,10 +26,10 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-import datetime
import optparse
import sys
import tempfile
+import urllib2
from common_includes import *
@@ -91,13 +91,30 @@ class DetectLastPush(Step):
class PrepareChangeLog(Step):
MESSAGE = "Prepare raw ChangeLog entry."
+ def Reload(self, body):
+ """Attempts to reload the commit message from rietveld in order to allow
+ late changes to the LOG flag. Note: This is brittle to future changes of
+ the web page name or structure.
+ """
+ match = re.search(r"^Review URL: https://codereview\.chromium\.org/(\d+)$",
+ body, flags=re.M)
+ if match:
+ cl_url = "https://codereview.chromium.org/%s/description" % match.group(1)
+ try:
+ # Fetch from Rietveld but only retry once with one second delay since
+ # there might be many revisions.
+ body = self.ReadURL(cl_url, wait_plan=[1])
+ except urllib2.URLError:
+ pass
+ return body
+
def RunStep(self):
self.RestoreIfUnset("last_push")
# These version numbers are used again later for the trunk commit.
self.ReadAndPersistVersion()
- date = datetime.date.today().strftime("%Y-%m-%d")
+ date = self.GetDate()
self.Persist("date", date)
output = "%s: Version %s.%s.%s\n\n" % (date,
self._state["major"],
@@ -112,7 +129,7 @@ class PrepareChangeLog(Step):
commit_messages = [
[
self.Git("log -1 %s --format=\"%%s\"" % commit),
- self.Git("log -1 %s --format=\"%%B\"" % commit),
+ self.Reload(self.Git("log -1 %s --format=\"%%B\"" % commit)),
self.Git("log -1 %s --format=\"%%an\"" % commit),
] for commit in commits.splitlines()
]
@@ -140,9 +157,6 @@ 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="")
-
- # TODO(machenbach): Don't use EDITOR in forced mode as soon as script is
- # well tested.
self.Editor(self.Config(CHANGELOG_ENTRY_FILE))
handle, new_changelog = tempfile.mkstemp()
os.close(handle)
@@ -151,6 +165,7 @@ class EditChangeLog(Step):
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()
if changelog_entry == "":
self.Die("Empty ChangeLog entry.")
@@ -196,7 +211,11 @@ class CommitLocal(Step):
self._state["new_minor"],
self._state["new_build"]))
self.Persist("prep_commit_msg", prep_commit_msg)
- if self.Git("commit -a -m \"%s\"" % prep_commit_msg) is None:
+
+ # Include optional TBR only in the git command. The persisted commit
+ # message is used for finding the commit again later.
+ review = "\n\nTBR=%s" % self._options.r if not self.IsManual() else ""
+ if self.Git("commit -a -m \"%s%s\"" % (prep_commit_msg, review)) is None:
self.Die("'git commit -a' failed.")
@@ -346,7 +365,7 @@ class CommitSVN(Step):
print("Sorry, grepping for the SVN revision failed. Please look for it "
"in the last command's output above and provide it manually (just "
"the number, without the leading \"r\").")
- self.DieInForcedMode("Can't prompt in forced mode.")
+ self.DieNoManualMode("Can't prompt in forced mode.")
while not trunk_revision:
print "> ",
trunk_revision = self.ReadLine()
@@ -371,7 +390,7 @@ class CheckChromium(Step):
def Run(self):
chrome_path = self._options.c
if not chrome_path:
- self.DieInForcedMode("Please specify the path to a Chromium checkout in "
+ self.DieNoManualMode("Please specify the path to a Chromium checkout in "
"forced mode.")
print ("Do you have a \"NewGit\" Chromium checkout and want "
"this script to automate creation of the roll CL? If yes, enter the "
@@ -439,12 +458,12 @@ class UploadCL(Step):
rev = self._options.r
else:
print "Please enter the email address of a reviewer for the roll CL: ",
- self.DieInForcedMode("A reviewer must be specified in forced mode.")
+ self.DieNoManualMode("A reviewer must be specified in forced mode.")
rev = self.ReadLine()
args = "commit -am \"Update V8 to version %s.\n\nTBR=%s\"" % (ver, rev)
if self.Git(args) is None:
self.Die("'git commit' failed.")
- force_flag = " -f" if self._options.f else ""
+ force_flag = " -f" if not self.IsManual() else ""
if self.Git("cl upload --send-mail%s" % force_flag, pipe=False) is None:
self.Die("'git cl upload' failed, please try again.")
print "CL uploaded."
@@ -529,6 +548,9 @@ def BuildOptions():
result.add_option("-l", "--last-push", dest="l",
help=("Manually specify the git commit ID "
"of the last push to trunk."))
+ result.add_option("-m", "--manual", dest="m",
+ help="Prompt the user at every important step.",
+ default=False, action="store_true")
result.add_option("-r", "--reviewer", dest="r",
help=("Specify the account name to be used for reviews."))
result.add_option("-s", "--step", dest="s",
@@ -541,6 +563,15 @@ def ProcessOptions(options):
if options.s < 0:
print "Bad step number %d" % options.s
return False
+ if not options.m and not options.r:
+ print "A reviewer (-r) is required in (semi-)automatic mode."
+ return False
+ if options.f and options.m:
+ print "Manual and forced mode cannot be combined."
+ return False
+ if not options.m and not options.c:
+ print "A chromium checkout (-c) is required in (semi-)automatic mode."
+ return False
return True
« no previous file with comments | « tools/push-to-trunk/common_includes.py ('k') | tools/push-to-trunk/test_scripts.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698