| 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 optparse | 6 import optparse |
| 7 import os | 7 import os |
| 8 import re | 8 import re |
| 9 import string | 9 import string |
| 10 import sys | 10 import sys |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 if (version['minor'] > minor): | 162 if (version['minor'] > minor): |
| 163 return True | 163 return True |
| 164 elif (version['minor'] < minor): | 164 elif (version['minor'] < minor): |
| 165 return False | 165 return False |
| 166 | 166 |
| 167 if (version['patch'] >= patch): | 167 if (version['patch'] >= patch): |
| 168 return True | 168 return True |
| 169 else: | 169 else: |
| 170 return False | 170 return False |
| 171 | 171 |
| 172 def checkoutRevision(url, revision, branch_url, revert=False): | 172 def checkoutRevision(url, revision, branch_url, revert=False, pop=True): |
| 173 files_info = getFileInfo(url, revision) | 173 files_info = getFileInfo(url, revision) |
| 174 paths = getBestMergePaths2(files_info, revision) | 174 paths = getBestMergePaths2(files_info, revision) |
| 175 export_map = getBestExportPathsMap2(files_info, revision) | 175 export_map = getBestExportPathsMap2(files_info, revision) |
| 176 | 176 |
| 177 command = 'svn checkout -N ' + branch_url | 177 command = 'svn checkout -N ' + branch_url |
| 178 print command | 178 print command |
| 179 os.system(command) | 179 os.system(command) |
| 180 | 180 |
| 181 match = re.search(r"^[a-z]+://.*/(.*)", branch_url) | 181 match = re.search(r"^[a-z]+://.*/(.*)", branch_url) |
| 182 | 182 |
| 183 if match: | 183 if match: |
| 184 os.chdir(match.group(1)) | 184 os.chdir(match.group(1)) |
| 185 | 185 |
| 186 # This line is extremely important due to the way svn behaves in the | 186 # This line is extremely important due to the way svn behaves in the |
| 187 # set-depths action. If parents aren't handled before children, the child | 187 # set-depths action. If parents aren't handled before children, the child |
| 188 # directories get clobbered and the merge step fails. | 188 # directories get clobbered and the merge step fails. |
| 189 paths.sort() | 189 paths.sort() |
| 190 | 190 |
| 191 # Checkout the directories that already exist | 191 # Checkout the directories that already exist |
| 192 for path in paths: | 192 for path in paths: |
| 193 if (export_map.has_key(path) and not revert): | 193 if (export_map.has_key(path) and not revert): |
| 194 print "Exclude new directory " + path | 194 print "Exclude new directory " + path |
| 195 continue | 195 continue |
| 196 subpaths = path.split('/') | 196 subpaths = path.split('/') |
| 197 subpaths.pop(0) | 197 #In the normal case, where no url override is specified and it's just |
| 198 # chromium source, it's necessary to remove the 'trunk' from the filepath, |
| 199 # since in the checkout we include 'trunk' or 'branch/\d+'. |
| 200 # |
| 201 # However, when a url is specified we want to preserve that because it's |
| 202 # a part of the filepath and necessary for path operations on svn (because |
| 203 # frankly, we are checking out the correct top level, and not hacking it). |
| 204 if pop: |
| 205 subpaths.pop(0) |
| 198 base = '' | 206 base = '' |
| 199 for subpath in subpaths: | 207 for subpath in subpaths: |
| 200 base += '/' + subpath | 208 base += '/' + subpath |
| 201 # This logic ensures that you don't empty out any directories | 209 # This logic ensures that you don't empty out any directories |
| 202 if not os.path.exists("." + base): | 210 if not os.path.exists("." + base): |
| 203 command = ('svn update --depth empty ' + "." + base) | 211 command = ('svn update --depth empty ' + "." + base) |
| 204 print command | 212 print command |
| 205 os.system(command) | 213 os.system(command) |
| 206 | 214 |
| 207 if (revert): | 215 if (revert): |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 f = open("drover.properties") | 517 f = open("drover.properties") |
| 510 exec(f) | 518 exec(f) |
| 511 f.close() | 519 f.close() |
| 512 if FILE_PATTERN: | 520 if FILE_PATTERN: |
| 513 file_pattern_ = FILE_PATTERN | 521 file_pattern_ = FILE_PATTERN |
| 514 | 522 |
| 515 if options.revert and options.branch: | 523 if options.revert and options.branch: |
| 516 url = BRANCH_URL.replace("$branch", options.branch) | 524 url = BRANCH_URL.replace("$branch", options.branch) |
| 517 elif options.merge and options.sbranch: | 525 elif options.merge and options.sbranch: |
| 518 url = BRANCH_URL.replace("$branch", options.sbranch) | 526 url = BRANCH_URL.replace("$branch", options.sbranch) |
| 527 elif options.revert and options.url: |
| 528 url = options.url |
| 529 file_pattern_ = r"[ ]+([MADUC])[ ]+((/.*)/(.*))" |
| 519 else: | 530 else: |
| 520 url = TRUNK_URL | 531 url = TRUNK_URL |
| 521 | 532 |
| 522 working = options.workdir or DEFAULT_WORKING | 533 working = options.workdir or DEFAULT_WORKING |
| 523 | 534 |
| 524 if options.local: | 535 if options.local: |
| 525 working = os.getcwd() | 536 working = os.getcwd() |
| 526 if not inCheckoutRoot(working): | 537 if not inCheckoutRoot(working): |
| 527 print "'%s' appears not to be the root of a working copy" % working | 538 print "'%s' appears not to be the root of a working copy" % working |
| 528 return 1 | 539 return 1 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 556 mergeRevision(url, revision) | 567 mergeRevision(url, revision) |
| 557 # "Export" files that were added from the source and add them to branch | 568 # "Export" files that were added from the source and add them to branch |
| 558 exportRevision(url, revision) | 569 exportRevision(url, revision) |
| 559 # Delete directories that were deleted (file deletes are handled in the | 570 # Delete directories that were deleted (file deletes are handled in the |
| 560 # merge). | 571 # merge). |
| 561 deleteRevision(url, revision) | 572 deleteRevision(url, revision) |
| 562 elif options.revert: | 573 elif options.revert: |
| 563 action = "Revert" | 574 action = "Revert" |
| 564 if options.branch: | 575 if options.branch: |
| 565 url = BRANCH_URL.replace("$branch", options.branch) | 576 url = BRANCH_URL.replace("$branch", options.branch) |
| 566 checkoutRevision(url, revision, url, True) | 577 pop_em = not options.url |
| 578 checkoutRevision(url, revision, url, True, pop_em) |
| 567 revertRevision(url, revision) | 579 revertRevision(url, revision) |
| 568 revertExportRevision(url, revision) | 580 revertExportRevision(url, revision) |
| 569 | 581 |
| 570 # Check the base url so we actually find the author who made the change | 582 # Check the base url so we actually find the author who made the change |
| 571 if options.auditor: | 583 if options.auditor: |
| 572 author = options.auditor | 584 author = options.auditor |
| 573 else: | 585 else: |
| 574 author = getAuthor(url, revision) | 586 author = getAuthor(url, revision) |
| 575 if not author: | 587 if not author: |
| 576 author = getAuthor(TRUNK_URL, revision) | 588 author = getAuthor(TRUNK_URL, revision) |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 option_parser.add_option('-M', '--milestone', type="int", | 652 option_parser.add_option('-M', '--milestone', type="int", |
| 641 help='Milestone to revert or merge from') | 653 help='Milestone to revert or merge from') |
| 642 option_parser.add_option('-l', '--local', action='store_true', | 654 option_parser.add_option('-l', '--local', action='store_true', |
| 643 help='Local working copy to merge to') | 655 help='Local working copy to merge to') |
| 644 option_parser.add_option('-s', '--sbranch', | 656 option_parser.add_option('-s', '--sbranch', |
| 645 help='Source branch for merge') | 657 help='Source branch for merge') |
| 646 option_parser.add_option('-r', '--revert', type="int", | 658 option_parser.add_option('-r', '--revert', type="int", |
| 647 help='Revision to revert') | 659 help='Revision to revert') |
| 648 option_parser.add_option('-w', '--workdir', | 660 option_parser.add_option('-w', '--workdir', |
| 649 help='subdir to use for the revert') | 661 help='subdir to use for the revert') |
| 662 option_parser.add_option('-u', '--url', |
| 663 help='svn url to use for the revert') |
| 650 option_parser.add_option('-a', '--auditor', | 664 option_parser.add_option('-a', '--auditor', |
| 651 help='overrides the author for reviewer') | 665 help='overrides the author for reviewer') |
| 652 option_parser.add_option('', '--revertbot', action='store_true', | 666 option_parser.add_option('', '--revertbot', action='store_true', |
| 653 default=False) | 667 default=False) |
| 654 option_parser.add_option('', '--revertbot-commit', action='store_true', | 668 option_parser.add_option('', '--revertbot-commit', action='store_true', |
| 655 default=False) | 669 default=False) |
| 656 option_parser.add_option('', '--revertbot-reviewers') | 670 option_parser.add_option('', '--revertbot-reviewers') |
| 657 options, args = option_parser.parse_args() | 671 options, args = option_parser.parse_args() |
| 658 | 672 |
| 659 if not options.merge and not options.revert: | 673 if not options.merge and not options.revert: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 673 | 687 |
| 674 if options.branch and options.milestone: | 688 if options.branch and options.milestone: |
| 675 option_parser.error("--branch cannot be used with --milestone") | 689 option_parser.error("--branch cannot be used with --milestone") |
| 676 return 1 | 690 return 1 |
| 677 | 691 |
| 678 return drover(options, args) | 692 return drover(options, args) |
| 679 | 693 |
| 680 | 694 |
| 681 if __name__ == "__main__": | 695 if __name__ == "__main__": |
| 682 sys.exit(main()) | 696 sys.exit(main()) |
| OLD | NEW |