Add last-push check to automatic push-to-trunk script.

Make sure the script is not trying a push-to-trunk twice in a row.

This also passes through some command line parameters.

TEST=python -m unittest test_scripts.ScriptTest.testCheckLastPushRecently
R=ulan@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18306 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 7a8a098a
......@@ -57,6 +57,24 @@ class FetchLatestRevision(Step):
self.Persist("latest", match.group(1))
class CheckLastPush(Step):
MESSAGE = "Checking last V8 push to trunk."
def RunStep(self):
self.RestoreIfUnset("latest")
log = self.Git("svn log -1 --oneline ChangeLog").strip()
match = re.match(r"^r(\d+) \| Prepare push to trunk", log)
if match:
latest = int(self._state["latest"])
last_push = int(match.group(1))
# TODO(machebach): This metric counts all revisions. It could be
# improved by counting only the revisions on bleeding_edge.
if latest - last_push < 10:
# This makes sure the script doesn't push twice in a row when the cron
# job retries several times.
self.Die("Last push too recently: %d" % last_push)
class FetchLKGR(Step):
MESSAGE = "Fetching V8 LKGR."
......@@ -77,6 +95,10 @@ class PushToTrunk(Step):
if latest == lkgr:
print "ToT (r%d) is clean. Pushing to trunk." % latest
# TODO(machenbach): Call push to trunk script.
# TODO(machenbach): Update the script before calling it.
# self._side_effect_handler.Command(
# "tools/push-to-trunk/push-to-trunk.py",
# "-f -c %s -r %s" % (self._options.c, self._options.r))
else:
print("ToT (r%d) is ahead of the LKGR (r%d). Skipping push to trunk."
% (latest, lkgr))
......@@ -88,6 +110,7 @@ def RunAutoRoll(config,
step_classes = [
Preparation,
FetchLatestRevision,
CheckLastPush,
FetchLKGR,
PushToTrunk,
]
......@@ -96,9 +119,11 @@ def RunAutoRoll(config,
def BuildOptions():
result = optparse.OptionParser()
result.add_option("-f", "--force", dest="f",
help="Don't prompt the user.",
default=True, action="store_true")
result.add_option("-c", "--chromium", dest="c",
help=("Specify the path to your Chromium src/ "
"directory to automate the V8 roll."))
result.add_option("-r", "--reviewer", dest="r",
help=("Specify the account name to be used for reviews."))
result.add_option("-s", "--step", dest="s",
help="Specify the step where to start work. Default: 0.",
default=0, type="int")
......@@ -108,6 +133,10 @@ def BuildOptions():
def Main():
parser = BuildOptions()
(options, args) = parser.parse_args()
if not options.c or not options.r:
print "You need to specify the chromium src location and a reviewer."
parser.print_help()
return 1
RunAutoRoll(CONFIG, options)
if __name__ == "__main__":
......
......@@ -35,6 +35,8 @@ from common_includes import *
import push_to_trunk
from push_to_trunk import *
import auto_roll
from auto_roll import FetchLatestRevision
from auto_roll import CheckLastPush
TEST_CONFIG = {
......@@ -731,6 +733,16 @@ Performance and stability improvements on all platforms."""
def testPushToTrunkForced(self):
self._PushToTrunk(force=True)
def testCheckLastPushRecently(self):
self.ExpectGit([
["svn log -1 --oneline", "r101 | Text"],
["svn log -1 --oneline ChangeLog", "r99 | Prepare push to trunk..."],
])
state = {}
self.MakeStep(FetchLatestRevision, state=state).Run()
self.assertRaises(Exception, self.MakeStep(CheckLastPush, state=state).Run)
def testAutoRoll(self):
TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
......@@ -744,6 +756,7 @@ Performance and stability improvements on all platforms."""
["status -s -b -uno", "## some_branch\n"],
["svn fetch", ""],
["svn log -1 --oneline", "r101 | Text"],
["svn log -1 --oneline ChangeLog", "r65 | Prepare push to trunk..."],
])
auto_roll.RunAutoRoll(TEST_CONFIG, MakeOptions(m=False, f=True), self)
......
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