| 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): |
| (...skipping 16 matching lines...) Expand all Loading... |
| 59 self.Die("Could not extract current svn revision from log.") | 58 self.Die("Could not extract current svn revision from log.") |
| 60 self.Persist("latest", match.group(1)) | 59 self.Persist("latest", match.group(1)) |
| 61 | 60 |
| 62 | 61 |
| 63 class FetchLKGR(Step): | 62 class FetchLKGR(Step): |
| 64 def __init__(self): | 63 def __init__(self): |
| 65 Step.__init__(self, "Fetching V8 LKGR.") | 64 Step.__init__(self, "Fetching V8 LKGR.") |
| 66 | 65 |
| 67 def RunStep(self): | 66 def RunStep(self): |
| 68 lkgr_url = "https://v8-status.appspot.com/lkgr" | 67 lkgr_url = "https://v8-status.appspot.com/lkgr" |
| 69 try: | 68 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 | 69 |
| 79 | 70 |
| 80 class PushToTrunk(Step): | 71 class PushToTrunk(Step): |
| 81 def __init__(self): | 72 def __init__(self): |
| 82 Step.__init__(self, "Pushing to trunk if possible.") | 73 Step.__init__(self, "Pushing to trunk if possible.") |
| 83 | 74 |
| 84 def RunStep(self): | 75 def RunStep(self): |
| 85 self.RestoreIfUnset("latest") | 76 self.RestoreIfUnset("latest") |
| 86 self.RestoreIfUnset("lkgr") | 77 self.RestoreIfUnset("lkgr") |
| 87 latest = int(self._state["latest"]) | 78 latest = int(self._state["latest"]) |
| 88 lkgr = int(self._state["lkgr"]) | 79 lkgr = int(self._state["lkgr"]) |
| 89 if latest == lkgr: | 80 if latest == lkgr: |
| 90 print "ToT (r%d) is clean. Pushing to trunk." % latest | 81 print "ToT (r%d) is clean. Pushing to trunk." % latest |
| 91 # TODO(machenbach): Call push to trunk script. | 82 # TODO(machenbach): Call push to trunk script. |
| 92 else: | 83 else: |
| 93 print("ToT (r%d) is ahead of the LKGR (r%d). Skipping push to trunk." | 84 print("ToT (r%d) is ahead of the LKGR (r%d). Skipping push to trunk." |
| 94 % (latest, lkgr)) | 85 % (latest, lkgr)) |
| 95 | 86 |
| 96 | 87 |
| 88 def RunAutoRoll(config, |
| 89 options, |
| 90 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER): |
| 91 step_classes = [ |
| 92 Preparation, |
| 93 FetchLatestRevision, |
| 94 FetchLKGR, |
| 95 PushToTrunk, |
| 96 ] |
| 97 RunScript(step_classes, config, options, side_effect_handler) |
| 98 |
| 99 |
| 97 def BuildOptions(): | 100 def BuildOptions(): |
| 98 result = optparse.OptionParser() | 101 result = optparse.OptionParser() |
| 99 result.add_option("-s", "--step", dest="s", | 102 result.add_option("-s", "--step", dest="s", |
| 100 help="Specify the step where to start work. Default: 0.", | 103 help="Specify the step where to start work. Default: 0.", |
| 101 default=0, type="int") | 104 default=0, type="int") |
| 102 return result | 105 return result |
| 103 | 106 |
| 104 | 107 |
| 105 def Main(): | 108 def Main(): |
| 106 parser = BuildOptions() | 109 parser = BuildOptions() |
| 107 (options, args) = parser.parse_args() | 110 (options, args) = parser.parse_args() |
| 108 | 111 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 | 112 |
| 118 if __name__ == "__main__": | 113 if __name__ == "__main__": |
| 119 sys.exit(Main()) | 114 sys.exit(Main()) |
| OLD | NEW |