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

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

Issue 199733012: Split of rolling Chromium from push-to-trunk. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase. 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/chromium_roll.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 16 matching lines...) Expand all
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 28
29 import argparse 29 import argparse
30 import sys 30 import sys
31 import tempfile 31 import tempfile
32 import urllib2 32 import urllib2
33 33
34 from common_includes import * 34 from common_includes import *
35 35
36 TRUNKBRANCH = "TRUNKBRANCH" 36 TRUNKBRANCH = "TRUNKBRANCH"
37 CHROMIUM = "CHROMIUM"
38 DEPS_FILE = "DEPS_FILE"
39 37
40 CONFIG = { 38 CONFIG = {
41 BRANCHNAME: "prepare-push", 39 BRANCHNAME: "prepare-push",
42 TRUNKBRANCH: "trunk-push", 40 TRUNKBRANCH: "trunk-push",
43 PERSISTFILE_BASENAME: "/tmp/v8-push-to-trunk-tempfile", 41 PERSISTFILE_BASENAME: "/tmp/v8-push-to-trunk-tempfile",
44 TEMP_BRANCH: "prepare-push-temporary-branch-created-by-script", 42 TEMP_BRANCH: "prepare-push-temporary-branch-created-by-script",
45 DOT_GIT_LOCATION: ".git", 43 DOT_GIT_LOCATION: ".git",
46 VERSION_FILE: "src/version.cc", 44 VERSION_FILE: "src/version.cc",
47 CHANGELOG_FILE: "ChangeLog", 45 CHANGELOG_FILE: "ChangeLog",
48 CHANGELOG_ENTRY_FILE: "/tmp/v8-push-to-trunk-tempfile-changelog-entry", 46 CHANGELOG_ENTRY_FILE: "/tmp/v8-push-to-trunk-tempfile-changelog-entry",
49 PATCH_FILE: "/tmp/v8-push-to-trunk-tempfile-patch-file", 47 PATCH_FILE: "/tmp/v8-push-to-trunk-tempfile-patch-file",
50 COMMITMSG_FILE: "/tmp/v8-push-to-trunk-tempfile-commitmsg", 48 COMMITMSG_FILE: "/tmp/v8-push-to-trunk-tempfile-commitmsg",
51 DEPS_FILE: "DEPS",
52 } 49 }
53 50
54 PUSH_MESSAGE_SUFFIX = " (based on bleeding_edge revision r%d)" 51 PUSH_MESSAGE_SUFFIX = " (based on bleeding_edge revision r%d)"
55 PUSH_MESSAGE_RE = re.compile(r".* \(based on bleeding_edge revision r(\d+)\)$") 52 PUSH_MESSAGE_RE = re.compile(r".* \(based on bleeding_edge revision r(\d+)\)$")
56 53
57 54
58 class Preparation(Step): 55 class Preparation(Step):
59 MESSAGE = "Preparation." 56 MESSAGE = "Preparation."
60 57
61 def RunStep(self): 58 def RunStep(self):
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 self["trunk_revision"] = self.ReadLine() 363 self["trunk_revision"] = self.ReadLine()
367 364
368 365
369 class TagRevision(Step): 366 class TagRevision(Step):
370 MESSAGE = "Tag the new revision." 367 MESSAGE = "Tag the new revision."
371 368
372 def RunStep(self): 369 def RunStep(self):
373 self.GitSVNTag(self["version"]) 370 self.GitSVNTag(self["version"])
374 371
375 372
376 class CheckChromium(Step):
377 MESSAGE = "Ask for chromium checkout."
378
379 def Run(self):
380 self["chrome_path"] = self._options.chromium
381 if not self["chrome_path"]:
382 self.DieNoManualMode("Please specify the path to a Chromium checkout in "
383 "forced mode.")
384 print ("Do you have a \"NewGit\" Chromium checkout and want "
385 "this script to automate creation of the roll CL? If yes, enter the "
386 "path to (and including) the \"src\" directory here, otherwise just "
387 "press <Return>: "),
388 self["chrome_path"] = self.ReadLine()
389
390
391 class SwitchChromium(Step):
392 MESSAGE = "Switch to Chromium checkout."
393 REQUIRES = "chrome_path"
394
395 def RunStep(self):
396 self["v8_path"] = os.getcwd()
397 os.chdir(self["chrome_path"])
398 self.InitialEnvironmentChecks()
399 # Check for a clean workdir.
400 if not self.GitIsWorkdirClean(): # pragma: no cover
401 self.Die("Workspace is not clean. Please commit or undo your changes.")
402 # Assert that the DEPS file is there.
403 if not os.path.exists(self.Config(DEPS_FILE)): # pragma: no cover
404 self.Die("DEPS file not present.")
405
406
407 class UpdateChromiumCheckout(Step):
408 MESSAGE = "Update the checkout and create a new branch."
409 REQUIRES = "chrome_path"
410
411 def RunStep(self):
412 os.chdir(self["chrome_path"])
413 self.GitCheckout("master")
414 self.GitPull()
415 self.GitCreateBranch("v8-roll-%s" % self["trunk_revision"])
416
417
418 class UploadCL(Step):
419 MESSAGE = "Create and upload CL."
420 REQUIRES = "chrome_path"
421
422 def RunStep(self):
423 os.chdir(self["chrome_path"])
424
425 # Patch DEPS file.
426 deps = FileToText(self.Config(DEPS_FILE))
427 deps = re.sub("(?<=\"v8_revision\": \")([0-9]+)(?=\")",
428 self["trunk_revision"],
429 deps)
430 TextToFile(deps, self.Config(DEPS_FILE))
431
432 if self._options.reviewer:
433 print "Using account %s for review." % self._options.reviewer
434 rev = self._options.reviewer
435 else:
436 print "Please enter the email address of a reviewer for the roll CL: ",
437 self.DieNoManualMode("A reviewer must be specified in forced mode.")
438 rev = self.ReadLine()
439 suffix = PUSH_MESSAGE_SUFFIX % int(self["svn_revision"])
440 self.GitCommit("Update V8 to version %s%s.\n\nTBR=%s"
441 % (self["version"], suffix, rev))
442 self.GitUpload(author=self._options.author,
443 force=self._options.force_upload)
444 print "CL uploaded."
445
446
447 class SwitchV8(Step):
448 MESSAGE = "Returning to V8 checkout."
449 REQUIRES = "chrome_path"
450
451 def RunStep(self):
452 os.chdir(self["v8_path"])
453
454
455 class CleanUp(Step): 373 class CleanUp(Step):
456 MESSAGE = "Done!" 374 MESSAGE = "Done!"
457 375
458 def RunStep(self): 376 def RunStep(self):
459 if self["chrome_path"]: 377 print("Congratulations, you have successfully created the trunk "
460 print("Congratulations, you have successfully created the trunk " 378 "revision %s. Please don't forget to roll this new version into "
461 "revision %s and rolled it into Chromium. Please don't forget to " 379 "Chromium, and to update the v8rel spreadsheet:"
462 "update the v8rel spreadsheet:" % self["version"]) 380 % self["version"])
463 else: # pragma: no cover 381 print "%s\ttrunk\t%s" % (self["version"], self["trunk_revision"])
464 print("Congratulations, you have successfully created the trunk "
465 "revision %s. Please don't forget to roll this new version into "
466 "Chromium, and to update the v8rel spreadsheet:"
467 % self["version"])
468 print "%s\ttrunk\t%s" % (self["version"],
469 self["trunk_revision"])
470 382
471 self.CommonCleanup() 383 self.CommonCleanup()
472 if self.Config(TRUNKBRANCH) != self["current_branch"]: 384 if self.Config(TRUNKBRANCH) != self["current_branch"]:
473 self.GitDeleteBranch(self.Config(TRUNKBRANCH)) 385 self.GitDeleteBranch(self.Config(TRUNKBRANCH))
474 386
475 387
476 class PushToTrunk(ScriptsBase): 388 class PushToTrunk(ScriptsBase):
477 def _PrepareOptions(self, parser): 389 def _PrepareOptions(self, parser):
478 group = parser.add_mutually_exclusive_group() 390 group = parser.add_mutually_exclusive_group()
479 group.add_argument("-f", "--force", 391 group.add_argument("-f", "--force",
480 help="Don't prompt the user.", 392 help="Don't prompt the user.",
481 default=False, action="store_true") 393 default=False, action="store_true")
482 group.add_argument("-m", "--manual", 394 group.add_argument("-m", "--manual",
483 help="Prompt the user at every important step.", 395 help="Prompt the user at every important step.",
484 default=False, action="store_true") 396 default=False, action="store_true")
485 parser.add_argument("-b", "--last-bleeding-edge", 397 parser.add_argument("-b", "--last-bleeding-edge",
486 help=("The git commit ID of the last bleeding edge " 398 help=("The git commit ID of the last bleeding edge "
487 "revision that was pushed to trunk. This is " 399 "revision that was pushed to trunk. This is "
488 "used for the auto-generated ChangeLog entry.")) 400 "used for the auto-generated ChangeLog entry."))
489 parser.add_argument("-c", "--chromium",
490 help=("The path to your Chromium src/ "
491 "directory to automate the V8 roll."))
492 parser.add_argument("-l", "--last-push", 401 parser.add_argument("-l", "--last-push",
493 help="The git commit ID of the last push to trunk.") 402 help="The git commit ID of the last push to trunk.")
494 parser.add_argument("-R", "--revision", 403 parser.add_argument("-R", "--revision",
495 help="The svn revision to push (defaults to HEAD).") 404 help="The svn revision to push (defaults to HEAD).")
496 405
497 def _ProcessOptions(self, options): # pragma: no cover 406 def _ProcessOptions(self, options): # pragma: no cover
498 if not options.manual and not options.reviewer: 407 if not options.manual and not options.reviewer:
499 print "A reviewer (-r) is required in (semi-)automatic mode." 408 print "A reviewer (-r) is required in (semi-)automatic mode."
500 return False 409 return False
501 if not options.manual and not options.chromium:
502 print "A chromium checkout (-c) is required in (semi-)automatic mode."
503 return False
504 if not options.manual and not options.author: 410 if not options.manual and not options.author:
505 print "Specify your chromium.org email with -a in (semi-)automatic mode." 411 print "Specify your chromium.org email with -a in (semi-)automatic mode."
506 return False 412 return False
507 if options.revision and not int(options.revision) > 0: 413 if options.revision and not int(options.revision) > 0:
508 print("The --revision flag must be a positiv integer pointing to a " 414 print("The --revision flag must be a positiv integer pointing to a "
509 "valid svn revision.") 415 "valid svn revision.")
510 return False 416 return False
511 417
512 options.tbr_commit = not options.manual 418 options.tbr_commit = not options.manual
513 return True 419 return True
(...skipping 10 matching lines...) Expand all
524 StragglerCommits, 430 StragglerCommits,
525 SquashCommits, 431 SquashCommits,
526 NewBranch, 432 NewBranch,
527 ApplyChanges, 433 ApplyChanges,
528 AddChangeLog, 434 AddChangeLog,
529 SetVersion, 435 SetVersion,
530 CommitTrunk, 436 CommitTrunk,
531 SanityCheck, 437 SanityCheck,
532 CommitSVN, 438 CommitSVN,
533 TagRevision, 439 TagRevision,
534 CheckChromium,
535 SwitchChromium,
536 UpdateChromiumCheckout,
537 UploadCL,
538 SwitchV8,
539 CleanUp, 440 CleanUp,
540 ] 441 ]
541 442
542 443
543 if __name__ == "__main__": # pragma: no cover 444 if __name__ == "__main__": # pragma: no cover
544 sys.exit(PushToTrunk(CONFIG).Run()) 445 sys.exit(PushToTrunk(CONFIG).Run())
OLDNEW
« no previous file with comments | « tools/push-to-trunk/chromium_roll.py ('k') | tools/push-to-trunk/test_scripts.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698