| Index: tools/push-to-trunk/auto_roll.py
|
| diff --git a/tools/push-to-trunk/auto_roll.py b/tools/push-to-trunk/auto_roll.py
|
| index 2c71041d0295ac6191fdc5cb6485c9eb5bbc159f..ac2067c61ecc96111e07e002fdaefd9c29cf96be 100755
|
| --- a/tools/push-to-trunk/auto_roll.py
|
| +++ b/tools/push-to-trunk/auto_roll.py
|
| @@ -26,8 +26,8 @@
|
| # (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 argparse
|
| import json
|
| +import optparse
|
| import os
|
| import re
|
| import sys
|
| @@ -52,9 +52,9 @@ class AutoRollOptions(CommonOptions):
|
| super(AutoRollOptions, self).__init__(options)
|
| self.requires_editor = False
|
| self.status_password = options.status_password
|
| + self.r = options.r
|
| self.c = options.c
|
| self.push = getattr(options, 'push', False)
|
| - self.author = getattr(options, 'a', None)
|
|
|
|
|
| class Preparation(Step):
|
| @@ -83,35 +83,39 @@ class CheckTreeStatus(Step):
|
| def RunStep(self):
|
| status_url = "https://v8-status.appspot.com/current?format=json"
|
| status_json = self.ReadURL(status_url, wait_plan=[5, 20, 300, 300])
|
| - self["tree_message"] = json.loads(status_json)["message"]
|
| - if re.search(r"nopush|no push", self["tree_message"], flags=re.I):
|
| - self.Die("Push to trunk disabled by tree state: %s"
|
| - % self["tree_message"])
|
| + message = json.loads(status_json)["message"]
|
| + if re.search(r"nopush|no push", message, flags=re.I):
|
| + self.Die("Push to trunk disabled by tree state: %s" % message)
|
| + self.Persist("tree_message", message)
|
|
|
|
|
| class FetchLatestRevision(Step):
|
| MESSAGE = "Fetching latest V8 revision."
|
|
|
| def RunStep(self):
|
| - match = re.match(r"^r(\d+) ", self.GitSVNLog())
|
| + log = self.Git("svn log -1 --oneline").strip()
|
| + match = re.match(r"^r(\d+) ", log)
|
| if not match:
|
| self.Die("Could not extract current svn revision from log.")
|
| - self["latest"] = match.group(1)
|
| + self.Persist("latest", match.group(1))
|
|
|
|
|
| class CheckLastPush(Step):
|
| MESSAGE = "Checking last V8 push to trunk."
|
|
|
| def RunStep(self):
|
| - last_push_hash = self.FindLastTrunkPush()
|
| - last_push = int(self.GitSVNFindSVNRev(last_push_hash))
|
| -
|
| - # TODO(machenbach): This metric counts all revisions. It could be
|
| - # improved by counting only the revisions on bleeding_edge.
|
| - if int(self["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)
|
| + 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):
|
| @@ -120,7 +124,7 @@ class FetchLKGR(Step):
|
| def RunStep(self):
|
| lkgr_url = "https://v8-status.appspot.com/lkgr"
|
| # Retry several times since app engine might have issues.
|
| - self["lkgr"] = self.ReadURL(lkgr_url, wait_plan=[5, 20, 300, 300])
|
| + self.Persist("lkgr", self.ReadURL(lkgr_url, wait_plan=[5, 20, 300, 300]))
|
|
|
|
|
| class PushToTrunk(Step):
|
| @@ -141,24 +145,27 @@ class PushToTrunk(Step):
|
| wait_plan=[5, 20])
|
|
|
| def RunStep(self):
|
| - latest = int(self["latest"])
|
| - lkgr = int(self["lkgr"])
|
| + self.RestoreIfUnset("latest")
|
| + self.RestoreIfUnset("lkgr")
|
| + self.RestoreIfUnset("tree_message")
|
| + latest = int(self._state["latest"])
|
| + lkgr = int(self._state["lkgr"])
|
| if latest == lkgr:
|
| print "ToT (r%d) is clean. Pushing to trunk." % latest
|
| self.PushTreeStatus("Tree is closed (preparing to push)")
|
|
|
| + # TODO(machenbach): Call push to trunk script.
|
| # TODO(machenbach): Update the script before calling it.
|
| try:
|
| if self._options.push:
|
| self._side_effect_handler.Call(
|
| RunPushToTrunk,
|
| push_to_trunk.CONFIG,
|
| - PushToTrunkOptions.MakeForcedOptions(self._options.author,
|
| - self._options.reviewer,
|
| + PushToTrunkOptions.MakeForcedOptions(self._options.r,
|
| self._options.c),
|
| self._side_effect_handler)
|
| finally:
|
| - self.PushTreeStatus(self["tree_message"])
|
| + self.PushTreeStatus(self._state["tree_message"])
|
| else:
|
| print("ToT (r%d) is ahead of the LKGR (r%d). Skipping push to trunk."
|
| % (latest, lkgr))
|
| @@ -180,30 +187,28 @@ def RunAutoRoll(config,
|
|
|
|
|
| def BuildOptions():
|
| - parser = argparse.ArgumentParser()
|
| - parser.add_argument("-a", "--author", dest="a",
|
| - help="The author email used for rietveld.")
|
| - parser.add_argument("-c", "--chromium", dest="c",
|
| - help=("The path to your Chromium src/ directory to "
|
| - "automate the V8 roll."))
|
| - parser.add_argument("-p", "--push",
|
| - help="Push to trunk if possible. Dry run if unspecified.",
|
| - default=False, action="store_true")
|
| - parser.add_argument("-r", "--reviewer",
|
| - help="The account name to be used for reviews.")
|
| - parser.add_argument("-s", "--step", dest="s",
|
| - help="Specify the step where to start work. Default: 0.",
|
| - default=0, type=int)
|
| - parser.add_argument("--status-password",
|
| - help="A file with the password to the status app.")
|
| - return parser
|
| + result = optparse.OptionParser()
|
| + result.add_option("-c", "--chromium", dest="c",
|
| + help=("Specify the path to your Chromium src/ "
|
| + "directory to automate the V8 roll."))
|
| + result.add_option("-p", "--push",
|
| + help="Push to trunk if possible. Dry run if unspecified.",
|
| + 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",
|
| + help="Specify the step where to start work. Default: 0.",
|
| + default=0, type="int")
|
| + result.add_option("--status-password",
|
| + help="A file with the password to the status app.")
|
| + return result
|
|
|
|
|
| def Main():
|
| parser = BuildOptions()
|
| - options = parser.parse_args()
|
| - if not options.a or not options.c or not options.reviewer:
|
| - print "You need to specify author, chromium src location and reviewer."
|
| + (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, AutoRollOptions(options))
|
|
|