Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: tools/push-to-trunk/push_to_trunk.py

Issue 203753010: Deprecate prepare push commit when pushing to trunk. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/push-to-trunk.sh ('k') | tools/push-to-trunk/test_scripts.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 last_push_title = self.GitLog(n=1, format="%s", git_hash=last_push) 94 last_push_title = self.GitLog(n=1, format="%s", git_hash=last_push)
95 last_push_be_svn = PUSH_MESSAGE_RE.match(last_push_title).group(1) 95 last_push_be_svn = PUSH_MESSAGE_RE.match(last_push_title).group(1)
96 if not last_push_be_svn: # pragma: no cover 96 if not last_push_be_svn: # pragma: no cover
97 self.Die("Could not retrieve bleeding edge revision for trunk push %s" 97 self.Die("Could not retrieve bleeding edge revision for trunk push %s"
98 % last_push) 98 % last_push)
99 last_push_bleeding_edge = self.GitSVNFindGitHash(last_push_be_svn) 99 last_push_bleeding_edge = self.GitSVNFindGitHash(last_push_be_svn)
100 if not last_push_bleeding_edge: # pragma: no cover 100 if not last_push_bleeding_edge: # pragma: no cover
101 self.Die("Could not retrieve bleeding edge git hash for trunk push %s" 101 self.Die("Could not retrieve bleeding edge git hash for trunk push %s"
102 % last_push) 102 % last_push)
103 103
104 # TODO(machenbach): last_push_trunk points to the svn revision on trunk. 104 # This points to the svn revision of the last push on trunk.
105 # It is not used yet but we'll need it for retrieving the current version.
106 self["last_push_trunk"] = last_push 105 self["last_push_trunk"] = last_push
107 # TODO(machenbach): This currently points to the prepare push revision that 106 # This points to the last bleeding_edge revision that went into the last
108 # will be deprecated soon. After the deprecation it will point to the last 107 # push.
109 # bleeding_edge revision that went into the last push.
110 self["last_push_bleeding_edge"] = last_push_bleeding_edge 108 self["last_push_bleeding_edge"] = last_push_bleeding_edge
111 109
112 110
113 class IncrementVersion(Step): 111 class IncrementVersion(Step):
114 MESSAGE = "Increment version number." 112 MESSAGE = "Increment version number."
115 113
116 def RunStep(self): 114 def RunStep(self):
117 # Retrieve current version from last trunk push. 115 # Retrieve current version from last trunk push.
118 self.GitCheckoutFile(self.Config(VERSION_FILE), self["last_push_trunk"]) 116 self.GitCheckoutFile(self.Config(VERSION_FILE), self["last_push_trunk"])
119 self.ReadAndPersistVersion() 117 self.ReadAndPersistVersion()
(...skipping 10 matching lines...) Expand all
130 else: 128 else:
131 self.Editor(self.Config(VERSION_FILE)) 129 self.Editor(self.Config(VERSION_FILE))
132 130
133 # Variables prefixed with 'new_' contain the new version numbers for the 131 # Variables prefixed with 'new_' contain the new version numbers for the
134 # ongoing trunk push. 132 # ongoing trunk push.
135 self.ReadAndPersistVersion("new_") 133 self.ReadAndPersistVersion("new_")
136 self["version"] = "%s.%s.%s" % (self["new_major"], 134 self["version"] = "%s.%s.%s" % (self["new_major"],
137 self["new_minor"], 135 self["new_minor"],
138 self["new_build"]) 136 self["new_build"])
139 137
140 # TODO(machenbach): The following will be deprecated. Increment version
141 # numbers for version.cc on bleeding_edge (new build level on trunk + 1).
142 text = FileToText(self.Config(VERSION_FILE))
143 text = MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$",
144 r"\g<space>%s" % str(int(self["new_build"]) + 1),
145 text)
146 TextToFile(text, self.Config(VERSION_FILE))
147 self.ReadAndPersistVersion("new_be_")
148
149 138
150 class PrepareChangeLog(Step): 139 class PrepareChangeLog(Step):
151 MESSAGE = "Prepare raw ChangeLog entry." 140 MESSAGE = "Prepare raw ChangeLog entry."
152 141
153 def Reload(self, body): 142 def Reload(self, body):
154 """Attempts to reload the commit message from rietveld in order to allow 143 """Attempts to reload the commit message from rietveld in order to allow
155 late changes to the LOG flag. Note: This is brittle to future changes of 144 late changes to the LOG flag. Note: This is brittle to future changes of
156 the web page name or structure. 145 the web page name or structure.
157 """ 146 """
158 match = re.search(r"^Review URL: https://codereview\.chromium\.org/(\d+)$", 147 match = re.search(r"^Review URL: https://codereview\.chromium\.org/(\d+)$",
159 body, flags=re.M) 148 body, flags=re.M)
160 if match: 149 if match:
161 cl_url = ("https://codereview.chromium.org/%s/description" 150 cl_url = ("https://codereview.chromium.org/%s/description"
162 % match.group(1)) 151 % match.group(1))
163 try: 152 try:
164 # Fetch from Rietveld but only retry once with one second delay since 153 # Fetch from Rietveld but only retry once with one second delay since
165 # there might be many revisions. 154 # there might be many revisions.
166 body = self.ReadURL(cl_url, wait_plan=[1]) 155 body = self.ReadURL(cl_url, wait_plan=[1])
167 except urllib2.URLError: # pragma: no cover 156 except urllib2.URLError: # pragma: no cover
168 pass 157 pass
169 return body 158 return body
170 159
171 def RunStep(self): 160 def RunStep(self):
172 self["date"] = self.GetDate() 161 self["date"] = self.GetDate()
173 output = "%s: Version %s\n\n" % (self["date"], self["version"]) 162 output = "%s: Version %s\n\n" % (self["date"], self["version"])
174 TextToFile(output, self.Config(CHANGELOG_ENTRY_FILE)) 163 TextToFile(output, self.Config(CHANGELOG_ENTRY_FILE))
164 # TODO(machenbach): Retrieve the push hash also from a command-line option.
175 commits = self.GitLog(format="%H", 165 commits = self.GitLog(format="%H",
176 git_hash="%s..HEAD" % self["last_push_bleeding_edge"]) 166 git_hash="%s..HEAD" % self["last_push_bleeding_edge"])
177 167
178 # Cache raw commit messages. 168 # Cache raw commit messages.
179 commit_messages = [ 169 commit_messages = [
180 [ 170 [
181 self.GitLog(n=1, format="%s", git_hash=commit), 171 self.GitLog(n=1, format="%s", git_hash=commit),
182 self.Reload(self.GitLog(n=1, format="%B", git_hash=commit)), 172 self.Reload(self.GitLog(n=1, format="%B", git_hash=commit)),
183 self.GitLog(n=1, format="%an", git_hash=commit), 173 self.GitLog(n=1, format="%an", git_hash=commit),
184 ] for commit in commits.splitlines() 174 ] for commit in commits.splitlines()
(...skipping 30 matching lines...) Expand all
215 changelog_entry = "\n".join(map(Fill80, changelog_entry.splitlines())) 205 changelog_entry = "\n".join(map(Fill80, changelog_entry.splitlines()))
216 changelog_entry = changelog_entry.lstrip() 206 changelog_entry = changelog_entry.lstrip()
217 207
218 if changelog_entry == "": # pragma: no cover 208 if changelog_entry == "": # pragma: no cover
219 self.Die("Empty ChangeLog entry.") 209 self.Die("Empty ChangeLog entry.")
220 210
221 # Safe new change log for adding it later to the trunk patch. 211 # Safe new change log for adding it later to the trunk patch.
222 TextToFile(changelog_entry, self.Config(CHANGELOG_ENTRY_FILE)) 212 TextToFile(changelog_entry, self.Config(CHANGELOG_ENTRY_FILE))
223 213
224 214
225 class CommitLocal(Step):
226 MESSAGE = "Commit to local branch."
227
228 def RunStep(self):
229 self["prep_commit_msg"] = ("Prepare push to trunk. "
230 "Now working on version %s.%s.%s." % (self["new_be_major"],
231 self["new_be_minor"],
232 self["new_be_build"]))
233
234 # Include optional TBR only in the git command. The persisted commit
235 # message is used for finding the commit again later.
236 if self._options.tbr_commit:
237 message = "%s\n\nTBR=%s" % (self["prep_commit_msg"],
238 self._options.reviewer)
239 else:
240 message = "%s" % self["prep_commit_msg"]
241 self.GitCommit(message)
242
243
244 class CommitRepository(Step):
245 MESSAGE = "Commit to the repository."
246
247 def RunStep(self):
248 self.WaitForLGTM()
249 self.GitPresubmit()
250 self.GitDCommit()
251
252
253 class StragglerCommits(Step): 215 class StragglerCommits(Step):
254 MESSAGE = ("Fetch straggler commits that sneaked in since this script was " 216 MESSAGE = ("Fetch straggler commits that sneaked in since this script was "
255 "started.") 217 "started.")
256 218
257 def RunStep(self): 219 def RunStep(self):
258 self.GitSVNFetch() 220 self.GitSVNFetch()
259 self.GitCheckout("svn/bleeding_edge") 221 self.GitCheckout("svn/bleeding_edge")
260 self["prepare_commit_hash"] = self.GitLog(n=1, format="%H", 222 # TODO(machenbach): Retrieve the push hash also from a command-line option.
261 grep=self["prep_commit_msg"]) 223 self["push_hash"] = self.GitLog(n=1, format="%H", git_hash="HEAD")
262 # TODO(machenbach): Retrieve the push hash from a command-line option or
263 # use ToT. The "prepare_commit_hash" will be deprecated along with the
264 # prepare push commit.
265 self["push_hash"] = self.GitLog(n=1, format="%H",
266 parent_hash=self["prepare_commit_hash"])
267 224
268 225
269 class SquashCommits(Step): 226 class SquashCommits(Step):
270 MESSAGE = "Squash commits into one." 227 MESSAGE = "Squash commits into one."
271 228
272 def RunStep(self): 229 def RunStep(self):
273 # Instead of relying on "git rebase -i", we'll just create a diff, because 230 # Instead of relying on "git rebase -i", we'll just create a diff, because
274 # that's easier to automate. 231 # that's easier to automate.
275 TextToFile(self.GitDiff("svn/trunk", self["push_hash"]), 232 TextToFile(self.GitDiff("svn/trunk", self["push_hash"]),
276 self.Config(PATCH_FILE)) 233 self.Config(PATCH_FILE))
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 314
358 def RunStep(self): 315 def RunStep(self):
359 self.GitCommit(file_name = self.Config(COMMITMSG_FILE)) 316 self.GitCommit(file_name = self.Config(COMMITMSG_FILE))
360 Command("rm", "-f %s*" % self.Config(COMMITMSG_FILE)) 317 Command("rm", "-f %s*" % self.Config(COMMITMSG_FILE))
361 318
362 319
363 class SanityCheck(Step): 320 class SanityCheck(Step):
364 MESSAGE = "Sanity check." 321 MESSAGE = "Sanity check."
365 322
366 def RunStep(self): 323 def RunStep(self):
324 # TODO(machenbach): Run presubmit script here as it is now missing in the
325 # prepare push process.
367 if not self.Confirm("Please check if your local checkout is sane: Inspect " 326 if not self.Confirm("Please check if your local checkout is sane: Inspect "
368 "%s, compile, run tests. Do you want to commit this new trunk " 327 "%s, compile, run tests. Do you want to commit this new trunk "
369 "revision to the repository?" % self.Config(VERSION_FILE)): 328 "revision to the repository?" % self.Config(VERSION_FILE)):
370 self.Die("Execution canceled.") # pragma: no cover 329 self.Die("Execution canceled.") # pragma: no cover
371 330
372 331
373 class CommitSVN(Step): 332 class CommitSVN(Step):
374 MESSAGE = "Commit to SVN." 333 MESSAGE = "Commit to SVN."
375 334
376 def RunStep(self): 335 def RunStep(self):
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 return True 494 return True
536 495
537 def _Steps(self): 496 def _Steps(self):
538 return [ 497 return [
539 Preparation, 498 Preparation,
540 FreshBranch, 499 FreshBranch,
541 DetectLastPush, 500 DetectLastPush,
542 IncrementVersion, 501 IncrementVersion,
543 PrepareChangeLog, 502 PrepareChangeLog,
544 EditChangeLog, 503 EditChangeLog,
545 CommitLocal,
546 UploadStep,
547 CommitRepository,
548 StragglerCommits, 504 StragglerCommits,
549 SquashCommits, 505 SquashCommits,
550 NewBranch, 506 NewBranch,
551 ApplyChanges, 507 ApplyChanges,
552 AddChangeLog, 508 AddChangeLog,
553 SetVersion, 509 SetVersion,
554 CommitTrunk, 510 CommitTrunk,
555 SanityCheck, 511 SanityCheck,
556 CommitSVN, 512 CommitSVN,
557 TagRevision, 513 TagRevision,
558 CheckChromium, 514 CheckChromium,
559 SwitchChromium, 515 SwitchChromium,
560 UpdateChromiumCheckout, 516 UpdateChromiumCheckout,
561 UploadCL, 517 UploadCL,
562 SwitchV8, 518 SwitchV8,
563 CleanUp, 519 CleanUp,
564 ] 520 ]
565 521
566 522
567 if __name__ == "__main__": # pragma: no cover 523 if __name__ == "__main__": # pragma: no cover
568 sys.exit(PushToTrunk(CONFIG).Run()) 524 sys.exit(PushToTrunk(CONFIG).Run())
OLDNEW
« no previous file with comments | « tools/push-to-trunk.sh ('k') | tools/push-to-trunk/test_scripts.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698