OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import datetime | 6 import datetime |
7 import optparse | 7 import optparse |
8 import os | 8 import os |
9 import re | 9 import re |
10 import string | 10 import string |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 if options.branch: | 508 if options.branch: |
509 DEFAULT_WORKING += ("_" + options.branch) | 509 DEFAULT_WORKING += ("_" + options.branch) |
510 | 510 |
511 if not isMinimumSVNVersion(1, 5): | 511 if not isMinimumSVNVersion(1, 5): |
512 print "You need to use at least SVN version 1.5.x" | 512 print "You need to use at least SVN version 1.5.x" |
513 return 1 | 513 return 1 |
514 | 514 |
515 # Override the default properties if there is a drover.properties file. | 515 # Override the default properties if there is a drover.properties file. |
516 global file_pattern_ | 516 global file_pattern_ |
517 if os.path.exists("drover.properties"): | 517 if os.path.exists("drover.properties"): |
| 518 print 'Using options from %s' % os.path.join( |
| 519 os.getcwd(), 'drover.properties') |
518 FILE_PATTERN = file_pattern_ | 520 FILE_PATTERN = file_pattern_ |
519 f = open("drover.properties") | 521 f = open("drover.properties") |
520 exec(f) | 522 exec(f) |
521 f.close() | 523 f.close() |
522 if FILE_PATTERN: | 524 if FILE_PATTERN: |
523 file_pattern_ = FILE_PATTERN | 525 file_pattern_ = FILE_PATTERN |
524 | 526 |
525 if options.revert and options.branch: | 527 if options.revert and options.branch: |
526 print 'Note: --branch is usually not needed for reverts.' | 528 print 'Note: --branch is usually not needed for reverts.' |
527 url = BRANCH_URL.replace("$branch", options.branch) | 529 url = BRANCH_URL.replace("$branch", options.branch) |
528 elif options.merge and options.sbranch: | 530 elif options.merge and options.sbranch: |
529 url = BRANCH_URL.replace("$branch", options.sbranch) | 531 url = BRANCH_URL.replace("$branch", options.sbranch) |
530 elif options.revert: | 532 elif options.revert: |
531 url = options.url or BASE_URL | 533 url = options.url or BASE_URL |
532 file_pattern_ = r"[ ]+([MADUC])[ ]+((/.*)/(.*))" | 534 file_pattern_ = r"[ ]+([MADUC])[ ]+((/.*)/(.*))" |
533 else: | 535 else: |
534 url = TRUNK_URL | 536 url = TRUNK_URL |
535 | 537 |
536 working = options.workdir or DEFAULT_WORKING | 538 working = options.workdir or DEFAULT_WORKING |
537 | 539 |
538 if options.local: | 540 if options.local: |
539 working = os.getcwd() | 541 working = os.getcwd() |
540 if not inCheckoutRoot(working): | 542 if not inCheckoutRoot(working): |
541 print "'%s' appears not to be the root of a working copy" % working | 543 print "'%s' appears not to be the root of a working copy" % working |
542 return 1 | 544 return 1 |
543 if (isSVNDirty() and not | 545 if (isSVNDirty() and not |
544 prompt("Working copy contains uncommitted files. Continue?")): | 546 prompt("Working copy contains uncommitted files. Continue?")): |
545 return 1 | 547 return 1 |
546 | 548 |
547 if options.revert and not options.no_alt_urls: | 549 if options.revert and not options.no_alt_urls and not options.url: |
548 for cur_url in [url] + REVERT_ALT_URLS: | 550 for cur_url in [url] + REVERT_ALT_URLS: |
549 try: | 551 try: |
550 commit_date_str = getSVNInfo( | 552 commit_date_str = getSVNInfo( |
551 cur_url, options.revert).get('Last Changed Date', 'x').split()[0] | 553 cur_url, options.revert).get('Last Changed Date', 'x').split()[0] |
552 commit_date = datetime.datetime.strptime(commit_date_str, '%Y-%m-%d') | 554 commit_date = datetime.datetime.strptime(commit_date_str, '%Y-%m-%d') |
553 if (datetime.datetime.now() - commit_date).days < 120: | 555 if (datetime.datetime.now() - commit_date).days < 180: |
554 if cur_url != url: | 556 if cur_url != url: |
555 print 'Guessing svn repo: %s.' % cur_url, | 557 print 'Guessing svn repo: %s.' % cur_url, |
556 print 'Use --no-alt-urls to disable heuristic.' | 558 print 'Use --no-alt-urls to disable heuristic.' |
557 url = cur_url | 559 url = cur_url |
558 break | 560 break |
559 except ValueError: | 561 except ValueError: |
560 pass | 562 pass |
561 command = 'svn log ' + url + " -r "+str(revision) + " -v" | 563 command = 'svn log ' + url + " -r "+str(revision) + " -v" |
562 os.system(command) | 564 os.system(command) |
563 | 565 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 | 715 |
714 if options.branch and options.milestone: | 716 if options.branch and options.milestone: |
715 option_parser.error("--branch cannot be used with --milestone") | 717 option_parser.error("--branch cannot be used with --milestone") |
716 return 1 | 718 return 1 |
717 | 719 |
718 return drover(options, args) | 720 return drover(options, args) |
719 | 721 |
720 | 722 |
721 if __name__ == "__main__": | 723 if __name__ == "__main__": |
722 sys.exit(main()) | 724 sys.exit(main()) |
OLD | NEW |