| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 """Snapshot Build Bisect Tool | 6 """Snapshot Build Bisect Tool |
| 7 | 7 |
| 8 This script bisects a snapshot archive using binary search. It starts at | 8 This script bisects a snapshot archive using binary search. It starts at |
| 9 a bad revision (it will try to guess HEAD) and asks for a last known-good | 9 a bad revision (it will try to guess HEAD) and asks for a last known-good |
| 10 revision. It will then binary search across this revision range by downloading, | 10 revision. It will then binary search across this revision range by downloading, |
| 11 unzipping, and opening Chromium for you. After testing the specific revision, | 11 unzipping, and opening Chromium for you. After testing the specific revision, |
| 12 it will ask you whether it is good or bad before continuing the search. | 12 it will ask you whether it is good or bad before continuing the search. |
| 13 """ | 13 """ |
| 14 | 14 |
| 15 # The root URL for storage. | 15 # The root URL for storage. |
| 16 BASE_URL = 'http://commondatastorage.googleapis.com/chromium-browser-snapshots' | 16 BASE_URL = 'http://commondatastorage.googleapis.com/chromium-browser-snapshots' |
| 17 | 17 |
| 18 # URL to the ViewVC commit page. | 18 # URL to the ViewVC commit page. |
| 19 BUILD_VIEWVC_URL = 'http://src.chromium.org/viewvc/chrome?view=rev&revision=%d' | 19 BUILD_VIEWVC_URL = 'http://src.chromium.org/viewvc/chrome?view=rev&revision=%d' |
| 20 | 20 |
| 21 # Changelogs URL. | 21 # Changelogs URL. |
| 22 CHANGELOG_URL = 'http://build.chromium.org/f/chromium/' \ | 22 CHANGELOG_URL = 'http://build.chromium.org/f/chromium/' \ |
| 23 'perf/dashboard/ui/changelog.html?url=/trunk/src&range=%d:%d' | 23 'perf/dashboard/ui/changelog.html?url=/trunk/src&range=%d:%d' |
| 24 | 24 |
| 25 # DEPS file URL. |
| 26 DEPS_FILE= 'http://src.chromium.org/viewvc/chrome/trunk/src/DEPS?revision=%d' |
| 27 |
| 28 # WebKit Changelogs URL. |
| 29 WEBKIT_CHANGELOG_URL = 'http://trac.webkit.org/log/' \ |
| 30 'trunk/?rev=%d&stop_rev=%d&verbose=on' |
| 31 |
| 25 ############################################################################### | 32 ############################################################################### |
| 26 | 33 |
| 27 import math | 34 import math |
| 28 import optparse | 35 import optparse |
| 29 import os | 36 import os |
| 30 import pipes | 37 import pipes |
| 31 import re | 38 import re |
| 32 import shutil | 39 import shutil |
| 33 import subprocess | 40 import subprocess |
| 34 import sys | 41 import sys |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 os.unlink(f) | 424 os.unlink(f) |
| 418 except OSError: | 425 except OSError: |
| 419 pass | 426 pass |
| 420 sys.exit(0) | 427 sys.exit(0) |
| 421 | 428 |
| 422 rev = revlist[pivot] | 429 rev = revlist[pivot] |
| 423 | 430 |
| 424 return (revlist[good], revlist[bad]) | 431 return (revlist[good], revlist[bad]) |
| 425 | 432 |
| 426 | 433 |
| 434 def GetWebKitRevisionForChromiumRevision(rev): |
| 435 """Returns the webkit revision that was in chromium's DEPS file at |
| 436 chromium revision |rev|.""" |
| 437 # . doesn't match newlines without re.DOTALL, so this is safe. |
| 438 webkit_re = re.compile(r'webkit_revision.:\D*(\d+)') |
| 439 url = urllib.urlopen(DEPS_FILE % rev) |
| 440 m = webkit_re.search(url.read()) |
| 441 url.close() |
| 442 if m: |
| 443 return int(m.group(1)) |
| 444 else: |
| 445 raise Exception('Could not get webkit revision for cr rev %d' % rev) |
| 446 |
| 447 |
| 427 def main(): | 448 def main(): |
| 428 usage = ('%prog [options] [-- chromium-options]\n' | 449 usage = ('%prog [options] [-- chromium-options]\n' |
| 429 'Perform binary search on the snapshot builds.\n' | 450 'Perform binary search on the snapshot builds.\n' |
| 430 '\n' | 451 '\n' |
| 431 'Tip: add "-- --no-first-run" to bypass the first run prompts.') | 452 'Tip: add "-- --no-first-run" to bypass the first run prompts.') |
| 432 parser = optparse.OptionParser(usage=usage) | 453 parser = optparse.OptionParser(usage=usage) |
| 433 # Strangely, the default help output doesn't include the choice list. | 454 # Strangely, the default help output doesn't include the choice list. |
| 434 choices = ['mac', 'win', 'linux', 'linux64'] | 455 choices = ['mac', 'win', 'linux', 'linux64'] |
| 435 # linux-chromiumos lacks a continuous archive http://crbug.com/78158 | 456 # linux-chromiumos lacks a continuous archive http://crbug.com/78158 |
| 436 parser.add_option('-a', '--archive', | 457 parser.add_option('-a', '--archive', |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 else: | 506 else: |
| 486 good_rev = 0 | 507 good_rev = 0 |
| 487 try: | 508 try: |
| 488 good_rev = int(raw_input('Last known good [0]: ')) | 509 good_rev = int(raw_input('Last known good [0]: ')) |
| 489 except Exception, e: | 510 except Exception, e: |
| 490 pass | 511 pass |
| 491 | 512 |
| 492 (last_known_good_rev, first_known_bad_rev) = Bisect( | 513 (last_known_good_rev, first_known_bad_rev) = Bisect( |
| 493 opts.archive, good_rev, bad_rev, args, opts.profile) | 514 opts.archive, good_rev, bad_rev, args, opts.profile) |
| 494 | 515 |
| 516 # Get corresponding webkit revisions. |
| 517 try: |
| 518 last_known_good_webkit_rev = GetWebKitRevisionForChromiumRevision( |
| 519 last_known_good_rev) |
| 520 first_known_bad_webkit_rev = GetWebKitRevisionForChromiumRevision( |
| 521 first_known_bad_rev) |
| 522 except Exception, e: |
| 523 # Silently ignore the failure. |
| 524 last_known_good_webkit_rev, first_known_bad_webkit_rev = 0, 0 |
| 525 |
| 495 # We're done. Let the user know the results in an official manner. | 526 # We're done. Let the user know the results in an official manner. |
| 496 print('You are probably looking for build %d.' % first_known_bad_rev) | 527 print('You are probably looking for build %d.' % first_known_bad_rev) |
| 497 print('CHANGELOG URL:') | 528 if last_known_good_webkit_rev != first_known_bad_webkit_rev: |
| 498 print(CHANGELOG_URL % (last_known_good_rev, first_known_bad_rev)) | 529 print 'WEBKIT CHANGELOG URL:' |
| 499 print('Built at revision:') | 530 print WEBKIT_CHANGELOG_URL % (first_known_bad_webkit_rev, |
| 500 print(BUILD_VIEWVC_URL % first_known_bad_rev) | 531 last_known_good_webkit_rev) |
| 532 print 'CHANGELOG URL:' |
| 533 print CHANGELOG_URL % (last_known_good_rev, first_known_bad_rev) |
| 534 print 'Built at revision:' |
| 535 print BUILD_VIEWVC_URL % first_known_bad_rev |
| 501 | 536 |
| 502 if __name__ == '__main__': | 537 if __name__ == '__main__': |
| 503 sys.exit(main()) | 538 sys.exit(main()) |
| OLD | NEW |