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

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

Issue 701463002: Add workdir feature to release scripts. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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 | « no previous file | 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 30 matching lines...) Expand all
41 import time 41 import time
42 import urllib 42 import urllib
43 import urllib2 43 import urllib2
44 44
45 from git_recipes import GitRecipesMixin 45 from git_recipes import GitRecipesMixin
46 from git_recipes import GitFailedException 46 from git_recipes import GitFailedException
47 47
48 VERSION_FILE = os.path.join("src", "version.cc") 48 VERSION_FILE = os.path.join("src", "version.cc")
49 49
50 # V8 base directory. 50 # V8 base directory.
51 DEFAULT_CWD = os.path.dirname( 51 V8_BASE = os.path.dirname(
52 os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) 52 os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
53 53
54 54
55 def TextToFile(text, file_name): 55 def TextToFile(text, file_name):
56 with open(file_name, "w") as f: 56 with open(file_name, "w") as f:
57 f.write(text) 57 f.write(text)
58 58
59 59
60 def AppendToFile(text, file_name): 60 def AppendToFile(text, file_name):
61 with open(file_name, "a") as f: 61 with open(file_name, "a") as f:
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 self._text = text 463 self._text = text
464 self._number = number 464 self._number = number
465 self._config = config 465 self._config = config
466 self._state = state 466 self._state = state
467 self._options = options 467 self._options = options
468 self._side_effect_handler = handler 468 self._side_effect_handler = handler
469 self.vc = VC_INTERFACES[options.vc_interface]() 469 self.vc = VC_INTERFACES[options.vc_interface]()
470 self.vc.InjectStep(self) 470 self.vc.InjectStep(self)
471 471
472 # The testing configuration might set a different default cwd. 472 # The testing configuration might set a different default cwd.
473 self.default_cwd = self._config.get("DEFAULT_CWD") or DEFAULT_CWD 473 self.default_cwd = (self._config.get("DEFAULT_CWD") or
474 os.path.join(self._options.work_dir, "v8"))
474 475
475 assert self._number >= 0 476 assert self._number >= 0
476 assert self._config is not None 477 assert self._config is not None
477 assert self._state is not None 478 assert self._state is not None
478 assert self._side_effect_handler is not None 479 assert self._side_effect_handler is not None
479 480
480 def __getitem__(self, key): 481 def __getitem__(self, key):
481 # Convenience method to allow direct [] access on step classes for 482 # Convenience method to allow direct [] access on step classes for
482 # manipulating the backed state dict. 483 # manipulating the backed state dict.
483 return self._state[key] 484 return self._state[key]
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 for line in self.GitBranch().splitlines(): 601 for line in self.GitBranch().splitlines():
601 if re.match(r"\*?\s*%s$" % re.escape(name), line): 602 if re.match(r"\*?\s*%s$" % re.escape(name), line):
602 msg = "Branch %s exists, do you want to delete it?" % name 603 msg = "Branch %s exists, do you want to delete it?" % name
603 if self.Confirm(msg): 604 if self.Confirm(msg):
604 self.GitDeleteBranch(name) 605 self.GitDeleteBranch(name)
605 print "Branch %s deleted." % name 606 print "Branch %s deleted." % name
606 else: 607 else:
607 msg = "Can't continue. Please delete branch %s and try again." % name 608 msg = "Can't continue. Please delete branch %s and try again." % name
608 self.Die(msg) 609 self.Die(msg)
609 610
611 def BootstrapV8Checkout(self):
Michael Achenbach 2014/11/03 08:44:54 Doh - this method isn't even called :/ Repairing i
612 if os.path.realpath(self.default_cwd) == os.path.realpath(V8_BASE):
613 self.Die("Can't use v8 checkout with calling script as work checkout.")
614 # Directory containing the working v8 checkout.
615 work_dir = os.path.dirname(self.default_cwd)
616 assert os.path.join(work_dir, "v8") == self.default_cwd
617
618 if not os.path.exits(work_dir):
Michael Achenbach 2014/11/03 09:02:02 exits??? sleepy...
619 os.makedirs(work_dir)
620 if not os.path.exits(self.default_cwd):
621 self.Command("fetch", "v8")
622
610 def InitialEnvironmentChecks(self, cwd): 623 def InitialEnvironmentChecks(self, cwd):
611 # Cancel if this is not a git checkout. 624 # Cancel if this is not a git checkout.
612 if not os.path.exists(os.path.join(cwd, ".git")): # pragma: no cover 625 if not os.path.exists(os.path.join(cwd, ".git")): # pragma: no cover
613 self.Die("This is not a git checkout, this script won't work for you.") 626 self.Die("This is not a git checkout, this script won't work for you.")
614 627
615 # Cancel if EDITOR is unset or not executable. 628 # Cancel if EDITOR is unset or not executable.
616 if (self._options.requires_editor and (not os.environ.get("EDITOR") or 629 if (self._options.requires_editor and (not os.environ.get("EDITOR") or
617 self.Command( 630 self.Command(
618 "which", os.environ["EDITOR"]) is None)): # pragma: no cover 631 "which", os.environ["EDITOR"]) is None)): # pragma: no cover
619 self.Die("Please set your EDITOR environment variable, you'll need it.") 632 self.Die("Please set your EDITOR environment variable, you'll need it.")
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 help=("Optional full svn checkout for the commit." 865 help=("Optional full svn checkout for the commit."
853 "The folder needs to be the svn root.")) 866 "The folder needs to be the svn root."))
854 parser.add_argument("--svn-config", 867 parser.add_argument("--svn-config",
855 help=("Optional folder used as svn --config-dir.")) 868 help=("Optional folder used as svn --config-dir."))
856 parser.add_argument("-s", "--step", 869 parser.add_argument("-s", "--step",
857 help="Specify the step where to start work. Default: 0.", 870 help="Specify the step where to start work. Default: 0.",
858 default=0, type=int) 871 default=0, type=int)
859 parser.add_argument("--vc-interface", 872 parser.add_argument("--vc-interface",
860 help=("Choose VC interface out of git_svn|" 873 help=("Choose VC interface out of git_svn|"
861 "git_read_svn_write.")) 874 "git_read_svn_write."))
875 parser.add_argument("--work-dir",
876 help=("Location where to bootstrap a working v8 "
877 "checkout."))
862 self._PrepareOptions(parser) 878 self._PrepareOptions(parser)
863 879
864 if args is None: # pragma: no cover 880 if args is None: # pragma: no cover
865 options = parser.parse_args() 881 options = parser.parse_args()
866 else: 882 else:
867 options = parser.parse_args(args) 883 options = parser.parse_args(args)
868 884
869 # Process common options. 885 # Process common options.
870 if options.step < 0: # pragma: no cover 886 if options.step < 0: # pragma: no cover
871 print "Bad step number %d" % options.step 887 print "Bad step number %d" % options.step
(...skipping 19 matching lines...) Expand all
891 options.force_readline_defaults = not options.manual 907 options.force_readline_defaults = not options.manual
892 options.force_upload = not options.manual 908 options.force_upload = not options.manual
893 909
894 # Process script specific options. 910 # Process script specific options.
895 if not self._ProcessOptions(options): 911 if not self._ProcessOptions(options):
896 parser.print_help() 912 parser.print_help()
897 return None 913 return None
898 914
899 if not options.vc_interface: 915 if not options.vc_interface:
900 options.vc_interface = "git_read_svn_write" 916 options.vc_interface = "git_read_svn_write"
917 if not options.work_dir:
918 options.work_dir = "/tmp/v8-release-scripts-work-dir"
901 return options 919 return options
902 920
903 def RunSteps(self, step_classes, args=None): 921 def RunSteps(self, step_classes, args=None):
904 options = self.MakeOptions(args) 922 options = self.MakeOptions(args)
905 if not options: 923 if not options:
906 return 1 924 return 1
907 925
908 state_file = "%s-state.json" % self._config["PERSISTFILE_BASENAME"] 926 state_file = "%s-state.json" % self._config["PERSISTFILE_BASENAME"]
909 if options.step == 0 and os.path.exists(state_file): 927 if options.step == 0 and os.path.exists(state_file):
910 os.remove(state_file) 928 os.remove(state_file)
911 929
912 steps = [] 930 steps = []
913 for (number, step_class) in enumerate(step_classes): 931 for (number, step_class) in enumerate(step_classes):
914 steps.append(MakeStep(step_class, number, self._state, self._config, 932 steps.append(MakeStep(step_class, number, self._state, self._config,
915 options, self._side_effect_handler)) 933 options, self._side_effect_handler))
916 for step in steps[options.step:]: 934 for step in steps[options.step:]:
917 if step.Run(): 935 if step.Run():
918 return 0 936 return 0
919 return 0 937 return 0
920 938
921 def Run(self, args=None): 939 def Run(self, args=None):
922 return self.RunSteps(self._Steps(), args) 940 return self.RunSteps(self._Steps(), args)
OLDNEW
« no previous file with comments | « no previous file | tools/push-to-trunk/test_scripts.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698