Chromium Code Reviews| Index: drover.py |
| diff --git a/drover.py b/drover.py |
| index 22e9b7d790609371338fc71a23224fe7900e7fc9..ca1c97b3ca20fc5be379852ec3af6f785bf5b1ac 100755 |
| --- a/drover.py |
| +++ b/drover.py |
| @@ -72,15 +72,13 @@ def gclUpload(revision, author): |
| def getSVNInfo(url, revision): |
| info = {} |
| - try: |
| - svn_info = subprocess2.check_output( |
| - ['svn', 'info', '%s@%s' % (url, revision)]).splitlines() |
| - for line in svn_info: |
| - match = re.search(r"(.*?):(.*)", line) |
| - if match: |
| - info[match.group(1).strip()] = match.group(2).strip() |
| - except subprocess2.CalledProcessError: |
| - pass |
| + svn_info = subprocess2.capture( |
| + ['svn', 'info', '--non-interactive', '%s@%s' % (url, revision)], |
| + stderr=subprocess2.VOID).splitlines() |
| + for line in svn_info: |
| + match = re.search(r"(.*?):(.*)", line) |
| + if match: |
| + info[match.group(1).strip()] = match.group(2).strip() |
| return info |
| def isSVNDirty(): |
| @@ -491,6 +489,8 @@ def drover(options, args): |
| # Initialize some variables used below. They can be overwritten by |
| # the drover.properties file. |
| BASE_URL = "svn://svn.chromium.org/chrome" |
| + REVERT_ALT_URLS = ['svn://svn.chromium.org/chrome-internal', |
| + 'svn://svn.chromium.org/native_client'] |
| TRUNK_URL = BASE_URL + "/trunk/src" |
| BRANCH_URL = BASE_URL + "/branches/$branch/src" |
| SKIP_CHECK_WORKING = True |
| @@ -521,11 +521,12 @@ def drover(options, args): |
| file_pattern_ = FILE_PATTERN |
| if options.revert and options.branch: |
| + print 'Note: --branch is usually not needed for reverts.' |
| url = BRANCH_URL.replace("$branch", options.branch) |
| elif options.merge and options.sbranch: |
| url = BRANCH_URL.replace("$branch", options.sbranch) |
| - elif options.revert and options.url: |
| - url = options.url |
| + elif options.revert: |
| + url = options.url or BASE_URL |
| file_pattern_ = r"[ ]+([MADUC])[ ]+((/.*)/(.*))" |
| else: |
| url = TRUNK_URL |
| @@ -541,6 +542,18 @@ def drover(options, args): |
| prompt("Working copy contains uncommitted files. Continue?")): |
| return 1 |
| + if options.revert and not options.no_alt_urls: |
| + for cur_url in [url] + REVERT_ALT_URLS: |
| + try: |
| + url_rev = int(getSVNInfo(cur_url, 'HEAD', ).get('Revision', '')) |
| + if 0 <= url_rev - options.revert < 20000: |
|
M-A Ruel
2013/03/18 17:09:37
Maybe 10000 to be on the safer side?
Isaac (away)
2013/03/18 19:25:59
I started w/ 10000 but it's only 2 months of chrom
|
| + if cur_url != url: |
| + print 'Guessing svn repo: %s.' % cur_url, |
| + print 'Use --no-alt-urls to disable heuristic.' |
| + url = cur_url |
| + break |
| + except ValueError: |
| + pass |
| command = 'svn log ' + url + " -r "+str(revision) + " -v" |
| os.system(command) |
| @@ -572,8 +585,6 @@ def drover(options, args): |
| deleteRevision(url, revision) |
| elif options.revert: |
| action = "Revert" |
| - if options.branch: |
| - url = BRANCH_URL.replace("$branch", options.branch) |
| pop_em = not options.url |
| checkoutRevision(url, revision, url, True, pop_em) |
| revertRevision(url, revision) |
| @@ -672,11 +683,13 @@ def main(): |
| help='svn url to use for the revert') |
| option_parser.add_option('-a', '--auditor', |
| help='overrides the author for reviewer') |
| - option_parser.add_option('', '--revertbot', action='store_true', |
| + option_parser.add_option('--revertbot', action='store_true', |
| default=False) |
| - option_parser.add_option('', '--revertbot-commit', action='store_true', |
| + option_parser.add_option('--no-alt-urls', action='store_true', |
| + help='Disable heuristics used to determine svn url') |
| + option_parser.add_option('--revertbot-commit', action='store_true', |
| default=False) |
| - option_parser.add_option('', '--revertbot-reviewers') |
| + option_parser.add_option('--revertbot-reviewers') |
| options, args = option_parser.parse_args() |
| if not options.merge and not options.revert: |