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

Side by Side Diff: drover.py

Issue 12111002: Add support for svn paths in the revert (removes need for .properties file). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: Created 7 years, 10 months 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 | no next file » | 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 (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
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 if pop:
198 subpaths.pop(0)
M-A Ruel 2013/01/29 23:04:10 Could you add a one line comment why it's done? I
198 base = '' 199 base = ''
199 for subpath in subpaths: 200 for subpath in subpaths:
200 base += '/' + subpath 201 base += '/' + subpath
201 # This logic ensures that you don't empty out any directories 202 # This logic ensures that you don't empty out any directories
202 if not os.path.exists("." + base): 203 if not os.path.exists("." + base):
203 command = ('svn update --depth empty ' + "." + base) 204 command = ('svn update --depth empty ' + "." + base)
204 print command 205 print command
205 os.system(command) 206 os.system(command)
206 207
207 if (revert): 208 if (revert):
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 f = open("drover.properties") 510 f = open("drover.properties")
510 exec(f) 511 exec(f)
511 f.close() 512 f.close()
512 if FILE_PATTERN: 513 if FILE_PATTERN:
513 file_pattern_ = FILE_PATTERN 514 file_pattern_ = FILE_PATTERN
514 515
515 if options.revert and options.branch: 516 if options.revert and options.branch:
516 url = BRANCH_URL.replace("$branch", options.branch) 517 url = BRANCH_URL.replace("$branch", options.branch)
517 elif options.merge and options.sbranch: 518 elif options.merge and options.sbranch:
518 url = BRANCH_URL.replace("$branch", options.sbranch) 519 url = BRANCH_URL.replace("$branch", options.sbranch)
520 elif options.revert and options.url:
521 url = options.url
522 file_pattern_ = r"[ ]+([MADUC])[ ]+((/.*)/(.*))"
519 else: 523 else:
520 url = TRUNK_URL 524 url = TRUNK_URL
521 525
522 working = options.workdir or DEFAULT_WORKING 526 working = options.workdir or DEFAULT_WORKING
523 527
524 if options.local: 528 if options.local:
525 working = os.getcwd() 529 working = os.getcwd()
526 if not inCheckoutRoot(working): 530 if not inCheckoutRoot(working):
527 print "'%s' appears not to be the root of a working copy" % working 531 print "'%s' appears not to be the root of a working copy" % working
528 return 1 532 return 1
(...skipping 27 matching lines...) Expand all
556 mergeRevision(url, revision) 560 mergeRevision(url, revision)
557 # "Export" files that were added from the source and add them to branch 561 # "Export" files that were added from the source and add them to branch
558 exportRevision(url, revision) 562 exportRevision(url, revision)
559 # Delete directories that were deleted (file deletes are handled in the 563 # Delete directories that were deleted (file deletes are handled in the
560 # merge). 564 # merge).
561 deleteRevision(url, revision) 565 deleteRevision(url, revision)
562 elif options.revert: 566 elif options.revert:
563 action = "Revert" 567 action = "Revert"
564 if options.branch: 568 if options.branch:
565 url = BRANCH_URL.replace("$branch", options.branch) 569 url = BRANCH_URL.replace("$branch", options.branch)
566 checkoutRevision(url, revision, url, True) 570 pop_em = (options.url == None or options.url == '')
M-A Ruel 2013/01/29 23:04:10 pop_em = not options.url
571 checkoutRevision(url, revision, url, True, pop_em)
567 revertRevision(url, revision) 572 revertRevision(url, revision)
568 revertExportRevision(url, revision) 573 revertExportRevision(url, revision)
569 574
570 # Check the base url so we actually find the author who made the change 575 # Check the base url so we actually find the author who made the change
571 if options.auditor: 576 if options.auditor:
572 author = options.auditor 577 author = options.auditor
573 else: 578 else:
574 author = getAuthor(url, revision) 579 author = getAuthor(url, revision)
575 if not author: 580 if not author:
576 author = getAuthor(TRUNK_URL, revision) 581 author = getAuthor(TRUNK_URL, revision)
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 option_parser.add_option('-M', '--milestone', type="int", 645 option_parser.add_option('-M', '--milestone', type="int",
641 help='Milestone to revert or merge from') 646 help='Milestone to revert or merge from')
642 option_parser.add_option('-l', '--local', action='store_true', 647 option_parser.add_option('-l', '--local', action='store_true',
643 help='Local working copy to merge to') 648 help='Local working copy to merge to')
644 option_parser.add_option('-s', '--sbranch', 649 option_parser.add_option('-s', '--sbranch',
645 help='Source branch for merge') 650 help='Source branch for merge')
646 option_parser.add_option('-r', '--revert', type="int", 651 option_parser.add_option('-r', '--revert', type="int",
647 help='Revision to revert') 652 help='Revision to revert')
648 option_parser.add_option('-w', '--workdir', 653 option_parser.add_option('-w', '--workdir',
649 help='subdir to use for the revert') 654 help='subdir to use for the revert')
655 option_parser.add_option('-u', '--url',
656 help='svn url to use for the revert')
650 option_parser.add_option('-a', '--auditor', 657 option_parser.add_option('-a', '--auditor',
651 help='overrides the author for reviewer') 658 help='overrides the author for reviewer')
652 option_parser.add_option('', '--revertbot', action='store_true', 659 option_parser.add_option('', '--revertbot', action='store_true',
653 default=False) 660 default=False)
654 option_parser.add_option('', '--revertbot-commit', action='store_true', 661 option_parser.add_option('', '--revertbot-commit', action='store_true',
655 default=False) 662 default=False)
656 option_parser.add_option('', '--revertbot-reviewers') 663 option_parser.add_option('', '--revertbot-reviewers')
657 options, args = option_parser.parse_args() 664 options, args = option_parser.parse_args()
658 665
659 if not options.merge and not options.revert: 666 if not options.merge and not options.revert:
(...skipping 13 matching lines...) Expand all
673 680
674 if options.branch and options.milestone: 681 if options.branch and options.milestone:
675 option_parser.error("--branch cannot be used with --milestone") 682 option_parser.error("--branch cannot be used with --milestone")
676 return 1 683 return 1
677 684
678 return drover(options, args) 685 return drover(options, args)
679 686
680 687
681 if __name__ == "__main__": 688 if __name__ == "__main__":
682 sys.exit(main()) 689 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698