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

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

Issue 170583002: Refactor persisting state in push and merge scripts. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 10 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/merge_to_branch.py ('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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 def RunStep(self): 102 def RunStep(self):
103 last_push = (self._options.l or 103 last_push = (self._options.l or
104 self.Git("log -1 --format=%H ChangeLog").strip()) 104 self.Git("log -1 --format=%H ChangeLog").strip())
105 while True: 105 while True:
106 # Print assumed commit, circumventing git's pager. 106 # Print assumed commit, circumventing git's pager.
107 print self.Git("log -1 %s" % last_push) 107 print self.Git("log -1 %s" % last_push)
108 if self.Confirm("Is the commit printed above the last push to trunk?"): 108 if self.Confirm("Is the commit printed above the last push to trunk?"):
109 break 109 break
110 args = "log -1 --format=%H %s^ ChangeLog" % last_push 110 args = "log -1 --format=%H %s^ ChangeLog" % last_push
111 last_push = self.Git(args).strip() 111 last_push = self.Git(args).strip()
112 self.Persist("last_push", last_push) 112 self["last_push"] = last_push
113 self._state["last_push"] = last_push
114 113
115 114
116 class PrepareChangeLog(Step): 115 class PrepareChangeLog(Step):
117 MESSAGE = "Prepare raw ChangeLog entry." 116 MESSAGE = "Prepare raw ChangeLog entry."
118 117
119 def Reload(self, body): 118 def Reload(self, body):
120 """Attempts to reload the commit message from rietveld in order to allow 119 """Attempts to reload the commit message from rietveld in order to allow
121 late changes to the LOG flag. Note: This is brittle to future changes of 120 late changes to the LOG flag. Note: This is brittle to future changes of
122 the web page name or structure. 121 the web page name or structure.
123 """ 122 """
124 match = re.search(r"^Review URL: https://codereview\.chromium\.org/(\d+)$", 123 match = re.search(r"^Review URL: https://codereview\.chromium\.org/(\d+)$",
125 body, flags=re.M) 124 body, flags=re.M)
126 if match: 125 if match:
127 cl_url = "https://codereview.chromium.org/%s/description" % match.group(1) 126 cl_url = ("https://codereview.chromium.org/%s/description"
127 % match.group(1))
128 try: 128 try:
129 # Fetch from Rietveld but only retry once with one second delay since 129 # Fetch from Rietveld but only retry once with one second delay since
130 # there might be many revisions. 130 # there might be many revisions.
131 body = self.ReadURL(cl_url, wait_plan=[1]) 131 body = self.ReadURL(cl_url, wait_plan=[1])
132 except urllib2.URLError: 132 except urllib2.URLError:
133 pass 133 pass
134 return body 134 return body
135 135
136 def RunStep(self): 136 def RunStep(self):
137 self.RestoreIfUnset("last_push")
138
139 # These version numbers are used again later for the trunk commit. 137 # These version numbers are used again later for the trunk commit.
140 self.ReadAndPersistVersion() 138 self.ReadAndPersistVersion()
141 139 self["date"] = self.GetDate()
142 date = self.GetDate() 140 self["version"] = "%s.%s.%s" % (self["major"],
143 self.Persist("date", date) 141 self["minor"],
144 output = "%s: Version %s.%s.%s\n\n" % (date, 142 self["build"])
145 self._state["major"], 143 output = "%s: Version %s\n\n" % (self["date"],
146 self._state["minor"], 144 self["version"])
147 self._state["build"])
148 TextToFile(output, self.Config(CHANGELOG_ENTRY_FILE)) 145 TextToFile(output, self.Config(CHANGELOG_ENTRY_FILE))
149 146
150 args = "log %s..HEAD --format=%%H" % self._state["last_push"] 147 args = "log %s..HEAD --format=%%H" % self["last_push"]
151 commits = self.Git(args).strip() 148 commits = self.Git(args).strip()
152 149
153 # Cache raw commit messages. 150 # Cache raw commit messages.
154 commit_messages = [ 151 commit_messages = [
155 [ 152 [
156 self.Git("log -1 %s --format=\"%%s\"" % commit), 153 self.Git("log -1 %s --format=\"%%s\"" % commit),
157 self.Reload(self.Git("log -1 %s --format=\"%%B\"" % commit)), 154 self.Reload(self.Git("log -1 %s --format=\"%%B\"" % commit)),
158 self.Git("log -1 %s --format=\"%%an\"" % commit), 155 self.Git("log -1 %s --format=\"%%an\"" % commit),
159 ] for commit in commits.splitlines() 156 ] for commit in commits.splitlines()
160 ] 157 ]
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 198
202 AppendToFile(FileToText(self.Config(CHANGELOG_FILE)), new_changelog) 199 AppendToFile(FileToText(self.Config(CHANGELOG_FILE)), new_changelog)
203 TextToFile(FileToText(new_changelog), self.Config(CHANGELOG_FILE)) 200 TextToFile(FileToText(new_changelog), self.Config(CHANGELOG_FILE))
204 os.remove(new_changelog) 201 os.remove(new_changelog)
205 202
206 203
207 class IncrementVersion(Step): 204 class IncrementVersion(Step):
208 MESSAGE = "Increment version number." 205 MESSAGE = "Increment version number."
209 206
210 def RunStep(self): 207 def RunStep(self):
211 self.RestoreIfUnset("build") 208 new_build = str(int(self["build"]) + 1)
212 new_build = str(int(self._state["build"]) + 1)
213 209
214 if self.Confirm(("Automatically increment BUILD_NUMBER? (Saying 'n' will " 210 if self.Confirm(("Automatically increment BUILD_NUMBER? (Saying 'n' will "
215 "fire up your EDITOR on %s so you can make arbitrary " 211 "fire up your EDITOR on %s so you can make arbitrary "
216 "changes. When you're done, save the file and exit your " 212 "changes. When you're done, save the file and exit your "
217 "EDITOR.)" % self.Config(VERSION_FILE))): 213 "EDITOR.)" % self.Config(VERSION_FILE))):
218 text = FileToText(self.Config(VERSION_FILE)) 214 text = FileToText(self.Config(VERSION_FILE))
219 text = MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$", 215 text = MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$",
220 r"\g<space>%s" % new_build, 216 r"\g<space>%s" % new_build,
221 text) 217 text)
222 TextToFile(text, self.Config(VERSION_FILE)) 218 TextToFile(text, self.Config(VERSION_FILE))
223 else: 219 else:
224 self.Editor(self.Config(VERSION_FILE)) 220 self.Editor(self.Config(VERSION_FILE))
225 221
226 self.ReadAndPersistVersion("new_") 222 self.ReadAndPersistVersion("new_")
227 223
228 224
229 class CommitLocal(Step): 225 class CommitLocal(Step):
230 MESSAGE = "Commit to local branch." 226 MESSAGE = "Commit to local branch."
231 227
232 def RunStep(self): 228 def RunStep(self):
233 self.RestoreVersionIfUnset("new_") 229 self["prep_commit_msg"] = ("Prepare push to trunk. "
234 prep_commit_msg = ("Prepare push to trunk. " 230 "Now working on version %s.%s.%s." % (self["new_major"],
235 "Now working on version %s.%s.%s." % (self._state["new_major"], 231 self["new_minor"],
236 self._state["new_minor"], 232 self["new_build"]))
237 self._state["new_build"]))
238 self.Persist("prep_commit_msg", prep_commit_msg)
239 233
240 # Include optional TBR only in the git command. The persisted commit 234 # Include optional TBR only in the git command. The persisted commit
241 # message is used for finding the commit again later. 235 # message is used for finding the commit again later.
242 if self._options.tbr_commit: 236 if self._options.tbr_commit:
243 review = "\n\nTBR=%s" % self._options.reviewer 237 review = "\n\nTBR=%s" % self._options.reviewer
244 else: 238 else:
245 review = "" 239 review = ""
246 if self.Git("commit -a -m \"%s%s\"" % (prep_commit_msg, review)) is None: 240 if self.Git("commit -a -m \"%s%s\""
241 % (self["prep_commit_msg"], review)) is None:
247 self.Die("'git commit -a' failed.") 242 self.Die("'git commit -a' failed.")
248 243
249 244
250 class CommitRepository(Step): 245 class CommitRepository(Step):
251 MESSAGE = "Commit to the repository." 246 MESSAGE = "Commit to the repository."
252 247
253 def RunStep(self): 248 def RunStep(self):
254 self.WaitForLGTM() 249 self.WaitForLGTM()
255 # Re-read the ChangeLog entry (to pick up possible changes). 250 # Re-read the ChangeLog entry (to pick up possible changes).
256 # FIXME(machenbach): This was hanging once with a broken pipe. 251 # FIXME(machenbach): This was hanging once with a broken pipe.
257 TextToFile(GetLastChangeLogEntries(self.Config(CHANGELOG_FILE)), 252 TextToFile(GetLastChangeLogEntries(self.Config(CHANGELOG_FILE)),
258 self.Config(CHANGELOG_ENTRY_FILE)) 253 self.Config(CHANGELOG_ENTRY_FILE))
259 254
260 if self.Git("cl presubmit", "PRESUBMIT_TREE_CHECK=\"skip\"") is None: 255 if self.Git("cl presubmit", "PRESUBMIT_TREE_CHECK=\"skip\"") is None:
261 self.Die("'git cl presubmit' failed, please try again.") 256 self.Die("'git cl presubmit' failed, please try again.")
262 257
263 if self.Git("cl dcommit -f --bypass-hooks", 258 if self.Git("cl dcommit -f --bypass-hooks",
264 retry_on=lambda x: x is None) is None: 259 retry_on=lambda x: x is None) is None:
265 self.Die("'git cl dcommit' failed, please try again.") 260 self.Die("'git cl dcommit' failed, please try again.")
266 261
267 262
268 class StragglerCommits(Step): 263 class StragglerCommits(Step):
269 MESSAGE = ("Fetch straggler commits that sneaked in since this script was " 264 MESSAGE = ("Fetch straggler commits that sneaked in since this script was "
270 "started.") 265 "started.")
271 266
272 def RunStep(self): 267 def RunStep(self):
273 if self.Git("svn fetch") is None: 268 if self.Git("svn fetch") is None:
274 self.Die("'git svn fetch' failed.") 269 self.Die("'git svn fetch' failed.")
275 self.Git("checkout svn/bleeding_edge") 270 self.Git("checkout svn/bleeding_edge")
276 self.RestoreIfUnset("prep_commit_msg") 271 args = "log -1 --format=%%H --grep=\"%s\"" % self["prep_commit_msg"]
277 args = "log -1 --format=%%H --grep=\"%s\"" % self._state["prep_commit_msg"] 272 self["prepare_commit_hash"] = self.Git(args).strip()
278 prepare_commit_hash = self.Git(args).strip()
279 self.Persist("prepare_commit_hash", prepare_commit_hash)
280 273
281 274
282 class SquashCommits(Step): 275 class SquashCommits(Step):
283 MESSAGE = "Squash commits into one." 276 MESSAGE = "Squash commits into one."
284 277
285 def RunStep(self): 278 def RunStep(self):
286 # Instead of relying on "git rebase -i", we'll just create a diff, because 279 # Instead of relying on "git rebase -i", we'll just create a diff, because
287 # that's easier to automate. 280 # that's easier to automate.
288 self.RestoreIfUnset("prepare_commit_hash") 281 args = "diff svn/trunk %s" % self["prepare_commit_hash"]
289 args = "diff svn/trunk %s" % self._state["prepare_commit_hash"]
290 TextToFile(self.Git(args), self.Config(PATCH_FILE)) 282 TextToFile(self.Git(args), self.Config(PATCH_FILE))
291 283
292 # Convert the ChangeLog entry to commit message format. 284 # Convert the ChangeLog entry to commit message format.
293 self.RestoreIfUnset("date")
294 text = FileToText(self.Config(CHANGELOG_ENTRY_FILE)) 285 text = FileToText(self.Config(CHANGELOG_ENTRY_FILE))
295 286
296 # Remove date and trailing white space. 287 # Remove date and trailing white space.
297 text = re.sub(r"^%s: " % self._state["date"], "", text.rstrip()) 288 text = re.sub(r"^%s: " % self["date"], "", text.rstrip())
298 289
299 # Retrieve svn revision for showing the used bleeding edge revision in the 290 # Retrieve svn revision for showing the used bleeding edge revision in the
300 # commit message. 291 # commit message.
301 args = "svn find-rev %s" % self._state["prepare_commit_hash"] 292 args = "svn find-rev %s" % self["prepare_commit_hash"]
302 svn_revision = self.Git(args).strip() 293 self["svn_revision"] = self.Git(args).strip()
303 self.Persist("svn_revision", svn_revision)
304 text = MSub(r"^(Version \d+\.\d+\.\d+)$", 294 text = MSub(r"^(Version \d+\.\d+\.\d+)$",
305 "\\1 (based on bleeding_edge revision r%s)" % svn_revision, 295 ("\\1 (based on bleeding_edge revision r%s)"
296 % self["svn_revision"]),
306 text) 297 text)
307 298
308 # Remove indentation and merge paragraphs into single long lines, keeping 299 # Remove indentation and merge paragraphs into single long lines, keeping
309 # empty lines between them. 300 # empty lines between them.
310 def SplitMapJoin(split_text, fun, join_text): 301 def SplitMapJoin(split_text, fun, join_text):
311 return lambda text: join_text.join(map(fun, text.split(split_text))) 302 return lambda text: join_text.join(map(fun, text.split(split_text)))
312 strip = lambda line: line.strip() 303 strip = lambda line: line.strip()
313 text = SplitMapJoin("\n\n", SplitMapJoin("\n", strip, " "), "\n\n")(text) 304 text = SplitMapJoin("\n\n", SplitMapJoin("\n", strip, " "), "\n\n")(text)
314 305
315 if not text: 306 if not text:
(...skipping 16 matching lines...) Expand all
332 323
333 def RunStep(self): 324 def RunStep(self):
334 self.ApplyPatch(self.Config(PATCH_FILE)) 325 self.ApplyPatch(self.Config(PATCH_FILE))
335 Command("rm", "-f %s*" % self.Config(PATCH_FILE)) 326 Command("rm", "-f %s*" % self.Config(PATCH_FILE))
336 327
337 328
338 class SetVersion(Step): 329 class SetVersion(Step):
339 MESSAGE = "Set correct version for trunk." 330 MESSAGE = "Set correct version for trunk."
340 331
341 def RunStep(self): 332 def RunStep(self):
342 self.RestoreVersionIfUnset()
343 output = "" 333 output = ""
344 for line in FileToText(self.Config(VERSION_FILE)).splitlines(): 334 for line in FileToText(self.Config(VERSION_FILE)).splitlines():
345 if line.startswith("#define MAJOR_VERSION"): 335 if line.startswith("#define MAJOR_VERSION"):
346 line = re.sub("\d+$", self._state["major"], line) 336 line = re.sub("\d+$", self["major"], line)
347 elif line.startswith("#define MINOR_VERSION"): 337 elif line.startswith("#define MINOR_VERSION"):
348 line = re.sub("\d+$", self._state["minor"], line) 338 line = re.sub("\d+$", self["minor"], line)
349 elif line.startswith("#define BUILD_NUMBER"): 339 elif line.startswith("#define BUILD_NUMBER"):
350 line = re.sub("\d+$", self._state["build"], line) 340 line = re.sub("\d+$", self["build"], line)
351 elif line.startswith("#define PATCH_LEVEL"): 341 elif line.startswith("#define PATCH_LEVEL"):
352 line = re.sub("\d+$", "0", line) 342 line = re.sub("\d+$", "0", line)
353 elif line.startswith("#define IS_CANDIDATE_VERSION"): 343 elif line.startswith("#define IS_CANDIDATE_VERSION"):
354 line = re.sub("\d+$", "0", line) 344 line = re.sub("\d+$", "0", line)
355 output += "%s\n" % line 345 output += "%s\n" % line
356 TextToFile(output, self.Config(VERSION_FILE)) 346 TextToFile(output, self.Config(VERSION_FILE))
357 347
358 348
359 class CommitTrunk(Step): 349 class CommitTrunk(Step):
360 MESSAGE = "Commit to local trunk branch." 350 MESSAGE = "Commit to local trunk branch."
(...skipping 18 matching lines...) Expand all
379 class CommitSVN(Step): 369 class CommitSVN(Step):
380 MESSAGE = "Commit to SVN." 370 MESSAGE = "Commit to SVN."
381 371
382 def RunStep(self): 372 def RunStep(self):
383 result = self.Git("svn dcommit 2>&1", retry_on=lambda x: x is None) 373 result = self.Git("svn dcommit 2>&1", retry_on=lambda x: x is None)
384 if not result: 374 if not result:
385 self.Die("'git svn dcommit' failed.") 375 self.Die("'git svn dcommit' failed.")
386 result = filter(lambda x: re.search(r"^Committed r[0-9]+", x), 376 result = filter(lambda x: re.search(r"^Committed r[0-9]+", x),
387 result.splitlines()) 377 result.splitlines())
388 if len(result) > 0: 378 if len(result) > 0:
389 trunk_revision = re.sub(r"^Committed r([0-9]+)", r"\1", result[0]) 379 self["trunk_revision"] = re.sub(r"^Committed r([0-9]+)", r"\1",result[0])
390 380
391 # Sometimes grepping for the revision fails. No idea why. If you figure 381 # Sometimes grepping for the revision fails. No idea why. If you figure
392 # out why it is flaky, please do fix it properly. 382 # out why it is flaky, please do fix it properly.
393 if not trunk_revision: 383 if not self["trunk_revision"]:
394 print("Sorry, grepping for the SVN revision failed. Please look for it " 384 print("Sorry, grepping for the SVN revision failed. Please look for it "
395 "in the last command's output above and provide it manually (just " 385 "in the last command's output above and provide it manually (just "
396 "the number, without the leading \"r\").") 386 "the number, without the leading \"r\").")
397 self.DieNoManualMode("Can't prompt in forced mode.") 387 self.DieNoManualMode("Can't prompt in forced mode.")
398 while not trunk_revision: 388 while not self["trunk_revision"]:
399 print "> ", 389 print "> ",
400 trunk_revision = self.ReadLine() 390 self["trunk_revision"] = self.ReadLine()
401 self.Persist("trunk_revision", trunk_revision)
402 391
403 392
404 class TagRevision(Step): 393 class TagRevision(Step):
405 MESSAGE = "Tag the new revision." 394 MESSAGE = "Tag the new revision."
406 395
407 def RunStep(self): 396 def RunStep(self):
408 self.RestoreVersionIfUnset() 397 if self.Git(("svn tag %s -m \"Tagging version %s\""
409 ver = "%s.%s.%s" % (self._state["major"], 398 % (self["version"], self["version"])),
410 self._state["minor"],
411 self._state["build"])
412 if self.Git("svn tag %s -m \"Tagging version %s\"" % (ver, ver),
413 retry_on=lambda x: x is None) is None: 399 retry_on=lambda x: x is None) is None:
414 self.Die("'git svn tag' failed.") 400 self.Die("'git svn tag' failed.")
415 401
416 402
417 class CheckChromium(Step): 403 class CheckChromium(Step):
418 MESSAGE = "Ask for chromium checkout." 404 MESSAGE = "Ask for chromium checkout."
419 405
420 def Run(self): 406 def Run(self):
421 chrome_path = self._options.c 407 self["chrome_path"] = self._options.c
422 if not chrome_path: 408 if not self["chrome_path"]:
423 self.DieNoManualMode("Please specify the path to a Chromium checkout in " 409 self.DieNoManualMode("Please specify the path to a Chromium checkout in "
424 "forced mode.") 410 "forced mode.")
425 print ("Do you have a \"NewGit\" Chromium checkout and want " 411 print ("Do you have a \"NewGit\" Chromium checkout and want "
426 "this script to automate creation of the roll CL? If yes, enter the " 412 "this script to automate creation of the roll CL? If yes, enter the "
427 "path to (and including) the \"src\" directory here, otherwise just " 413 "path to (and including) the \"src\" directory here, otherwise just "
428 "press <Return>: "), 414 "press <Return>: "),
429 chrome_path = self.ReadLine() 415 self["chrome_path"] = self.ReadLine()
430 self.Persist("chrome_path", chrome_path)
431 416
432 417
433 class SwitchChromium(Step): 418 class SwitchChromium(Step):
434 MESSAGE = "Switch to Chromium checkout." 419 MESSAGE = "Switch to Chromium checkout."
435 REQUIRES = "chrome_path" 420 REQUIRES = "chrome_path"
436 421
437 def RunStep(self): 422 def RunStep(self):
438 v8_path = os.getcwd() 423 self["v8_path"] = os.getcwd()
439 self.Persist("v8_path", v8_path) 424 os.chdir(self["chrome_path"])
440 os.chdir(self._state["chrome_path"])
441 self.InitialEnvironmentChecks() 425 self.InitialEnvironmentChecks()
442 # Check for a clean workdir. 426 # Check for a clean workdir.
443 if self.Git("status -s -uno").strip() != "": 427 if self.Git("status -s -uno").strip() != "":
444 self.Die("Workspace is not clean. Please commit or undo your changes.") 428 self.Die("Workspace is not clean. Please commit or undo your changes.")
445 # Assert that the DEPS file is there. 429 # Assert that the DEPS file is there.
446 if not os.path.exists(self.Config(DEPS_FILE)): 430 if not os.path.exists(self.Config(DEPS_FILE)):
447 self.Die("DEPS file not present.") 431 self.Die("DEPS file not present.")
448 432
449 433
450 class UpdateChromiumCheckout(Step): 434 class UpdateChromiumCheckout(Step):
451 MESSAGE = "Update the checkout and create a new branch." 435 MESSAGE = "Update the checkout and create a new branch."
452 REQUIRES = "chrome_path" 436 REQUIRES = "chrome_path"
453 437
454 def RunStep(self): 438 def RunStep(self):
455 os.chdir(self._state["chrome_path"]) 439 os.chdir(self["chrome_path"])
456 if self.Git("checkout master") is None: 440 if self.Git("checkout master") is None:
457 self.Die("'git checkout master' failed.") 441 self.Die("'git checkout master' failed.")
458 if self.Git("pull") is None: 442 if self.Git("pull") is None:
459 self.Die("'git pull' failed, please try again.") 443 self.Die("'git pull' failed, please try again.")
460 444
461 self.RestoreIfUnset("trunk_revision") 445 args = "checkout -b v8-roll-%s" % self["trunk_revision"]
462 args = "checkout -b v8-roll-%s" % self._state["trunk_revision"]
463 if self.Git(args) is None: 446 if self.Git(args) is None:
464 self.Die("Failed to checkout a new branch.") 447 self.Die("Failed to checkout a new branch.")
465 448
466 449
467 class UploadCL(Step): 450 class UploadCL(Step):
468 MESSAGE = "Create and upload CL." 451 MESSAGE = "Create and upload CL."
469 REQUIRES = "chrome_path" 452 REQUIRES = "chrome_path"
470 453
471 def RunStep(self): 454 def RunStep(self):
472 os.chdir(self._state["chrome_path"]) 455 os.chdir(self["chrome_path"])
473 456
474 # Patch DEPS file. 457 # Patch DEPS file.
475 self.RestoreIfUnset("trunk_revision")
476 deps = FileToText(self.Config(DEPS_FILE)) 458 deps = FileToText(self.Config(DEPS_FILE))
477 deps = re.sub("(?<=\"v8_revision\": \")([0-9]+)(?=\")", 459 deps = re.sub("(?<=\"v8_revision\": \")([0-9]+)(?=\")",
478 self._state["trunk_revision"], 460 self["trunk_revision"],
479 deps) 461 deps)
480 TextToFile(deps, self.Config(DEPS_FILE)) 462 TextToFile(deps, self.Config(DEPS_FILE))
481 463
482 self.RestoreVersionIfUnset()
483 ver = "%s.%s.%s" % (self._state["major"],
484 self._state["minor"],
485 self._state["build"])
486 if self._options.reviewer: 464 if self._options.reviewer:
487 print "Using account %s for review." % self._options.reviewer 465 print "Using account %s for review." % self._options.reviewer
488 rev = self._options.reviewer 466 rev = self._options.reviewer
489 else: 467 else:
490 print "Please enter the email address of a reviewer for the roll CL: ", 468 print "Please enter the email address of a reviewer for the roll CL: ",
491 self.DieNoManualMode("A reviewer must be specified in forced mode.") 469 self.DieNoManualMode("A reviewer must be specified in forced mode.")
492 rev = self.ReadLine() 470 rev = self.ReadLine()
493 self.RestoreIfUnset("svn_revision")
494 args = ("commit -am \"Update V8 to version %s " 471 args = ("commit -am \"Update V8 to version %s "
495 "(based on bleeding_edge revision r%s).\n\nTBR=%s\"" 472 "(based on bleeding_edge revision r%s).\n\nTBR=%s\""
496 % (ver, self._state["svn_revision"], rev)) 473 % (self["version"], self["svn_revision"], rev))
497 if self.Git(args) is None: 474 if self.Git(args) is None:
498 self.Die("'git commit' failed.") 475 self.Die("'git commit' failed.")
499 author_option = self._options.author 476 author_option = self._options.author
500 author = " --email \"%s\"" % author_option if author_option else "" 477 author = " --email \"%s\"" % author_option if author_option else ""
501 force_flag = " -f" if self._options.force_upload else "" 478 force_flag = " -f" if self._options.force_upload else ""
502 if self.Git("cl upload%s --send-mail%s" % (author, force_flag), 479 if self.Git("cl upload%s --send-mail%s" % (author, force_flag),
503 pipe=False) is None: 480 pipe=False) is None:
504 self.Die("'git cl upload' failed, please try again.") 481 self.Die("'git cl upload' failed, please try again.")
505 print "CL uploaded." 482 print "CL uploaded."
506 483
507 484
508 class SwitchV8(Step): 485 class SwitchV8(Step):
509 MESSAGE = "Returning to V8 checkout." 486 MESSAGE = "Returning to V8 checkout."
510 REQUIRES = "chrome_path" 487 REQUIRES = "chrome_path"
511 488
512 def RunStep(self): 489 def RunStep(self):
513 self.RestoreIfUnset("v8_path") 490 os.chdir(self["v8_path"])
514 os.chdir(self._state["v8_path"])
515 491
516 492
517 class CleanUp(Step): 493 class CleanUp(Step):
518 MESSAGE = "Done!" 494 MESSAGE = "Done!"
519 495
520 def RunStep(self): 496 def RunStep(self):
521 self.RestoreVersionIfUnset() 497 if self["chrome_path"]:
522 ver = "%s.%s.%s" % (self._state["major"],
523 self._state["minor"],
524 self._state["build"])
525 self.RestoreIfUnset("trunk_revision")
526 self.RestoreIfUnset("chrome_path")
527
528 if self._state["chrome_path"]:
529 print("Congratulations, you have successfully created the trunk " 498 print("Congratulations, you have successfully created the trunk "
530 "revision %s and rolled it into Chromium. Please don't forget to " 499 "revision %s and rolled it into Chromium. Please don't forget to "
531 "update the v8rel spreadsheet:" % ver) 500 "update the v8rel spreadsheet:" % self["version"])
532 else: 501 else:
533 print("Congratulations, you have successfully created the trunk " 502 print("Congratulations, you have successfully created the trunk "
534 "revision %s. Please don't forget to roll this new version into " 503 "revision %s. Please don't forget to roll this new version into "
535 "Chromium, and to update the v8rel spreadsheet:" % ver) 504 "Chromium, and to update the v8rel spreadsheet:"
536 print "%s\ttrunk\t%s" % (ver, self._state["trunk_revision"]) 505 % self["version"])
506 print "%s\ttrunk\t%s" % (self["version"],
507 self["trunk_revision"])
537 508
538 self.CommonCleanup() 509 self.CommonCleanup()
539 if self.Config(TRUNKBRANCH) != self._state["current_branch"]: 510 if self.Config(TRUNKBRANCH) != self["current_branch"]:
540 self.Git("branch -D %s" % self.Config(TRUNKBRANCH)) 511 self.Git("branch -D %s" % self.Config(TRUNKBRANCH))
541 512
542 513
543 def RunPushToTrunk(config, 514 def RunPushToTrunk(config,
544 options, 515 options,
545 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER): 516 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER):
546 step_classes = [ 517 step_classes = [
547 Preparation, 518 Preparation,
548 FreshBranch, 519 FreshBranch,
549 DetectLastPush, 520 DetectLastPush,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 def Main(): 590 def Main():
620 parser = BuildOptions() 591 parser = BuildOptions()
621 (options, args) = parser.parse_args() 592 (options, args) = parser.parse_args()
622 if not ProcessOptions(options): 593 if not ProcessOptions(options):
623 parser.print_help() 594 parser.print_help()
624 return 1 595 return 1
625 RunPushToTrunk(CONFIG, PushToTrunkOptions(options)) 596 RunPushToTrunk(CONFIG, PushToTrunkOptions(options))
626 597
627 if __name__ == "__main__": 598 if __name__ == "__main__":
628 sys.exit(Main()) 599 sys.exit(Main())
OLDNEW
« no previous file with comments | « tools/push-to-trunk/merge_to_branch.py ('k') | tools/push-to-trunk/test_scripts.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698