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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 self.DeleteBranch(self.Config(TRUNKBRANCH)) | 65 self.DeleteBranch(self.Config(TRUNKBRANCH)) |
66 | 66 |
67 | 67 |
68 class FreshBranch(Step): | 68 class FreshBranch(Step): |
69 MESSAGE = "Create a fresh branch." | 69 MESSAGE = "Create a fresh branch." |
70 | 70 |
71 def RunStep(self): | 71 def RunStep(self): |
72 self.GitCreateBranch(self.Config(BRANCHNAME), "svn/bleeding_edge") | 72 self.GitCreateBranch(self.Config(BRANCHNAME), "svn/bleeding_edge") |
73 | 73 |
74 | 74 |
| 75 class PreparePushRevision(Step): |
| 76 MESSAGE = "Check which revision to push." |
| 77 |
| 78 def RunStep(self): |
| 79 if self._options.revision: |
| 80 self["push_hash"] = self.GitSVNFindGitHash(self._options.revision) |
| 81 else: |
| 82 self["push_hash"] = self.GitLog(n=1, format="%H", git_hash="HEAD") |
| 83 if not self["push_hash"]: # pragma: no cover |
| 84 self.Die("Could not determine the git hash for the push.") |
| 85 |
| 86 |
75 class DetectLastPush(Step): | 87 class DetectLastPush(Step): |
76 MESSAGE = "Detect commit ID of last push to trunk." | 88 MESSAGE = "Detect commit ID of last push to trunk." |
77 | 89 |
78 def RunStep(self): | 90 def RunStep(self): |
79 last_push = self._options.last_push or self.FindLastTrunkPush() | 91 last_push = self._options.last_push or self.FindLastTrunkPush() |
80 while True: | 92 while True: |
81 # Print assumed commit, circumventing git's pager. | 93 # Print assumed commit, circumventing git's pager. |
82 print self.GitLog(n=1, git_hash=last_push) | 94 print self.GitLog(n=1, git_hash=last_push) |
83 if self.Confirm("Is the commit printed above the last push to trunk?"): | 95 if self.Confirm("Is the commit printed above the last push to trunk?"): |
84 break | 96 break |
(...skipping 13 matching lines...) Expand all Loading... |
98 % last_push) | 110 % last_push) |
99 last_push_bleeding_edge = self.GitSVNFindGitHash(last_push_be_svn) | 111 last_push_bleeding_edge = self.GitSVNFindGitHash(last_push_be_svn) |
100 if not last_push_bleeding_edge: # pragma: no cover | 112 if not last_push_bleeding_edge: # pragma: no cover |
101 self.Die("Could not retrieve bleeding edge git hash for trunk push %s" | 113 self.Die("Could not retrieve bleeding edge git hash for trunk push %s" |
102 % last_push) | 114 % last_push) |
103 | 115 |
104 # This points to the svn revision of the last push on trunk. | 116 # This points to the svn revision of the last push on trunk. |
105 self["last_push_trunk"] = last_push | 117 self["last_push_trunk"] = last_push |
106 # This points to the last bleeding_edge revision that went into the last | 118 # This points to the last bleeding_edge revision that went into the last |
107 # push. | 119 # push. |
| 120 # TODO(machenbach): Do we need a check to make sure we're not pushing a |
| 121 # revision older than the last push? If we do this, the output of the |
| 122 # current change log preparation won't make much sense. |
108 self["last_push_bleeding_edge"] = last_push_bleeding_edge | 123 self["last_push_bleeding_edge"] = last_push_bleeding_edge |
109 | 124 |
110 | 125 |
111 class IncrementVersion(Step): | 126 class IncrementVersion(Step): |
112 MESSAGE = "Increment version number." | 127 MESSAGE = "Increment version number." |
113 | 128 |
114 def RunStep(self): | 129 def RunStep(self): |
115 # Retrieve current version from last trunk push. | 130 # Retrieve current version from last trunk push. |
116 self.GitCheckoutFile(self.Config(VERSION_FILE), self["last_push_trunk"]) | 131 self.GitCheckoutFile(self.Config(VERSION_FILE), self["last_push_trunk"]) |
117 self.ReadAndPersistVersion() | 132 self.ReadAndPersistVersion() |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 # there might be many revisions. | 169 # there might be many revisions. |
155 body = self.ReadURL(cl_url, wait_plan=[1]) | 170 body = self.ReadURL(cl_url, wait_plan=[1]) |
156 except urllib2.URLError: # pragma: no cover | 171 except urllib2.URLError: # pragma: no cover |
157 pass | 172 pass |
158 return body | 173 return body |
159 | 174 |
160 def RunStep(self): | 175 def RunStep(self): |
161 self["date"] = self.GetDate() | 176 self["date"] = self.GetDate() |
162 output = "%s: Version %s\n\n" % (self["date"], self["version"]) | 177 output = "%s: Version %s\n\n" % (self["date"], self["version"]) |
163 TextToFile(output, self.Config(CHANGELOG_ENTRY_FILE)) | 178 TextToFile(output, self.Config(CHANGELOG_ENTRY_FILE)) |
164 # TODO(machenbach): Retrieve the push hash also from a command-line option. | |
165 commits = self.GitLog(format="%H", | 179 commits = self.GitLog(format="%H", |
166 git_hash="%s..HEAD" % self["last_push_bleeding_edge"]) | 180 git_hash="%s..%s" % (self["last_push_bleeding_edge"], |
| 181 self["push_hash"])) |
167 | 182 |
168 # Cache raw commit messages. | 183 # Cache raw commit messages. |
169 commit_messages = [ | 184 commit_messages = [ |
170 [ | 185 [ |
171 self.GitLog(n=1, format="%s", git_hash=commit), | 186 self.GitLog(n=1, format="%s", git_hash=commit), |
172 self.Reload(self.GitLog(n=1, format="%B", git_hash=commit)), | 187 self.Reload(self.GitLog(n=1, format="%B", git_hash=commit)), |
173 self.GitLog(n=1, format="%an", git_hash=commit), | 188 self.GitLog(n=1, format="%an", git_hash=commit), |
174 ] for commit in commits.splitlines() | 189 ] for commit in commits.splitlines() |
175 ] | 190 ] |
176 | 191 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 TextToFile(changelog_entry, self.Config(CHANGELOG_ENTRY_FILE)) | 227 TextToFile(changelog_entry, self.Config(CHANGELOG_ENTRY_FILE)) |
213 | 228 |
214 | 229 |
215 class StragglerCommits(Step): | 230 class StragglerCommits(Step): |
216 MESSAGE = ("Fetch straggler commits that sneaked in since this script was " | 231 MESSAGE = ("Fetch straggler commits that sneaked in since this script was " |
217 "started.") | 232 "started.") |
218 | 233 |
219 def RunStep(self): | 234 def RunStep(self): |
220 self.GitSVNFetch() | 235 self.GitSVNFetch() |
221 self.GitCheckout("svn/bleeding_edge") | 236 self.GitCheckout("svn/bleeding_edge") |
222 # TODO(machenbach): Retrieve the push hash also from a command-line option. | |
223 self["push_hash"] = self.GitLog(n=1, format="%H", git_hash="HEAD") | |
224 | 237 |
225 | 238 |
226 class SquashCommits(Step): | 239 class SquashCommits(Step): |
227 MESSAGE = "Squash commits into one." | 240 MESSAGE = "Squash commits into one." |
228 | 241 |
229 def RunStep(self): | 242 def RunStep(self): |
230 # Instead of relying on "git rebase -i", we'll just create a diff, because | 243 # Instead of relying on "git rebase -i", we'll just create a diff, because |
231 # that's easier to automate. | 244 # that's easier to automate. |
232 TextToFile(self.GitDiff("svn/trunk", self["push_hash"]), | 245 TextToFile(self.GitDiff("svn/trunk", self["push_hash"]), |
233 self.Config(PATCH_FILE)) | 246 self.Config(PATCH_FILE)) |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 default=False, action="store_true") | 484 default=False, action="store_true") |
472 parser.add_argument("-b", "--last-bleeding-edge", | 485 parser.add_argument("-b", "--last-bleeding-edge", |
473 help=("The git commit ID of the last bleeding edge " | 486 help=("The git commit ID of the last bleeding edge " |
474 "revision that was pushed to trunk. This is " | 487 "revision that was pushed to trunk. This is " |
475 "used for the auto-generated ChangeLog entry.")) | 488 "used for the auto-generated ChangeLog entry.")) |
476 parser.add_argument("-c", "--chromium", | 489 parser.add_argument("-c", "--chromium", |
477 help=("The path to your Chromium src/ " | 490 help=("The path to your Chromium src/ " |
478 "directory to automate the V8 roll.")) | 491 "directory to automate the V8 roll.")) |
479 parser.add_argument("-l", "--last-push", | 492 parser.add_argument("-l", "--last-push", |
480 help="The git commit ID of the last push to trunk.") | 493 help="The git commit ID of the last push to trunk.") |
| 494 parser.add_argument("-R", "--revision", |
| 495 help="The svn revision to push (defaults to HEAD).") |
481 | 496 |
482 def _ProcessOptions(self, options): # pragma: no cover | 497 def _ProcessOptions(self, options): # pragma: no cover |
483 if not options.manual and not options.reviewer: | 498 if not options.manual and not options.reviewer: |
484 print "A reviewer (-r) is required in (semi-)automatic mode." | 499 print "A reviewer (-r) is required in (semi-)automatic mode." |
485 return False | 500 return False |
486 if not options.manual and not options.chromium: | 501 if not options.manual and not options.chromium: |
487 print "A chromium checkout (-c) is required in (semi-)automatic mode." | 502 print "A chromium checkout (-c) is required in (semi-)automatic mode." |
488 return False | 503 return False |
489 if not options.manual and not options.author: | 504 if not options.manual and not options.author: |
490 print "Specify your chromium.org email with -a in (semi-)automatic mode." | 505 print "Specify your chromium.org email with -a in (semi-)automatic mode." |
491 return False | 506 return False |
| 507 if options.revision and not int(options.revision) > 0: |
| 508 print("The --revision flag must be a positiv integer pointing to a " |
| 509 "valid svn revision.") |
| 510 return False |
492 | 511 |
493 options.tbr_commit = not options.manual | 512 options.tbr_commit = not options.manual |
494 return True | 513 return True |
495 | 514 |
496 def _Steps(self): | 515 def _Steps(self): |
497 return [ | 516 return [ |
498 Preparation, | 517 Preparation, |
499 FreshBranch, | 518 FreshBranch, |
| 519 PreparePushRevision, |
500 DetectLastPush, | 520 DetectLastPush, |
501 IncrementVersion, | 521 IncrementVersion, |
502 PrepareChangeLog, | 522 PrepareChangeLog, |
503 EditChangeLog, | 523 EditChangeLog, |
504 StragglerCommits, | 524 StragglerCommits, |
505 SquashCommits, | 525 SquashCommits, |
506 NewBranch, | 526 NewBranch, |
507 ApplyChanges, | 527 ApplyChanges, |
508 AddChangeLog, | 528 AddChangeLog, |
509 SetVersion, | 529 SetVersion, |
510 CommitTrunk, | 530 CommitTrunk, |
511 SanityCheck, | 531 SanityCheck, |
512 CommitSVN, | 532 CommitSVN, |
513 TagRevision, | 533 TagRevision, |
514 CheckChromium, | 534 CheckChromium, |
515 SwitchChromium, | 535 SwitchChromium, |
516 UpdateChromiumCheckout, | 536 UpdateChromiumCheckout, |
517 UploadCL, | 537 UploadCL, |
518 SwitchV8, | 538 SwitchV8, |
519 CleanUp, | 539 CleanUp, |
520 ] | 540 ] |
521 | 541 |
522 | 542 |
523 if __name__ == "__main__": # pragma: no cover | 543 if __name__ == "__main__": # pragma: no cover |
524 sys.exit(PushToTrunk(CONFIG).Run()) | 544 sys.exit(PushToTrunk(CONFIG).Run()) |
OLD | NEW |