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 17 matching lines...) Expand all Loading... | |
28 | 28 |
29 import argparse | 29 import argparse |
30 import os | 30 import os |
31 import sys | 31 import sys |
32 import tempfile | 32 import tempfile |
33 import urllib2 | 33 import urllib2 |
34 | 34 |
35 from common_includes import * | 35 from common_includes import * |
36 | 36 |
37 PUSH_MSG_GIT_SUFFIX = " (based on %s)" | 37 PUSH_MSG_GIT_SUFFIX = " (based on %s)" |
38 PUSH_MSG_GIT_RE = re.compile(r".* \(based on (?P<git_rev>[a-fA-F0-9]+)\)$") | 38 |
39 VERSION_RE = re.compile(r"^\d+\.\d+\.\d+(?:\.\d+)?$") | |
40 | 39 |
41 class Preparation(Step): | 40 class Preparation(Step): |
42 MESSAGE = "Preparation." | 41 MESSAGE = "Preparation." |
43 | 42 |
44 def RunStep(self): | 43 def RunStep(self): |
45 self.InitialEnvironmentChecks(self.default_cwd) | 44 self.InitialEnvironmentChecks(self.default_cwd) |
46 self.CommonPrepare() | 45 self.CommonPrepare() |
47 | 46 |
48 if(self["current_branch"] == self.Config("CANDIDATESBRANCH") | 47 if(self["current_branch"] == self.Config("CANDIDATESBRANCH") |
49 or self["current_branch"] == self.Config("BRANCHNAME")): | 48 or self["current_branch"] == self.Config("BRANCHNAME")): |
(...skipping 16 matching lines...) Expand all Loading... | |
66 | 65 |
67 def RunStep(self): | 66 def RunStep(self): |
68 if self._options.revision: | 67 if self._options.revision: |
69 self["push_hash"] = self._options.revision | 68 self["push_hash"] = self._options.revision |
70 else: | 69 else: |
71 self["push_hash"] = self.GitLog(n=1, format="%H", git_hash="HEAD") | 70 self["push_hash"] = self.GitLog(n=1, format="%H", git_hash="HEAD") |
72 if not self["push_hash"]: # pragma: no cover | 71 if not self["push_hash"]: # pragma: no cover |
73 self.Die("Could not determine the git hash for the push.") | 72 self.Die("Could not determine the git hash for the push.") |
74 | 73 |
75 | 74 |
76 class DetectLastPush(Step): | |
77 MESSAGE = "Detect commit ID of last push to CANDIDATES." | |
78 | |
79 def RunStep(self): | |
80 last_push = self._options.last_push or self.FindLastCandidatesPush() | |
81 while True: | |
82 # Print assumed commit, circumventing git's pager. | |
Michael Achenbach
2015/01/27 11:39:04
This interaction was never used -> remove.
| |
83 print self.GitLog(n=1, git_hash=last_push) | |
84 if self.Confirm( | |
85 "Is the commit printed above the last push to candidates?"): | |
86 break | |
87 last_push = self.FindLastCandidatesPush(parent_hash=last_push) | |
88 | |
89 if self._options.last_master: | |
90 # Read the master revision of the last push from a command-line option. | |
91 last_push_master = self._options.last_master | |
92 else: | |
93 # Retrieve the master revision of the last push from the text in | |
94 # the push commit message. | |
95 last_push_title = self.GitLog(n=1, format="%s", git_hash=last_push) | |
96 last_push_master = PUSH_MSG_GIT_RE.match( | |
97 last_push_title).group("git_rev") | |
98 | |
99 if not last_push_master: # pragma: no cover | |
100 self.Die( | |
101 "Could not retrieve master git hash for candidates push %s" | |
102 % last_push) | |
103 | |
104 # This points to the git hash of the last push on candidates. | |
105 self["last_push_candidates"] = last_push | |
106 # This points to the last master revision that went into the last | |
107 # push. | |
108 # TODO(machenbach): Do we need a check to make sure we're not pushing a | |
109 # revision older than the last push? If we do this, the output of the | |
110 # current change log preparation won't make much sense. | |
111 self["last_push_master"] = last_push_master | |
112 | |
113 | |
114 class IncrementVersion(Step): | 75 class IncrementVersion(Step): |
115 MESSAGE = "Increment version number." | 76 MESSAGE = "Increment version number." |
116 | 77 |
117 def RunStep(self): | 78 def RunStep(self): |
118 latest_version = self.GetLatestVersion() | 79 latest_version = self.GetLatestVersion() |
119 | 80 |
120 # The version file on master can be used to bump up major/minor at | 81 # The version file on master can be used to bump up major/minor at |
121 # branch time. | 82 # branch time. |
122 self.GitCheckoutFile(VERSION_FILE, self.vc.RemoteMasterBranch()) | 83 self.GitCheckoutFile(VERSION_FILE, self.vc.RemoteMasterBranch()) |
123 self.ReadAndPersistVersion("master_") | 84 self.ReadAndPersistVersion("master_") |
(...skipping 14 matching lines...) Expand all Loading... | |
138 # Make sure patch level is 0 in a new push. | 99 # Make sure patch level is 0 in a new push. |
139 self["new_patch"] = "0" | 100 self["new_patch"] = "0" |
140 | 101 |
141 self["version"] = "%s.%s.%s" % (self["new_major"], | 102 self["version"] = "%s.%s.%s" % (self["new_major"], |
142 self["new_minor"], | 103 self["new_minor"], |
143 self["new_build"]) | 104 self["new_build"]) |
144 | 105 |
145 print ("Incremented version to %s" % self["version"]) | 106 print ("Incremented version to %s" % self["version"]) |
146 | 107 |
147 | 108 |
109 class DetectLastRelease(Step): | |
110 MESSAGE = "Detect commit ID of last release base." | |
111 | |
112 def RunStep(self): | |
113 if self._options.last_master: | |
114 self["last_push_master"] = self._options.last_master | |
115 else: | |
116 self["last_push_master"] = self.GetLatestReleaseBase() | |
117 | |
118 | |
148 class PrepareChangeLog(Step): | 119 class PrepareChangeLog(Step): |
149 MESSAGE = "Prepare raw ChangeLog entry." | 120 MESSAGE = "Prepare raw ChangeLog entry." |
150 | 121 |
151 def Reload(self, body): | 122 def Reload(self, body): |
152 """Attempts to reload the commit message from rietveld in order to allow | 123 """Attempts to reload the commit message from rietveld in order to allow |
153 late changes to the LOG flag. Note: This is brittle to future changes of | 124 late changes to the LOG flag. Note: This is brittle to future changes of |
154 the web page name or structure. | 125 the web page name or structure. |
155 """ | 126 """ |
156 match = re.search(r"^Review URL: https://codereview\.chromium\.org/(\d+)$", | 127 match = re.search(r"^Review URL: https://codereview\.chromium\.org/(\d+)$", |
157 body, flags=re.M) | 128 body, flags=re.M) |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
412 "/tmp/v8-push-to-candidates-tempfile-changelog-entry", | 383 "/tmp/v8-push-to-candidates-tempfile-changelog-entry", |
413 "PATCH_FILE": "/tmp/v8-push-to-candidates-tempfile-patch-file", | 384 "PATCH_FILE": "/tmp/v8-push-to-candidates-tempfile-patch-file", |
414 "COMMITMSG_FILE": "/tmp/v8-push-to-candidates-tempfile-commitmsg", | 385 "COMMITMSG_FILE": "/tmp/v8-push-to-candidates-tempfile-commitmsg", |
415 } | 386 } |
416 | 387 |
417 def _Steps(self): | 388 def _Steps(self): |
418 return [ | 389 return [ |
419 Preparation, | 390 Preparation, |
420 FreshBranch, | 391 FreshBranch, |
421 PreparePushRevision, | 392 PreparePushRevision, |
422 DetectLastPush, | |
423 IncrementVersion, | 393 IncrementVersion, |
394 DetectLastRelease, | |
424 PrepareChangeLog, | 395 PrepareChangeLog, |
425 EditChangeLog, | 396 EditChangeLog, |
426 StragglerCommits, | 397 StragglerCommits, |
427 SquashCommits, | 398 SquashCommits, |
428 NewBranch, | 399 NewBranch, |
429 ApplyChanges, | 400 ApplyChanges, |
430 CommitSquash, | 401 CommitSquash, |
431 SanityCheck, | 402 SanityCheck, |
432 Land, | 403 Land, |
433 PrepareVersionBranch, | 404 PrepareVersionBranch, |
434 AddChangeLog, | 405 AddChangeLog, |
435 SetVersion, | 406 SetVersion, |
436 CommitCandidate, | 407 CommitCandidate, |
437 Land, | 408 Land, |
438 TagRevision, | 409 TagRevision, |
439 CleanUp, | 410 CleanUp, |
440 ] | 411 ] |
441 | 412 |
442 | 413 |
443 if __name__ == "__main__": # pragma: no cover | 414 if __name__ == "__main__": # pragma: no cover |
444 sys.exit(PushToCandidates().Run()) | 415 sys.exit(PushToCandidates().Run()) |
OLD | NEW |