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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 MESSAGE = "Fetching latest V8 revision." | 50 MESSAGE = "Fetching latest V8 revision." |
51 | 51 |
52 def RunStep(self): | 52 def RunStep(self): |
53 log = self.Git("svn log -1 --oneline").strip() | 53 log = self.Git("svn log -1 --oneline").strip() |
54 match = re.match(r"^r(\d+) ", log) | 54 match = re.match(r"^r(\d+) ", log) |
55 if not match: | 55 if not match: |
56 self.Die("Could not extract current svn revision from log.") | 56 self.Die("Could not extract current svn revision from log.") |
57 self.Persist("latest", match.group(1)) | 57 self.Persist("latest", match.group(1)) |
58 | 58 |
59 | 59 |
| 60 class CheckLastPush(Step): |
| 61 MESSAGE = "Checking last V8 push to trunk." |
| 62 |
| 63 def RunStep(self): |
| 64 self.RestoreIfUnset("latest") |
| 65 log = self.Git("svn log -1 --oneline ChangeLog").strip() |
| 66 match = re.match(r"^r(\d+) \| Prepare push to trunk", log) |
| 67 if match: |
| 68 latest = int(self._state["latest"]) |
| 69 last_push = int(match.group(1)) |
| 70 # TODO(machebach): This metric counts all revisions. It could be |
| 71 # improved by counting only the revisions on bleeding_edge. |
| 72 if latest - last_push < 10: |
| 73 # This makes sure the script doesn't push twice in a row when the cron |
| 74 # job retries several times. |
| 75 self.Die("Last push too recently: %d" % last_push) |
| 76 |
| 77 |
60 class FetchLKGR(Step): | 78 class FetchLKGR(Step): |
61 MESSAGE = "Fetching V8 LKGR." | 79 MESSAGE = "Fetching V8 LKGR." |
62 | 80 |
63 def RunStep(self): | 81 def RunStep(self): |
64 lkgr_url = "https://v8-status.appspot.com/lkgr" | 82 lkgr_url = "https://v8-status.appspot.com/lkgr" |
65 # Retry several times since app engine might have issues. | 83 # Retry several times since app engine might have issues. |
66 self.Persist("lkgr", self.ReadURL(lkgr_url, wait_plan=[5, 20, 300, 300])) | 84 self.Persist("lkgr", self.ReadURL(lkgr_url, wait_plan=[5, 20, 300, 300])) |
67 | 85 |
68 | 86 |
69 class PushToTrunk(Step): | 87 class PushToTrunk(Step): |
70 MESSAGE = "Pushing to trunk if possible." | 88 MESSAGE = "Pushing to trunk if possible." |
71 | 89 |
72 def RunStep(self): | 90 def RunStep(self): |
73 self.RestoreIfUnset("latest") | 91 self.RestoreIfUnset("latest") |
74 self.RestoreIfUnset("lkgr") | 92 self.RestoreIfUnset("lkgr") |
75 latest = int(self._state["latest"]) | 93 latest = int(self._state["latest"]) |
76 lkgr = int(self._state["lkgr"]) | 94 lkgr = int(self._state["lkgr"]) |
77 if latest == lkgr: | 95 if latest == lkgr: |
78 print "ToT (r%d) is clean. Pushing to trunk." % latest | 96 print "ToT (r%d) is clean. Pushing to trunk." % latest |
79 # TODO(machenbach): Call push to trunk script. | 97 # TODO(machenbach): Call push to trunk script. |
| 98 # TODO(machenbach): Update the script before calling it. |
| 99 # self._side_effect_handler.Command( |
| 100 # "tools/push-to-trunk/push-to-trunk.py", |
| 101 # "-f -c %s -r %s" % (self._options.c, self._options.r)) |
80 else: | 102 else: |
81 print("ToT (r%d) is ahead of the LKGR (r%d). Skipping push to trunk." | 103 print("ToT (r%d) is ahead of the LKGR (r%d). Skipping push to trunk." |
82 % (latest, lkgr)) | 104 % (latest, lkgr)) |
83 | 105 |
84 | 106 |
85 def RunAutoRoll(config, | 107 def RunAutoRoll(config, |
86 options, | 108 options, |
87 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER): | 109 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER): |
88 step_classes = [ | 110 step_classes = [ |
89 Preparation, | 111 Preparation, |
90 FetchLatestRevision, | 112 FetchLatestRevision, |
| 113 CheckLastPush, |
91 FetchLKGR, | 114 FetchLKGR, |
92 PushToTrunk, | 115 PushToTrunk, |
93 ] | 116 ] |
94 RunScript(step_classes, config, options, side_effect_handler) | 117 RunScript(step_classes, config, options, side_effect_handler) |
95 | 118 |
96 | 119 |
97 def BuildOptions(): | 120 def BuildOptions(): |
98 result = optparse.OptionParser() | 121 result = optparse.OptionParser() |
99 result.add_option("-f", "--force", dest="f", | 122 result.add_option("-c", "--chromium", dest="c", |
100 help="Don't prompt the user.", | 123 help=("Specify the path to your Chromium src/ " |
101 default=True, action="store_true") | 124 "directory to automate the V8 roll.")) |
| 125 result.add_option("-r", "--reviewer", dest="r", |
| 126 help=("Specify the account name to be used for reviews.")) |
102 result.add_option("-s", "--step", dest="s", | 127 result.add_option("-s", "--step", dest="s", |
103 help="Specify the step where to start work. Default: 0.", | 128 help="Specify the step where to start work. Default: 0.", |
104 default=0, type="int") | 129 default=0, type="int") |
105 return result | 130 return result |
106 | 131 |
107 | 132 |
108 def Main(): | 133 def Main(): |
109 parser = BuildOptions() | 134 parser = BuildOptions() |
110 (options, args) = parser.parse_args() | 135 (options, args) = parser.parse_args() |
| 136 if not options.c or not options.r: |
| 137 print "You need to specify the chromium src location and a reviewer." |
| 138 parser.print_help() |
| 139 return 1 |
111 RunAutoRoll(CONFIG, options) | 140 RunAutoRoll(CONFIG, options) |
112 | 141 |
113 if __name__ == "__main__": | 142 if __name__ == "__main__": |
114 sys.exit(Main()) | 143 sys.exit(Main()) |
OLD | NEW |