OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 the V8 project authors. All rights reserved. | 2 # Copyright 2014 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 self.revisions = options.revisions | 64 self.revisions = options.revisions |
65 | 65 |
66 | 66 |
67 class Preparation(Step): | 67 class Preparation(Step): |
68 MESSAGE = "Preparation." | 68 MESSAGE = "Preparation." |
69 | 69 |
70 def RunStep(self): | 70 def RunStep(self): |
71 if os.path.exists(self.Config(ALREADY_MERGING_SENTINEL_FILE)): | 71 if os.path.exists(self.Config(ALREADY_MERGING_SENTINEL_FILE)): |
72 if self._options.delete_sentinel: | 72 if self._options.delete_sentinel: |
73 os.remove(self.Config(ALREADY_MERGING_SENTINEL_FILE)) | 73 os.remove(self.Config(ALREADY_MERGING_SENTINEL_FILE)) |
74 elif self._options.s == 0: | 74 elif self._options.step == 0: |
75 self.Die("A merge is already in progress") | 75 self.Die("A merge is already in progress") |
76 open(self.Config(ALREADY_MERGING_SENTINEL_FILE), "a").close() | 76 open(self.Config(ALREADY_MERGING_SENTINEL_FILE), "a").close() |
77 | 77 |
78 self.InitialEnvironmentChecks() | 78 self.InitialEnvironmentChecks() |
79 if self._options.revert_bleeding_edge: | 79 if self._options.revert_bleeding_edge: |
80 self["merge_to_branch"] = "bleeding_edge" | 80 self["merge_to_branch"] = "bleeding_edge" |
81 elif self._options.branch: | 81 elif self._options.branch: |
82 self["merge_to_branch"] = self._options.branch | 82 self["merge_to_branch"] = self._options.branch |
83 else: | 83 else: |
84 self.Die("Please specify a branch to merge to") | 84 self.Die("Please specify a branch to merge to") |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 parser.add_argument("-f", | 326 parser.add_argument("-f", |
327 help="Delete sentinel file.", | 327 help="Delete sentinel file.", |
328 default=False, action="store_true") | 328 default=False, action="store_true") |
329 parser.add_argument("-m", "--message", | 329 parser.add_argument("-m", "--message", |
330 help="A commit message for the patch.") | 330 help="A commit message for the patch.") |
331 parser.add_argument("-r", "--revert", | 331 parser.add_argument("-r", "--revert", |
332 help="Revert specified patches.", | 332 help="Revert specified patches.", |
333 default=False, action="store_true") | 333 default=False, action="store_true") |
334 parser.add_argument("-p", "--patch", dest="p", | 334 parser.add_argument("-p", "--patch", dest="p", |
335 help="A patch file to apply as part of the merge.") | 335 help="A patch file to apply as part of the merge.") |
336 parser.add_argument("-s", "--step", dest="s", | 336 parser.add_argument("-s", "--step", |
337 help="The step where to start work. Default: 0.", | 337 help="The step where to start work. Default: 0.", |
338 default=0, type=int) | 338 default=0, type=int) |
339 return parser | 339 return parser |
340 | 340 |
341 | 341 |
342 def ProcessOptions(options): | 342 def ProcessOptions(options): |
343 # TODO(machenbach): Add a test that covers revert from bleeding_edge | 343 # TODO(machenbach): Add a test that covers revert from bleeding_edge |
344 if len(options.revisions) < 1: | 344 if len(options.revisions) < 1: |
345 if not options.patch: | 345 if not options.patch: |
346 print "Either a patch file or revision numbers must be specified" | 346 print "Either a patch file or revision numbers must be specified" |
347 return False | 347 return False |
348 if not options.message: | 348 if not options.message: |
349 print "You must specify a merge comment if no patches are specified" | 349 print "You must specify a merge comment if no patches are specified" |
350 return False | 350 return False |
351 return True | 351 return True |
352 | 352 |
353 | 353 |
354 def Main(): | 354 def Main(): |
355 parser = BuildOptions() | 355 parser = BuildOptions() |
356 options = parser.parse_args() | 356 options = parser.parse_args() |
357 if not ProcessOptions(options): | 357 if not ProcessOptions(options): |
358 parser.print_help() | 358 parser.print_help() |
359 return 1 | 359 return 1 |
360 RunMergeToBranch(CONFIG, MergeToBranchOptions(options)) | 360 RunMergeToBranch(CONFIG, MergeToBranchOptions(options)) |
361 | 361 |
362 if __name__ == "__main__": | 362 if __name__ == "__main__": |
363 sys.exit(Main()) | 363 sys.exit(Main()) |
OLD | NEW |