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 27 matching lines...) Expand all Loading... |
38 PUSH_MSG_GIT_RE = re.compile(r".* \(based on (?P<git_rev>[a-fA-F0-9]+)\)$") | 38 PUSH_MSG_GIT_RE = re.compile(r".* \(based on (?P<git_rev>[a-fA-F0-9]+)\)$") |
39 VERSION_RE = re.compile(r"^\d+\.\d+\.\d+(?:\.\d+)?$") | 39 VERSION_RE = re.compile(r"^\d+\.\d+\.\d+(?:\.\d+)?$") |
40 | 40 |
41 class Preparation(Step): | 41 class Preparation(Step): |
42 MESSAGE = "Preparation." | 42 MESSAGE = "Preparation." |
43 | 43 |
44 def RunStep(self): | 44 def RunStep(self): |
45 self.InitialEnvironmentChecks(self.default_cwd) | 45 self.InitialEnvironmentChecks(self.default_cwd) |
46 self.CommonPrepare() | 46 self.CommonPrepare() |
47 | 47 |
48 # Make sure tags are fetched. | |
49 self.Git("fetch origin +refs/tags/*:refs/tags/*") | |
50 | |
51 if(self["current_branch"] == self.Config("CANDIDATESBRANCH") | 48 if(self["current_branch"] == self.Config("CANDIDATESBRANCH") |
52 or self["current_branch"] == self.Config("BRANCHNAME")): | 49 or self["current_branch"] == self.Config("BRANCHNAME")): |
53 print "Warning: Script started on branch %s" % self["current_branch"] | 50 print "Warning: Script started on branch %s" % self["current_branch"] |
54 | 51 |
55 self.PrepareBranch() | 52 self.PrepareBranch() |
56 self.DeleteBranch(self.Config("CANDIDATESBRANCH")) | 53 self.DeleteBranch(self.Config("CANDIDATESBRANCH")) |
57 | 54 |
58 | 55 |
59 class FreshBranch(Step): | 56 class FreshBranch(Step): |
60 MESSAGE = "Create a fresh branch." | 57 MESSAGE = "Create a fresh branch." |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 # This points to the git hash of the last push on candidates. | 104 # This points to the git hash of the last push on candidates. |
108 self["last_push_candidates"] = last_push | 105 self["last_push_candidates"] = last_push |
109 # This points to the last master revision that went into the last | 106 # This points to the last master revision that went into the last |
110 # push. | 107 # push. |
111 # TODO(machenbach): Do we need a check to make sure we're not pushing a | 108 # TODO(machenbach): Do we need a check to make sure we're not pushing a |
112 # revision older than the last push? If we do this, the output of the | 109 # revision older than the last push? If we do this, the output of the |
113 # current change log preparation won't make much sense. | 110 # current change log preparation won't make much sense. |
114 self["last_push_master"] = last_push_master | 111 self["last_push_master"] = last_push_master |
115 | 112 |
116 | 113 |
117 class GetLatestVersion(Step): | |
118 MESSAGE = "Get latest version from tags." | |
119 | |
120 def RunStep(self): | |
121 versions = sorted(filter(VERSION_RE.match, self.vc.GetTags()), | |
122 key=SortingKey, reverse=True) | |
123 self.StoreVersion(versions[0], "latest_") | |
124 self["latest_version"] = self.ArrayToVersion("latest_") | |
125 | |
126 # The version file on master can be used to bump up major/minor at | |
127 # branch time. | |
128 self.GitCheckoutFile(VERSION_FILE, self.vc.RemoteMasterBranch()) | |
129 self.ReadAndPersistVersion("master_") | |
130 self["master_version"] = self.ArrayToVersion("master_") | |
131 | |
132 if SortingKey(self["master_version"]) > SortingKey(self["latest_version"]): | |
133 self["latest_version"] = self["master_version"] | |
134 self.StoreVersion(self["latest_version"], "latest_") | |
135 | |
136 print "Determined latest version %s" % self["latest_version"] | |
137 | |
138 | |
139 class IncrementVersion(Step): | 114 class IncrementVersion(Step): |
140 MESSAGE = "Increment version number." | 115 MESSAGE = "Increment version number." |
141 | 116 |
142 def RunStep(self): | 117 def RunStep(self): |
| 118 latest_version = self.GetLatestVersion() |
| 119 |
| 120 # The version file on master can be used to bump up major/minor at |
| 121 # branch time. |
| 122 self.GitCheckoutFile(VERSION_FILE, self.vc.RemoteMasterBranch()) |
| 123 self.ReadAndPersistVersion("master_") |
| 124 master_version = self.ArrayToVersion("master_") |
| 125 |
| 126 # Use the highest version from master or from tags to determine the new |
| 127 # version. |
| 128 authoritative_version = sorted( |
| 129 [master_version, latest_version], key=SortingKey)[1] |
| 130 self.StoreVersion(authoritative_version, "authoritative_") |
| 131 |
143 # Variables prefixed with 'new_' contain the new version numbers for the | 132 # Variables prefixed with 'new_' contain the new version numbers for the |
144 # ongoing candidates push. | 133 # ongoing candidates push. |
145 self["new_major"] = self["latest_major"] | 134 self["new_major"] = self["authoritative_major"] |
146 self["new_minor"] = self["latest_minor"] | 135 self["new_minor"] = self["authoritative_minor"] |
147 self["new_build"] = str(int(self["latest_build"]) + 1) | 136 self["new_build"] = str(int(self["authoritative_build"]) + 1) |
148 | 137 |
149 # Make sure patch level is 0 in a new push. | 138 # Make sure patch level is 0 in a new push. |
150 self["new_patch"] = "0" | 139 self["new_patch"] = "0" |
151 | 140 |
152 self["version"] = "%s.%s.%s" % (self["new_major"], | 141 self["version"] = "%s.%s.%s" % (self["new_major"], |
153 self["new_minor"], | 142 self["new_minor"], |
154 self["new_build"]) | 143 self["new_build"]) |
155 | 144 |
| 145 print ("Incremented version to %s" % self["version"]) |
| 146 |
156 | 147 |
157 class PrepareChangeLog(Step): | 148 class PrepareChangeLog(Step): |
158 MESSAGE = "Prepare raw ChangeLog entry." | 149 MESSAGE = "Prepare raw ChangeLog entry." |
159 | 150 |
160 def Reload(self, body): | 151 def Reload(self, body): |
161 """Attempts to reload the commit message from rietveld in order to allow | 152 """Attempts to reload the commit message from rietveld in order to allow |
162 late changes to the LOG flag. Note: This is brittle to future changes of | 153 late changes to the LOG flag. Note: This is brittle to future changes of |
163 the web page name or structure. | 154 the web page name or structure. |
164 """ | 155 """ |
165 match = re.search(r"^Review URL: https://codereview\.chromium\.org/(\d+)$", | 156 match = re.search(r"^Review URL: https://codereview\.chromium\.org/(\d+)$", |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 "PATCH_FILE": "/tmp/v8-push-to-candidates-tempfile-patch-file", | 413 "PATCH_FILE": "/tmp/v8-push-to-candidates-tempfile-patch-file", |
423 "COMMITMSG_FILE": "/tmp/v8-push-to-candidates-tempfile-commitmsg", | 414 "COMMITMSG_FILE": "/tmp/v8-push-to-candidates-tempfile-commitmsg", |
424 } | 415 } |
425 | 416 |
426 def _Steps(self): | 417 def _Steps(self): |
427 return [ | 418 return [ |
428 Preparation, | 419 Preparation, |
429 FreshBranch, | 420 FreshBranch, |
430 PreparePushRevision, | 421 PreparePushRevision, |
431 DetectLastPush, | 422 DetectLastPush, |
432 GetLatestVersion, | |
433 IncrementVersion, | 423 IncrementVersion, |
434 PrepareChangeLog, | 424 PrepareChangeLog, |
435 EditChangeLog, | 425 EditChangeLog, |
436 StragglerCommits, | 426 StragglerCommits, |
437 SquashCommits, | 427 SquashCommits, |
438 NewBranch, | 428 NewBranch, |
439 ApplyChanges, | 429 ApplyChanges, |
440 CommitSquash, | 430 CommitSquash, |
441 SanityCheck, | 431 SanityCheck, |
442 Land, | 432 Land, |
443 PrepareVersionBranch, | 433 PrepareVersionBranch, |
444 AddChangeLog, | 434 AddChangeLog, |
445 SetVersion, | 435 SetVersion, |
446 CommitCandidate, | 436 CommitCandidate, |
447 Land, | 437 Land, |
448 TagRevision, | 438 TagRevision, |
449 CleanUp, | 439 CleanUp, |
450 ] | 440 ] |
451 | 441 |
452 | 442 |
453 if __name__ == "__main__": # pragma: no cover | 443 if __name__ == "__main__": # pragma: no cover |
454 sys.exit(PushToCandidates().Run()) | 444 sys.exit(PushToCandidates().Run()) |
OLD | NEW |