| 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 18 matching lines...) Expand all Loading... |
| 29 import argparse | 29 import argparse |
| 30 import json | 30 import json |
| 31 import os | 31 import os |
| 32 import re | 32 import re |
| 33 import sys | 33 import sys |
| 34 import urllib | 34 import urllib |
| 35 | 35 |
| 36 from common_includes import * | 36 from common_includes import * |
| 37 import push_to_trunk | 37 import push_to_trunk |
| 38 | 38 |
| 39 SETTINGS_LOCATION = "SETTINGS_LOCATION" | |
| 40 | |
| 41 CONFIG = { | |
| 42 PERSISTFILE_BASENAME: "/tmp/v8-auto-push-tempfile", | |
| 43 SETTINGS_LOCATION: "~/.auto-roll", | |
| 44 } | |
| 45 | |
| 46 PUSH_MESSAGE_RE = re.compile(r".* \(based on bleeding_edge revision r(\d+)\)$") | 39 PUSH_MESSAGE_RE = re.compile(r".* \(based on bleeding_edge revision r(\d+)\)$") |
| 47 | 40 |
| 48 | |
| 49 class Preparation(Step): | 41 class Preparation(Step): |
| 50 MESSAGE = "Preparation." | 42 MESSAGE = "Preparation." |
| 51 | 43 |
| 52 def RunStep(self): | 44 def RunStep(self): |
| 53 self.InitialEnvironmentChecks(self.default_cwd) | 45 self.InitialEnvironmentChecks(self.default_cwd) |
| 54 self.CommonPrepare() | 46 self.CommonPrepare() |
| 55 | 47 |
| 56 | 48 |
| 57 class CheckAutoPushSettings(Step): | 49 class CheckAutoPushSettings(Step): |
| 58 MESSAGE = "Checking settings file." | 50 MESSAGE = "Checking settings file." |
| 59 | 51 |
| 60 def RunStep(self): | 52 def RunStep(self): |
| 61 settings_file = os.path.realpath(self.Config(SETTINGS_LOCATION)) | 53 settings_file = os.path.realpath(self.Config("SETTINGS_LOCATION")) |
| 62 if os.path.exists(settings_file): | 54 if os.path.exists(settings_file): |
| 63 settings_dict = json.loads(FileToText(settings_file)) | 55 settings_dict = json.loads(FileToText(settings_file)) |
| 64 if settings_dict.get("enable_auto_roll") is False: | 56 if settings_dict.get("enable_auto_roll") is False: |
| 65 self.Die("Push to trunk disabled by auto-roll settings file: %s" | 57 self.Die("Push to trunk disabled by auto-roll settings file: %s" |
| 66 % settings_file) | 58 % settings_file) |
| 67 | 59 |
| 68 | 60 |
| 69 class CheckTreeStatus(Step): | 61 class CheckTreeStatus(Step): |
| 70 MESSAGE = "Checking v8 tree status message." | 62 MESSAGE = "Checking v8 tree status message." |
| 71 | 63 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 103 |
| 112 | 104 |
| 113 class PushToTrunk(Step): | 105 class PushToTrunk(Step): |
| 114 MESSAGE = "Pushing to trunk if specified." | 106 MESSAGE = "Pushing to trunk if specified." |
| 115 | 107 |
| 116 def RunStep(self): | 108 def RunStep(self): |
| 117 print "Pushing lkgr %s to trunk." % self["lkgr"] | 109 print "Pushing lkgr %s to trunk." % self["lkgr"] |
| 118 | 110 |
| 119 # TODO(machenbach): Update the script before calling it. | 111 # TODO(machenbach): Update the script before calling it. |
| 120 if self._options.push: | 112 if self._options.push: |
| 121 P = push_to_trunk.PushToTrunk | |
| 122 self._side_effect_handler.Call( | 113 self._side_effect_handler.Call( |
| 123 P(push_to_trunk.CONFIG, self._side_effect_handler).Run, | 114 push_to_trunk.PushToTrunk().Run, |
| 124 ["--author", self._options.author, | 115 ["--author", self._options.author, |
| 125 "--reviewer", self._options.reviewer, | 116 "--reviewer", self._options.reviewer, |
| 126 "--revision", self["lkgr"], | 117 "--revision", self["lkgr"], |
| 127 "--force"]) | 118 "--force"]) |
| 128 | 119 |
| 129 | 120 |
| 130 class AutoPush(ScriptsBase): | 121 class AutoPush(ScriptsBase): |
| 131 def _PrepareOptions(self, parser): | 122 def _PrepareOptions(self, parser): |
| 132 parser.add_argument("-p", "--push", | 123 parser.add_argument("-p", "--push", |
| 133 help="Push to trunk. Dry run if unspecified.", | 124 help="Push to trunk. Dry run if unspecified.", |
| 134 default=False, action="store_true") | 125 default=False, action="store_true") |
| 135 | 126 |
| 136 def _ProcessOptions(self, options): | 127 def _ProcessOptions(self, options): |
| 137 if not options.author or not options.reviewer: # pragma: no cover | 128 if not options.author or not options.reviewer: # pragma: no cover |
| 138 print "You need to specify author and reviewer." | 129 print "You need to specify author and reviewer." |
| 139 return False | 130 return False |
| 140 options.requires_editor = False | 131 options.requires_editor = False |
| 141 return True | 132 return True |
| 142 | 133 |
| 134 def _Config(self): |
| 135 return { |
| 136 "PERSISTFILE_BASENAME": "/tmp/v8-auto-push-tempfile", |
| 137 "SETTINGS_LOCATION": "~/.auto-roll", |
| 138 } |
| 139 |
| 143 def _Steps(self): | 140 def _Steps(self): |
| 144 return [ | 141 return [ |
| 145 Preparation, | 142 Preparation, |
| 146 CheckAutoPushSettings, | 143 CheckAutoPushSettings, |
| 147 CheckTreeStatus, | 144 CheckTreeStatus, |
| 148 FetchLKGR, | 145 FetchLKGR, |
| 149 CheckLastPush, | 146 CheckLastPush, |
| 150 PushToTrunk, | 147 PushToTrunk, |
| 151 ] | 148 ] |
| 152 | 149 |
| 153 | 150 |
| 154 if __name__ == "__main__": # pragma: no cover | 151 if __name__ == "__main__": # pragma: no cover |
| 155 sys.exit(AutoPush(CONFIG).Run()) | 152 sys.exit(AutoPush().Run()) |
| OLD | NEW |