| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 the V8 project authors. All rights reserved. | 2 # Copyright 2013 the V8 project authors. All rights reserved. |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following | 10 # copyright notice, this list of conditions and the following |
| 11 # disclaimer in the documentation and/or other materials provided | 11 # disclaimer in the documentation and/or other materials provided |
| 12 # with the distribution. | 12 # with the distribution. |
| 13 # * Neither the name of Google Inc. nor the names of its | 13 # * Neither the name of Google Inc. nor the names of its |
| 14 # contributors may be used to endorse or promote products derived | 14 # contributors may be used to endorse or promote products derived |
| 15 # from this software without specific prior written permission. | 15 # from this software without specific prior written permission. |
| 16 # | 16 # |
| 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | 28 |
| 29 import json |
| 29 import optparse | 30 import optparse |
| 31 import os |
| 30 import re | 32 import re |
| 31 import sys | 33 import sys |
| 32 | 34 |
| 33 from common_includes import * | 35 from common_includes import * |
| 34 | 36 |
| 37 SETTINGS_LOCATION = "SETTINGS_LOCATION" |
| 38 |
| 35 CONFIG = { | 39 CONFIG = { |
| 36 PERSISTFILE_BASENAME: "/tmp/v8-auto-roll-tempfile", | 40 PERSISTFILE_BASENAME: "/tmp/v8-auto-roll-tempfile", |
| 37 DOT_GIT_LOCATION: ".git", | 41 DOT_GIT_LOCATION: ".git", |
| 42 SETTINGS_LOCATION: "~/.auto-roll", |
| 38 } | 43 } |
| 39 | 44 |
| 40 | 45 |
| 41 class AutoRollOptions(CommonOptions): | 46 class AutoRollOptions(CommonOptions): |
| 42 def __init__(self, options): | 47 def __init__(self, options): |
| 43 super(AutoRollOptions, self).__init__(options) | 48 super(AutoRollOptions, self).__init__(options) |
| 44 self.requires_editor = False | 49 self.requires_editor = False |
| 45 | 50 |
| 46 | 51 |
| 47 class Preparation(Step): | 52 class Preparation(Step): |
| 48 MESSAGE = "Preparation." | 53 MESSAGE = "Preparation." |
| 49 | 54 |
| 50 def RunStep(self): | 55 def RunStep(self): |
| 51 self.InitialEnvironmentChecks() | 56 self.InitialEnvironmentChecks() |
| 52 self.CommonPrepare() | 57 self.CommonPrepare() |
| 53 | 58 |
| 54 | 59 |
| 60 class CheckAutoRollSettings(Step): |
| 61 MESSAGE = "Checking settings file." |
| 62 |
| 63 def RunStep(self): |
| 64 settings_file = os.path.realpath(self.Config(SETTINGS_LOCATION)) |
| 65 if os.path.exists(settings_file): |
| 66 settings_dict = json.loads(FileToText(settings_file)) |
| 67 if settings_dict.get("enable_auto_roll") is False: |
| 68 self.Die("Push to trunk disabled by auto-roll settings file: %s" |
| 69 % settings_file) |
| 70 |
| 71 |
| 72 class CheckTreeStatus(Step): |
| 73 MESSAGE = "Checking v8 tree status message." |
| 74 |
| 75 def RunStep(self): |
| 76 status_url = "https://v8-status.appspot.com/current?format=json" |
| 77 status_json = self.ReadURL(status_url, wait_plan=[5, 20, 300, 300]) |
| 78 message = json.loads(status_json)["message"] |
| 79 if re.search(r"nopush|no push", message, flags=re.I): |
| 80 self.Die("Push to trunk disabled by tree state: %s" % message) |
| 81 |
| 82 |
| 55 class FetchLatestRevision(Step): | 83 class FetchLatestRevision(Step): |
| 56 MESSAGE = "Fetching latest V8 revision." | 84 MESSAGE = "Fetching latest V8 revision." |
| 57 | 85 |
| 58 def RunStep(self): | 86 def RunStep(self): |
| 59 log = self.Git("svn log -1 --oneline").strip() | 87 log = self.Git("svn log -1 --oneline").strip() |
| 60 match = re.match(r"^r(\d+) ", log) | 88 match = re.match(r"^r(\d+) ", log) |
| 61 if not match: | 89 if not match: |
| 62 self.Die("Could not extract current svn revision from log.") | 90 self.Die("Could not extract current svn revision from log.") |
| 63 self.Persist("latest", match.group(1)) | 91 self.Persist("latest", match.group(1)) |
| 64 | 92 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 else: | 136 else: |
| 109 print("ToT (r%d) is ahead of the LKGR (r%d). Skipping push to trunk." | 137 print("ToT (r%d) is ahead of the LKGR (r%d). Skipping push to trunk." |
| 110 % (latest, lkgr)) | 138 % (latest, lkgr)) |
| 111 | 139 |
| 112 | 140 |
| 113 def RunAutoRoll(config, | 141 def RunAutoRoll(config, |
| 114 options, | 142 options, |
| 115 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER): | 143 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER): |
| 116 step_classes = [ | 144 step_classes = [ |
| 117 Preparation, | 145 Preparation, |
| 146 CheckAutoRollSettings, |
| 147 CheckTreeStatus, |
| 118 FetchLatestRevision, | 148 FetchLatestRevision, |
| 119 CheckLastPush, | 149 CheckLastPush, |
| 120 FetchLKGR, | 150 FetchLKGR, |
| 121 PushToTrunk, | 151 PushToTrunk, |
| 122 ] | 152 ] |
| 123 RunScript(step_classes, config, options, side_effect_handler) | 153 RunScript(step_classes, config, options, side_effect_handler) |
| 124 | 154 |
| 125 | 155 |
| 126 def BuildOptions(): | 156 def BuildOptions(): |
| 127 result = optparse.OptionParser() | 157 result = optparse.OptionParser() |
| (...skipping 12 matching lines...) Expand all Loading... |
| 140 parser = BuildOptions() | 170 parser = BuildOptions() |
| 141 (options, args) = parser.parse_args() | 171 (options, args) = parser.parse_args() |
| 142 if not options.c or not options.r: | 172 if not options.c or not options.r: |
| 143 print "You need to specify the chromium src location and a reviewer." | 173 print "You need to specify the chromium src location and a reviewer." |
| 144 parser.print_help() | 174 parser.print_help() |
| 145 return 1 | 175 return 1 |
| 146 RunAutoRoll(CONFIG, AutoRollOptions(options)) | 176 RunAutoRoll(CONFIG, AutoRollOptions(options)) |
| 147 | 177 |
| 148 if __name__ == "__main__": | 178 if __name__ == "__main__": |
| 149 sys.exit(Main()) | 179 sys.exit(Main()) |
| OLD | NEW |