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 106 matching lines...) Loading... |
117 # This points to the svn revision of the last push on trunk. | 117 # This points to the svn revision of the last push on trunk. |
118 self["last_push_trunk"] = last_push | 118 self["last_push_trunk"] = last_push |
119 # This points to the last bleeding_edge revision that went into the last | 119 # This points to the last bleeding_edge revision that went into the last |
120 # push. | 120 # push. |
121 # TODO(machenbach): Do we need a check to make sure we're not pushing a | 121 # TODO(machenbach): Do we need a check to make sure we're not pushing a |
122 # revision older than the last push? If we do this, the output of the | 122 # revision older than the last push? If we do this, the output of the |
123 # current change log preparation won't make much sense. | 123 # current change log preparation won't make much sense. |
124 self["last_push_bleeding_edge"] = last_push_bleeding_edge | 124 self["last_push_bleeding_edge"] = last_push_bleeding_edge |
125 | 125 |
126 | 126 |
| 127 # TODO(machenbach): Code similarities with bump_up_version.py. Merge after |
| 128 # turning this script into a pure git script. |
| 129 class GetCurrentBleedingEdgeVersion(Step): |
| 130 MESSAGE = "Get latest bleeding edge version." |
| 131 |
| 132 def RunStep(self): |
| 133 self.GitCheckoutFile(self.Config(VERSION_FILE), "master") |
| 134 |
| 135 # Store latest version. |
| 136 self.ReadAndPersistVersion("latest_") |
| 137 self["latest_version"] = self.ArrayToVersion("latest_") |
| 138 print "Bleeding edge version: %s" % self["latest_version"] |
| 139 |
| 140 |
127 class IncrementVersion(Step): | 141 class IncrementVersion(Step): |
128 MESSAGE = "Increment version number." | 142 MESSAGE = "Increment version number." |
129 | 143 |
130 def RunStep(self): | 144 def RunStep(self): |
131 # Retrieve current version from last trunk push. | 145 # Retrieve current version from last trunk push. |
132 self.GitCheckoutFile(self.Config(VERSION_FILE), self["last_push_trunk"]) | 146 self.GitCheckoutFile(self.Config(VERSION_FILE), self["last_push_trunk"]) |
133 self.ReadAndPersistVersion() | 147 self.ReadAndPersistVersion() |
| 148 self["trunk_version"] = self.ArrayToVersion("") |
| 149 |
| 150 if self["latest_build"] == "9999": # pragma: no cover |
| 151 # If version control on bleeding edge was switched off, just use the last |
| 152 # trunk version. |
| 153 self["latest_version"] = self["trunk_version"] |
| 154 |
| 155 if SortingKey(self["trunk_version"]) < SortingKey(self["latest_version"]): |
| 156 # If the version on bleeding_edge is newer than on trunk, use it. |
| 157 self.GitCheckoutFile(self.Config(VERSION_FILE), "master") |
| 158 self.ReadAndPersistVersion() |
134 | 159 |
135 if self.Confirm(("Automatically increment BUILD_NUMBER? (Saying 'n' will " | 160 if self.Confirm(("Automatically increment BUILD_NUMBER? (Saying 'n' will " |
136 "fire up your EDITOR on %s so you can make arbitrary " | 161 "fire up your EDITOR on %s so you can make arbitrary " |
137 "changes. When you're done, save the file and exit your " | 162 "changes. When you're done, save the file and exit your " |
138 "EDITOR.)" % self.Config(VERSION_FILE))): | 163 "EDITOR.)" % self.Config(VERSION_FILE))): |
| 164 |
139 text = FileToText(self.Config(VERSION_FILE)) | 165 text = FileToText(self.Config(VERSION_FILE)) |
140 text = MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$", | 166 text = MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$", |
141 r"\g<space>%s" % str(int(self["build"]) + 1), | 167 r"\g<space>%s" % str(int(self["build"]) + 1), |
142 text) | 168 text) |
143 TextToFile(text, self.Config(VERSION_FILE)) | 169 TextToFile(text, self.Config(VERSION_FILE)) |
144 else: | 170 else: |
145 self.Editor(self.Config(VERSION_FILE)) | 171 self.Editor(self.Config(VERSION_FILE)) |
146 | 172 |
147 # Variables prefixed with 'new_' contain the new version numbers for the | 173 # Variables prefixed with 'new_' contain the new version numbers for the |
148 # ongoing trunk push. | 174 # ongoing trunk push. |
149 self.ReadAndPersistVersion("new_") | 175 self.ReadAndPersistVersion("new_") |
| 176 |
| 177 # Make sure patch level is 0 in a new push. |
| 178 self["new_patch"] = "0" |
| 179 |
150 self["version"] = "%s.%s.%s" % (self["new_major"], | 180 self["version"] = "%s.%s.%s" % (self["new_major"], |
151 self["new_minor"], | 181 self["new_minor"], |
152 self["new_build"]) | 182 self["new_build"]) |
153 | 183 |
154 | 184 |
155 class PrepareChangeLog(Step): | 185 class PrepareChangeLog(Step): |
156 MESSAGE = "Prepare raw ChangeLog entry." | 186 MESSAGE = "Prepare raw ChangeLog entry." |
157 | 187 |
158 def Reload(self, body): | 188 def Reload(self, body): |
159 """Attempts to reload the commit message from rietveld in order to allow | 189 """Attempts to reload the commit message from rietveld in order to allow |
(...skipping 140 matching lines...) Loading... |
300 os.remove(self.Config(CHANGELOG_ENTRY_FILE)) | 330 os.remove(self.Config(CHANGELOG_ENTRY_FILE)) |
301 | 331 |
302 | 332 |
303 class SetVersion(Step): | 333 class SetVersion(Step): |
304 MESSAGE = "Set correct version for trunk." | 334 MESSAGE = "Set correct version for trunk." |
305 | 335 |
306 def RunStep(self): | 336 def RunStep(self): |
307 # The version file has been modified by the patch. Reset it to the version | 337 # The version file has been modified by the patch. Reset it to the version |
308 # on trunk and apply the correct version. | 338 # on trunk and apply the correct version. |
309 self.GitCheckoutFile(self.Config(VERSION_FILE), "svn/trunk") | 339 self.GitCheckoutFile(self.Config(VERSION_FILE), "svn/trunk") |
310 output = "" | 340 self.SetVersion(self.Config(VERSION_FILE), "new_") |
311 for line in FileToText(self.Config(VERSION_FILE)).splitlines(): | |
312 if line.startswith("#define MAJOR_VERSION"): | |
313 line = re.sub("\d+$", self["new_major"], line) | |
314 elif line.startswith("#define MINOR_VERSION"): | |
315 line = re.sub("\d+$", self["new_minor"], line) | |
316 elif line.startswith("#define BUILD_NUMBER"): | |
317 line = re.sub("\d+$", self["new_build"], line) | |
318 elif line.startswith("#define PATCH_LEVEL"): | |
319 line = re.sub("\d+$", "0", line) | |
320 elif line.startswith("#define IS_CANDIDATE_VERSION"): | |
321 line = re.sub("\d+$", "0", line) | |
322 output += "%s\n" % line | |
323 TextToFile(output, self.Config(VERSION_FILE)) | |
324 | 341 |
325 | 342 |
326 class CommitTrunk(Step): | 343 class CommitTrunk(Step): |
327 MESSAGE = "Commit to local trunk branch." | 344 MESSAGE = "Commit to local trunk branch." |
328 | 345 |
329 def RunStep(self): | 346 def RunStep(self): |
330 self.GitCommit(file_name = self.Config(COMMITMSG_FILE)) | 347 self.GitCommit(file_name = self.Config(COMMITMSG_FILE)) |
331 Command("rm", "-f %s*" % self.Config(COMMITMSG_FILE)) | 348 Command("rm", "-f %s*" % self.Config(COMMITMSG_FILE)) |
332 | 349 |
333 | 350 |
(...skipping 87 matching lines...) Loading... |
421 | 438 |
422 options.tbr_commit = not options.manual | 439 options.tbr_commit = not options.manual |
423 return True | 440 return True |
424 | 441 |
425 def _Steps(self): | 442 def _Steps(self): |
426 return [ | 443 return [ |
427 Preparation, | 444 Preparation, |
428 FreshBranch, | 445 FreshBranch, |
429 PreparePushRevision, | 446 PreparePushRevision, |
430 DetectLastPush, | 447 DetectLastPush, |
| 448 GetCurrentBleedingEdgeVersion, |
431 IncrementVersion, | 449 IncrementVersion, |
432 PrepareChangeLog, | 450 PrepareChangeLog, |
433 EditChangeLog, | 451 EditChangeLog, |
434 StragglerCommits, | 452 StragglerCommits, |
435 SquashCommits, | 453 SquashCommits, |
436 NewBranch, | 454 NewBranch, |
437 ApplyChanges, | 455 ApplyChanges, |
438 AddChangeLog, | 456 AddChangeLog, |
439 SetVersion, | 457 SetVersion, |
440 CommitTrunk, | 458 CommitTrunk, |
441 SanityCheck, | 459 SanityCheck, |
442 CommitSVN, | 460 CommitSVN, |
443 TagRevision, | 461 TagRevision, |
444 CleanUp, | 462 CleanUp, |
445 ] | 463 ] |
446 | 464 |
447 | 465 |
448 if __name__ == "__main__": # pragma: no cover | 466 if __name__ == "__main__": # pragma: no cover |
449 sys.exit(PushToTrunk(CONFIG).Run()) | 467 sys.exit(PushToTrunk(CONFIG).Run()) |
OLD | NEW |