| OLD | NEW |
| (Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright 2013 the V8 project authors. All rights reserved. |
| 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are |
| 5 # met: |
| 6 # |
| 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following |
| 11 # disclaimer in the documentation and/or other materials provided |
| 12 # with the distribution. |
| 13 # * Neither the name of Google Inc. nor the names of its |
| 14 # contributors may be used to endorse or promote products derived |
| 15 # from this software without specific prior written permission. |
| 16 # |
| 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 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. |
| 28 |
| 29 import optparse |
| 30 import re |
| 31 import sys |
| 32 |
| 33 from common_includes import * |
| 34 |
| 35 CONFIG = { |
| 36 PERSISTFILE_BASENAME: "/tmp/v8-auto-roll-tempfile", |
| 37 DOT_GIT_LOCATION: ".git", |
| 38 } |
| 39 |
| 40 |
| 41 class Preparation(Step): |
| 42 MESSAGE = "Preparation." |
| 43 |
| 44 def RunStep(self): |
| 45 self.InitialEnvironmentChecks() |
| 46 self.CommonPrepare() |
| 47 |
| 48 |
| 49 class FetchLatestRevision(Step): |
| 50 MESSAGE = "Fetching latest V8 revision." |
| 51 |
| 52 def RunStep(self): |
| 53 log = self.Git("svn log -1 --oneline").strip() |
| 54 match = re.match(r"^r(\d+) ", log) |
| 55 if not match: |
| 56 self.Die("Could not extract current svn revision from log.") |
| 57 self.Persist("latest", match.group(1)) |
| 58 |
| 59 |
| 60 class FetchLKGR(Step): |
| 61 MESSAGE = "Fetching V8 LKGR." |
| 62 |
| 63 def RunStep(self): |
| 64 lkgr_url = "https://v8-status.appspot.com/lkgr" |
| 65 self.Persist("lkgr", self.ReadURL(lkgr_url)) |
| 66 |
| 67 |
| 68 class PushToTrunk(Step): |
| 69 MESSAGE = "Pushing to trunk if possible." |
| 70 |
| 71 def RunStep(self): |
| 72 self.RestoreIfUnset("latest") |
| 73 self.RestoreIfUnset("lkgr") |
| 74 latest = int(self._state["latest"]) |
| 75 lkgr = int(self._state["lkgr"]) |
| 76 if latest == lkgr: |
| 77 print "ToT (r%d) is clean. Pushing to trunk." % latest |
| 78 # TODO(machenbach): Call push to trunk script. |
| 79 else: |
| 80 print("ToT (r%d) is ahead of the LKGR (r%d). Skipping push to trunk." |
| 81 % (latest, lkgr)) |
| 82 |
| 83 |
| 84 def RunAutoRoll(config, |
| 85 options, |
| 86 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER): |
| 87 step_classes = [ |
| 88 Preparation, |
| 89 FetchLatestRevision, |
| 90 FetchLKGR, |
| 91 PushToTrunk, |
| 92 ] |
| 93 RunScript(step_classes, config, options, side_effect_handler) |
| 94 |
| 95 |
| 96 def BuildOptions(): |
| 97 result = optparse.OptionParser() |
| 98 result.add_option("-s", "--step", dest="s", |
| 99 help="Specify the step where to start work. Default: 0.", |
| 100 default=0, type="int") |
| 101 return result |
| 102 |
| 103 |
| 104 def Main(): |
| 105 parser = BuildOptions() |
| 106 (options, args) = parser.parse_args() |
| 107 RunAutoRoll(CONFIG, options) |
| 108 |
| 109 if __name__ == "__main__": |
| 110 sys.exit(Main()) |
| OLD | NEW |