OLD | NEW |
1 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import optparse | 5 import optparse |
6 import os | 6 import os |
7 import re | 7 import re |
8 import subprocess | 8 import subprocess |
9 import sys | 9 import sys |
10 import webbrowser | 10 import webbrowser |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 def clobberDir(dir): | 54 def clobberDir(dir): |
55 """Removes a given directory""" | 55 """Removes a given directory""" |
56 | 56 |
57 if (os.path.exists(dir)): | 57 if (os.path.exists(dir)): |
58 print dir + " directory found, deleting" | 58 print dir + " directory found, deleting" |
59 # The following line was removed due to access controls in Windows | 59 # The following line was removed due to access controls in Windows |
60 # which make os.unlink(path) calls impossible. | 60 # which make os.unlink(path) calls impossible. |
61 #TODO(laforge) : Is this correct? | 61 #TODO(laforge) : Is this correct? |
62 deltree(dir) | 62 deltree(dir) |
63 | 63 |
| 64 def rungcl(subcommand): |
| 65 gcl_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "gcl") |
| 66 if not os.path.exists(gcl_path): |
| 67 print "WARNING: gcl not found beside drover.py. Using system gcl instead..." |
| 68 gcl_path = 'gcl' |
| 69 |
| 70 command = "%s %s" % (gcl_path, subcommand) |
| 71 return os.system(command) |
| 72 |
64 def gclUpload(revision, author): | 73 def gclUpload(revision, author): |
65 command = ("gcl upload " + str(revision) + | 74 command = ("upload " + str(revision) + |
66 " --send_mail --no_try --no_presubmit --reviewers=" + author) | 75 " --send_mail --no_try --no_presubmit --reviewers=" + author) |
67 os.system(command) | 76 return rungcl(command) |
68 | 77 |
69 def getSVNInfo(url, revision): | 78 def getSVNInfo(url, revision): |
70 command = 'svn info ' + url + "@"+str(revision) | 79 command = 'svn info ' + url + "@"+str(revision) |
71 svn_info = subprocess.Popen(command, | 80 svn_info = subprocess.Popen(command, |
72 shell=True, | 81 shell=True, |
73 stdout=subprocess.PIPE, | 82 stdout=subprocess.PIPE, |
74 stderr=subprocess.PIPE).stdout.readlines() | 83 stderr=subprocess.PIPE).stdout.readlines() |
75 info = {} | 84 info = {} |
76 for line in svn_info: | 85 for line in svn_info: |
77 match = re.search(r"(.*?):(.*)", line) | 86 match = re.search(r"(.*?):(.*)", line) |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 author = getAuthor(TRUNK_URL, revision) | 421 author = getAuthor(TRUNK_URL, revision) |
413 | 422 |
414 filename = str(revision)+".txt" | 423 filename = str(revision)+".txt" |
415 out = open(filename,"w") | 424 out = open(filename,"w") |
416 out.write(action +" " + str(revision) + " - ") | 425 out.write(action +" " + str(revision) + " - ") |
417 out.write(getRevisionLog(url, revision)) | 426 out.write(getRevisionLog(url, revision)) |
418 if (author): | 427 if (author): |
419 out.write("TBR=" + author) | 428 out.write("TBR=" + author) |
420 out.close() | 429 out.close() |
421 | 430 |
422 change_cmd = 'gcl change ' + str(revision) + " " + filename | 431 change_cmd = 'change ' + str(revision) + " " + filename |
423 if options.revertbot: | 432 if options.revertbot: |
424 change_cmd += ' --silent' | 433 change_cmd += ' --silent' |
425 os.system(change_cmd) | 434 rungcl(change_cmd) |
426 os.unlink(filename) | 435 os.unlink(filename) |
427 print author | 436 print author |
428 print revision | 437 print revision |
429 print ("gcl upload " + str(revision) + | 438 print ("gcl upload " + str(revision) + |
430 " --send_mail --no_try --no_presubmit --reviewers=" + author) | 439 " --send_mail --no_try --no_presubmit --reviewers=" + author) |
431 | 440 |
432 if options.revertbot or prompt("Would you like to upload?"): | 441 if options.revertbot or prompt("Would you like to upload?"): |
433 if PROMPT_FOR_AUTHOR: | 442 if PROMPT_FOR_AUTHOR: |
434 author = text_prompt("Enter new author or press enter to accept default", | 443 author = text_prompt("Enter new author or press enter to accept default", |
435 author) | 444 author) |
436 if options.revertbot and options.revertbot_reviewers: | 445 if options.revertbot and options.revertbot_reviewers: |
437 author += "," | 446 author += "," |
438 author += options.revertbot_reviewers | 447 author += options.revertbot_reviewers |
439 gclUpload(revision, author) | 448 gclUpload(revision, author) |
440 else: | 449 else: |
441 print "Deleting the changelist." | 450 print "Deleting the changelist." |
442 print "gcl delete " + str(revision) | 451 print "gcl delete " + str(revision) |
443 os.system("gcl delete " + str(revision)) | 452 rungcl("delete " + str(revision)) |
444 sys.exit(0) | 453 sys.exit(0) |
445 | 454 |
446 # We commit if the reverbot is set to commit automatically, or if this is | 455 # We commit if the reverbot is set to commit automatically, or if this is |
447 # not the revertbot and the user agrees. | 456 # not the revertbot and the user agrees. |
448 if options.revertbot_commit or (not options.revertbot and | 457 if options.revertbot_commit or (not options.revertbot and |
449 prompt("Would you like to commit?")): | 458 prompt("Would you like to commit?")): |
450 print "gcl commit " + str(revision) + " --no_presubmit --force" | 459 print "gcl commit " + str(revision) + " --no_presubmit --force" |
451 os.system("gcl commit " + str(revision) + " --no_presubmit --force") | 460 rungcl("commit " + str(revision) + " --no_presubmit --force") |
452 else: | 461 else: |
453 sys.exit(0) | 462 sys.exit(0) |
454 | 463 |
455 if __name__ == "__main__": | 464 if __name__ == "__main__": |
456 option_parser = optparse.OptionParser(usage=USAGE % {"app": sys.argv[0]}) | 465 option_parser = optparse.OptionParser(usage=USAGE % {"app": sys.argv[0]}) |
457 option_parser.add_option('-m', '--merge', type="int", | 466 option_parser.add_option('-m', '--merge', type="int", |
458 help='Revision to merge from trunk to branch') | 467 help='Revision to merge from trunk to branch') |
459 option_parser.add_option('-b', '--branch', | 468 option_parser.add_option('-b', '--branch', |
460 help='Branch to revert or merge from') | 469 help='Branch to revert or merge from') |
461 option_parser.add_option('-r', '--revert', type="int", | 470 option_parser.add_option('-r', '--revert', type="int", |
462 help='Revision to revert') | 471 help='Revision to revert') |
463 option_parser.add_option('-w', '--workdir', | 472 option_parser.add_option('-w', '--workdir', |
464 help='subdir to use for the revert') | 473 help='subdir to use for the revert') |
465 option_parser.add_option('', '--revertbot', action='store_true', | 474 option_parser.add_option('', '--revertbot', action='store_true', |
466 default=False) | 475 default=False) |
467 option_parser.add_option('', '--revertbot-commit', action='store_true', | 476 option_parser.add_option('', '--revertbot-commit', action='store_true', |
468 default=False) | 477 default=False) |
469 option_parser.add_option('', '--revertbot-reviewers') | 478 option_parser.add_option('', '--revertbot-reviewers') |
470 options, args = option_parser.parse_args() | 479 options, args = option_parser.parse_args() |
471 | 480 |
472 if not options.merge and not options.revert: | 481 if not options.merge and not options.revert: |
473 option_parser.error("You need at least --merge or --revert") | 482 option_parser.error("You need at least --merge or --revert") |
474 sys.exit(1) | 483 sys.exit(1) |
475 | 484 |
476 if options.merge and not options.branch: | 485 if options.merge and not options.branch: |
477 option_parser.error("--merge requires a --branch") | 486 option_parser.error("--merge requires a --branch") |
478 sys.exit(1) | 487 sys.exit(1) |
479 | 488 |
480 sys.exit(main(options, args)) | 489 sys.exit(main(options, args)) |
OLD | NEW |