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): | |
Robert Sesek
2011/10/25 20:55:17
Needs """docstring"""
Nico
2011/10/25 20:57:24
Done.
| |
435 # . doesn't match newlines without re.DOTALL, so this is safe. | |
436 webkit_re = re.compile(r'webkit_revision.:\D*(\d+)') | |
437 m = webkit_re.search(urllib.urlopen(DEPS_FILE % rev).read()) | |
Robert Sesek
2011/10/25 20:55:17
Do you need to close this?
Nico
2011/10/25 20:57:24
It'll be closed when it's garbage collected or whe
Robert Sesek
2011/10/25 20:59:35
OK. But add a comment to that effect because this
| |
438 print m.group(0) | |
439 if m: | |
440 return int(m.group(1)) | |
441 else: | |
442 raise Exception('Could not get webkit revision for cr rev %d' % rev) | |
443 | |
444 | |
427 def main(): | 445 def main(): |
428 usage = ('%prog [options] [-- chromium-options]\n' | 446 usage = ('%prog [options] [-- chromium-options]\n' |
429 'Perform binary search on the snapshot builds.\n' | 447 'Perform binary search on the snapshot builds.\n' |
430 '\n' | 448 '\n' |
431 'Tip: add "-- --no-first-run" to bypass the first run prompts.') | 449 'Tip: add "-- --no-first-run" to bypass the first run prompts.') |
432 parser = optparse.OptionParser(usage=usage) | 450 parser = optparse.OptionParser(usage=usage) |
433 # Strangely, the default help output doesn't include the choice list. | 451 # Strangely, the default help output doesn't include the choice list. |
434 choices = ['mac', 'win', 'linux', 'linux64'] | 452 choices = ['mac', 'win', 'linux', 'linux64'] |
435 # linux-chromiumos lacks a continuous archive http://crbug.com/78158 | 453 # linux-chromiumos lacks a continuous archive http://crbug.com/78158 |
436 parser.add_option('-a', '--archive', | 454 parser.add_option('-a', '--archive', |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
485 else: | 503 else: |
486 good_rev = 0 | 504 good_rev = 0 |
487 try: | 505 try: |
488 good_rev = int(raw_input('Last known good [0]: ')) | 506 good_rev = int(raw_input('Last known good [0]: ')) |
489 except Exception, e: | 507 except Exception, e: |
490 pass | 508 pass |
491 | 509 |
492 (last_known_good_rev, first_known_bad_rev) = Bisect( | 510 (last_known_good_rev, first_known_bad_rev) = Bisect( |
493 opts.archive, good_rev, bad_rev, args, opts.profile) | 511 opts.archive, good_rev, bad_rev, args, opts.profile) |
494 | 512 |
513 # Get corresponding webkit revisions. | |
514 try: | |
515 last_known_good_webkit_rev = GetWebKitRevisionForChromiumRevision( | |
516 last_known_good_rev) | |
517 first_known_bad_webkit_rev = GetWebKitRevisionForChromiumRevision( | |
518 first_known_bad_rev) | |
519 except Exception, e: | |
520 # Silently ignore the failure. | |
521 last_known_good_webkit_rev, first_known_bad_webkit_rev = 0, 0 | |
522 | |
495 # We're done. Let the user know the results in an official manner. | 523 # 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) | 524 print('You are probably looking for build %d.' % first_known_bad_rev) |
497 print('CHANGELOG URL:') | 525 print last_known_good_webkit_rev , first_known_bad_webkit_rev |
498 print(CHANGELOG_URL % (last_known_good_rev, first_known_bad_rev)) | 526 if last_known_good_webkit_rev != first_known_bad_webkit_rev: |
499 print('Built at revision:') | 527 print 'WEBKIT CHANGELOG URL:' |
500 print(BUILD_VIEWVC_URL % first_known_bad_rev) | 528 print WEBKIT_CHANGELOG_URL % (first_known_bad_webkit_rev, |
529 last_known_good_webkit_rev) | |
530 print 'CHANGELOG URL:' | |
531 print CHANGELOG_URL % (last_known_good_rev, first_known_bad_rev) | |
532 print 'Built at revision:' | |
533 print BUILD_VIEWVC_URL % first_known_bad_rev | |
501 | 534 |
502 if __name__ == '__main__': | 535 if __name__ == '__main__': |
503 sys.exit(main()) | 536 sys.exit(main()) |
OLD | NEW |