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 sys | 30 import sys |
31 import tempfile | 31 import tempfile |
32 import urllib2 | 32 import urllib2 |
33 | 33 |
34 from common_includes import * | 34 from common_includes import * |
35 | 35 |
36 TRUNKBRANCH = "TRUNKBRANCH" | 36 TRUNKBRANCH = "TRUNKBRANCH" |
37 CHROMIUM = "CHROMIUM" | 37 CHROMIUM = "CHROMIUM" |
38 DEPS_FILE = "DEPS_FILE" | 38 DEPS_FILE = "DEPS_FILE" |
39 NEW_CHANGELOG_FILE = "NEW_CHANGELOG_FILE" | |
40 | 39 |
41 CONFIG = { | 40 CONFIG = { |
42 BRANCHNAME: "prepare-push", | 41 BRANCHNAME: "prepare-push", |
43 TRUNKBRANCH: "trunk-push", | 42 TRUNKBRANCH: "trunk-push", |
44 PERSISTFILE_BASENAME: "/tmp/v8-push-to-trunk-tempfile", | 43 PERSISTFILE_BASENAME: "/tmp/v8-push-to-trunk-tempfile", |
45 TEMP_BRANCH: "prepare-push-temporary-branch-created-by-script", | 44 TEMP_BRANCH: "prepare-push-temporary-branch-created-by-script", |
46 DOT_GIT_LOCATION: ".git", | 45 DOT_GIT_LOCATION: ".git", |
47 VERSION_FILE: "src/version.cc", | 46 VERSION_FILE: "src/version.cc", |
48 CHANGELOG_FILE: "ChangeLog", | 47 CHANGELOG_FILE: "ChangeLog", |
49 NEW_CHANGELOG_FILE: "/tmp/v8-push-to-trunk-tempfile-new-changelog", | |
50 CHANGELOG_ENTRY_FILE: "/tmp/v8-push-to-trunk-tempfile-changelog-entry", | 48 CHANGELOG_ENTRY_FILE: "/tmp/v8-push-to-trunk-tempfile-changelog-entry", |
51 PATCH_FILE: "/tmp/v8-push-to-trunk-tempfile-patch-file", | 49 PATCH_FILE: "/tmp/v8-push-to-trunk-tempfile-patch-file", |
52 COMMITMSG_FILE: "/tmp/v8-push-to-trunk-tempfile-commitmsg", | 50 COMMITMSG_FILE: "/tmp/v8-push-to-trunk-tempfile-commitmsg", |
53 DEPS_FILE: "DEPS", | 51 DEPS_FILE: "DEPS", |
54 } | 52 } |
55 | 53 |
56 PUSH_MESSAGE_SUFFIX = " (based on bleeding_edge revision r%d)" | 54 PUSH_MESSAGE_SUFFIX = " (based on bleeding_edge revision r%d)" |
57 PUSH_MESSAGE_RE = re.compile(r".* \(based on bleeding_edge revision r(\d+)\)$") | 55 PUSH_MESSAGE_RE = re.compile(r".* \(based on bleeding_edge revision r(\d+)\)$") |
58 | 56 |
59 | 57 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 # Strip comments and reformat with correct indentation. | 181 # Strip comments and reformat with correct indentation. |
184 changelog_entry = FileToText(self.Config(CHANGELOG_ENTRY_FILE)).rstrip() | 182 changelog_entry = FileToText(self.Config(CHANGELOG_ENTRY_FILE)).rstrip() |
185 changelog_entry = StripComments(changelog_entry) | 183 changelog_entry = StripComments(changelog_entry) |
186 changelog_entry = "\n".join(map(Fill80, changelog_entry.splitlines())) | 184 changelog_entry = "\n".join(map(Fill80, changelog_entry.splitlines())) |
187 changelog_entry = changelog_entry.lstrip() | 185 changelog_entry = changelog_entry.lstrip() |
188 | 186 |
189 if changelog_entry == "": # pragma: no cover | 187 if changelog_entry == "": # pragma: no cover |
190 self.Die("Empty ChangeLog entry.") | 188 self.Die("Empty ChangeLog entry.") |
191 | 189 |
192 # Safe new change log for adding it later to the trunk patch. | 190 # Safe new change log for adding it later to the trunk patch. |
193 TextToFile(changelog_entry, self.Config(NEW_CHANGELOG_FILE)) | 191 TextToFile(changelog_entry, self.Config(CHANGELOG_ENTRY_FILE)) |
194 | |
195 old_change_log = FileToText(self.Config(CHANGELOG_FILE)) | |
196 new_change_log = "%s\n\n\n%s" % (changelog_entry, old_change_log) | |
197 TextToFile(new_change_log, self.Config(CHANGELOG_FILE)) | |
198 | 192 |
199 | 193 |
200 class IncrementVersion(Step): | 194 class IncrementVersion(Step): |
201 MESSAGE = "Increment version number." | 195 MESSAGE = "Increment version number." |
202 | 196 |
203 def RunStep(self): | 197 def RunStep(self): |
204 new_build = str(int(self["build"]) + 1) | 198 new_build = str(int(self["build"]) + 1) |
205 | 199 |
206 if self.Confirm(("Automatically increment BUILD_NUMBER? (Saying 'n' will " | 200 if self.Confirm(("Automatically increment BUILD_NUMBER? (Saying 'n' will " |
207 "fire up your EDITOR on %s so you can make arbitrary " | 201 "fire up your EDITOR on %s so you can make arbitrary " |
(...skipping 27 matching lines...) Expand all Loading... |
235 else: | 229 else: |
236 message = "%s" % self["prep_commit_msg"] | 230 message = "%s" % self["prep_commit_msg"] |
237 self.GitCommit(message) | 231 self.GitCommit(message) |
238 | 232 |
239 | 233 |
240 class CommitRepository(Step): | 234 class CommitRepository(Step): |
241 MESSAGE = "Commit to the repository." | 235 MESSAGE = "Commit to the repository." |
242 | 236 |
243 def RunStep(self): | 237 def RunStep(self): |
244 self.WaitForLGTM() | 238 self.WaitForLGTM() |
245 # Re-read the ChangeLog entry (to pick up possible changes). | |
246 # FIXME(machenbach): This was hanging once with a broken pipe. | |
247 TextToFile(GetLastChangeLogEntries(self.Config(CHANGELOG_FILE)), | |
248 self.Config(CHANGELOG_ENTRY_FILE)) | |
249 | |
250 self.GitPresubmit() | 239 self.GitPresubmit() |
251 self.GitDCommit() | 240 self.GitDCommit() |
252 | 241 |
253 | 242 |
254 class StragglerCommits(Step): | 243 class StragglerCommits(Step): |
255 MESSAGE = ("Fetch straggler commits that sneaked in since this script was " | 244 MESSAGE = ("Fetch straggler commits that sneaked in since this script was " |
256 "started.") | 245 "started.") |
257 | 246 |
258 def RunStep(self): | 247 def RunStep(self): |
259 self.GitSVNFetch() | 248 self.GitSVNFetch() |
(...skipping 26 matching lines...) Expand all Loading... |
286 # Remove indentation and merge paragraphs into single long lines, keeping | 275 # Remove indentation and merge paragraphs into single long lines, keeping |
287 # empty lines between them. | 276 # empty lines between them. |
288 def SplitMapJoin(split_text, fun, join_text): | 277 def SplitMapJoin(split_text, fun, join_text): |
289 return lambda text: join_text.join(map(fun, text.split(split_text))) | 278 return lambda text: join_text.join(map(fun, text.split(split_text))) |
290 strip = lambda line: line.strip() | 279 strip = lambda line: line.strip() |
291 text = SplitMapJoin("\n\n", SplitMapJoin("\n", strip, " "), "\n\n")(text) | 280 text = SplitMapJoin("\n\n", SplitMapJoin("\n", strip, " "), "\n\n")(text) |
292 | 281 |
293 if not text: # pragma: no cover | 282 if not text: # pragma: no cover |
294 self.Die("Commit message editing failed.") | 283 self.Die("Commit message editing failed.") |
295 TextToFile(text, self.Config(COMMITMSG_FILE)) | 284 TextToFile(text, self.Config(COMMITMSG_FILE)) |
296 os.remove(self.Config(CHANGELOG_ENTRY_FILE)) | |
297 | 285 |
298 | 286 |
299 class NewBranch(Step): | 287 class NewBranch(Step): |
300 MESSAGE = "Create a new branch from trunk." | 288 MESSAGE = "Create a new branch from trunk." |
301 | 289 |
302 def RunStep(self): | 290 def RunStep(self): |
303 self.GitCreateBranch(self.Config(TRUNKBRANCH), "svn/trunk") | 291 self.GitCreateBranch(self.Config(TRUNKBRANCH), "svn/trunk") |
304 | 292 |
305 | 293 |
306 class ApplyChanges(Step): | 294 class ApplyChanges(Step): |
307 MESSAGE = "Apply squashed changes." | 295 MESSAGE = "Apply squashed changes." |
308 | 296 |
309 def RunStep(self): | 297 def RunStep(self): |
310 self.ApplyPatch(self.Config(PATCH_FILE)) | 298 self.ApplyPatch(self.Config(PATCH_FILE)) |
311 Command("rm", "-f %s*" % self.Config(PATCH_FILE)) | 299 Command("rm", "-f %s*" % self.Config(PATCH_FILE)) |
312 | 300 |
313 | 301 |
314 class AddChangeLog(Step): | 302 class AddChangeLog(Step): |
315 MESSAGE = "Add ChangeLog changes to trunk branch." | 303 MESSAGE = "Add ChangeLog changes to trunk branch." |
316 | 304 |
317 def RunStep(self): | 305 def RunStep(self): |
318 # The change log has been modified by the patch. Reset it to the version | 306 # The change log has been modified by the patch. Reset it to the version |
319 # on trunk and apply the exact changes determined by this PrepareChangeLog | 307 # on trunk and apply the exact changes determined by this PrepareChangeLog |
320 # step above. | 308 # step above. |
321 self.GitCheckoutFile(self.Config(CHANGELOG_FILE), "svn/trunk") | 309 self.GitCheckoutFile(self.Config(CHANGELOG_FILE), "svn/trunk") |
322 changelog_entry = FileToText(self.Config(NEW_CHANGELOG_FILE)) | 310 changelog_entry = FileToText(self.Config(CHANGELOG_ENTRY_FILE)) |
323 old_change_log = FileToText(self.Config(CHANGELOG_FILE)) | 311 old_change_log = FileToText(self.Config(CHANGELOG_FILE)) |
324 new_change_log = "%s\n\n\n%s" % (changelog_entry, old_change_log) | 312 new_change_log = "%s\n\n\n%s" % (changelog_entry, old_change_log) |
325 TextToFile(new_change_log, self.Config(CHANGELOG_FILE)) | 313 TextToFile(new_change_log, self.Config(CHANGELOG_FILE)) |
326 os.remove(self.Config(NEW_CHANGELOG_FILE)) | 314 os.remove(self.Config(CHANGELOG_ENTRY_FILE)) |
327 | 315 |
328 | 316 |
329 class SetVersion(Step): | 317 class SetVersion(Step): |
330 MESSAGE = "Set correct version for trunk." | 318 MESSAGE = "Set correct version for trunk." |
331 | 319 |
332 def RunStep(self): | 320 def RunStep(self): |
333 output = "" | 321 output = "" |
334 for line in FileToText(self.Config(VERSION_FILE)).splitlines(): | 322 for line in FileToText(self.Config(VERSION_FILE)).splitlines(): |
335 if line.startswith("#define MAJOR_VERSION"): | 323 if line.startswith("#define MAJOR_VERSION"): |
336 line = re.sub("\d+$", self["major"], line) | 324 line = re.sub("\d+$", self["major"], line) |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 SwitchChromium, | 542 SwitchChromium, |
555 UpdateChromiumCheckout, | 543 UpdateChromiumCheckout, |
556 UploadCL, | 544 UploadCL, |
557 SwitchV8, | 545 SwitchV8, |
558 CleanUp, | 546 CleanUp, |
559 ] | 547 ] |
560 | 548 |
561 | 549 |
562 if __name__ == "__main__": # pragma: no cover | 550 if __name__ == "__main__": # pragma: no cover |
563 sys.exit(PushToTrunk(CONFIG).Run()) | 551 sys.exit(PushToTrunk(CONFIG).Run()) |
OLD | NEW |