| 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 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 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 optparse | 29 import optparse |
| 30 import re | 30 import re |
| 31 import sys | 31 import sys |
| 32 import urllib2 | |
| 33 | 32 |
| 34 from common_includes import * | 33 from common_includes import * |
| 35 | 34 |
| 36 CONFIG = { | 35 CONFIG = { |
| 37 PERSISTFILE_BASENAME: "/tmp/v8-auto-roll-tempfile", | 36 PERSISTFILE_BASENAME: "/tmp/v8-auto-roll-tempfile", |
| 38 DOT_GIT_LOCATION: ".git", | 37 DOT_GIT_LOCATION: ".git", |
| 39 } | 38 } |
| 40 | 39 |
| 41 | 40 |
| 42 class Preparation(Step): | 41 class Preparation(Step): |
| 43 def __init__(self): | 42 MESSAGE = "Preparation." |
| 44 Step.__init__(self, "Preparation.") | |
| 45 | 43 |
| 46 def RunStep(self): | 44 def RunStep(self): |
| 47 self.InitialEnvironmentChecks() | 45 self.InitialEnvironmentChecks() |
| 48 self.CommonPrepare() | 46 self.CommonPrepare() |
| 49 | 47 |
| 50 | 48 |
| 51 class FetchLatestRevision(Step): | 49 class FetchLatestRevision(Step): |
| 52 def __init__(self): | 50 MESSAGE = "Fetching latest V8 revision." |
| 53 Step.__init__(self, "Fetching latest V8 revision.") | |
| 54 | 51 |
| 55 def RunStep(self): | 52 def RunStep(self): |
| 56 log = self.Git("svn log -1 --oneline").strip() | 53 log = self.Git("svn log -1 --oneline").strip() |
| 57 match = re.match(r"^r(\d+) ", log) | 54 match = re.match(r"^r(\d+) ", log) |
| 58 if not match: | 55 if not match: |
| 59 self.Die("Could not extract current svn revision from log.") | 56 self.Die("Could not extract current svn revision from log.") |
| 60 self.Persist("latest", match.group(1)) | 57 self.Persist("latest", match.group(1)) |
| 61 | 58 |
| 62 | 59 |
| 63 class FetchLKGR(Step): | 60 class FetchLKGR(Step): |
| 64 def __init__(self): | 61 MESSAGE = "Fetching V8 LKGR." |
| 65 Step.__init__(self, "Fetching V8 LKGR.") | |
| 66 | 62 |
| 67 def RunStep(self): | 63 def RunStep(self): |
| 68 lkgr_url = "https://v8-status.appspot.com/lkgr" | 64 lkgr_url = "https://v8-status.appspot.com/lkgr" |
| 69 try: | 65 self.Persist("lkgr", self.ReadURL(lkgr_url)) |
| 70 # pylint: disable=E1121 | |
| 71 url_fh = urllib2.urlopen(lkgr_url, None, 60) | |
| 72 except urllib2.URLError: | |
| 73 self.Die("URLException while fetching %s" % lkgr_url) | |
| 74 try: | |
| 75 self.Persist("lkgr", url_fh.read()) | |
| 76 finally: | |
| 77 url_fh.close() | |
| 78 | 66 |
| 79 | 67 |
| 80 class PushToTrunk(Step): | 68 class PushToTrunk(Step): |
| 81 def __init__(self): | 69 MESSAGE = "Pushing to trunk if possible." |
| 82 Step.__init__(self, "Pushing to trunk if possible.") | |
| 83 | 70 |
| 84 def RunStep(self): | 71 def RunStep(self): |
| 85 self.RestoreIfUnset("latest") | 72 self.RestoreIfUnset("latest") |
| 86 self.RestoreIfUnset("lkgr") | 73 self.RestoreIfUnset("lkgr") |
| 87 latest = int(self._state["latest"]) | 74 latest = int(self._state["latest"]) |
| 88 lkgr = int(self._state["lkgr"]) | 75 lkgr = int(self._state["lkgr"]) |
| 89 if latest == lkgr: | 76 if latest == lkgr: |
| 90 print "ToT (r%d) is clean. Pushing to trunk." % latest | 77 print "ToT (r%d) is clean. Pushing to trunk." % latest |
| 91 # TODO(machenbach): Call push to trunk script. | 78 # TODO(machenbach): Call push to trunk script. |
| 92 else: | 79 else: |
| 93 print("ToT (r%d) is ahead of the LKGR (r%d). Skipping push to trunk." | 80 print("ToT (r%d) is ahead of the LKGR (r%d). Skipping push to trunk." |
| 94 % (latest, lkgr)) | 81 % (latest, lkgr)) |
| 95 | 82 |
| 96 | 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 |
| 97 def BuildOptions(): | 96 def BuildOptions(): |
| 98 result = optparse.OptionParser() | 97 result = optparse.OptionParser() |
| 99 result.add_option("-s", "--step", dest="s", | 98 result.add_option("-s", "--step", dest="s", |
| 100 help="Specify the step where to start work. Default: 0.", | 99 help="Specify the step where to start work. Default: 0.", |
| 101 default=0, type="int") | 100 default=0, type="int") |
| 102 return result | 101 return result |
| 103 | 102 |
| 104 | 103 |
| 105 def Main(): | 104 def Main(): |
| 106 parser = BuildOptions() | 105 parser = BuildOptions() |
| 107 (options, args) = parser.parse_args() | 106 (options, args) = parser.parse_args() |
| 108 | 107 RunAutoRoll(CONFIG, options) |
| 109 step_classes = [ | |
| 110 Preparation, | |
| 111 FetchLatestRevision, | |
| 112 FetchLKGR, | |
| 113 PushToTrunk, | |
| 114 ] | |
| 115 | |
| 116 RunScript(step_classes, CONFIG, options, DEFAULT_SIDE_EFFECT_HANDLER) | |
| 117 | 108 |
| 118 if __name__ == "__main__": | 109 if __name__ == "__main__": |
| 119 sys.exit(Main()) | 110 sys.exit(Main()) |
| OLD | NEW |