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 """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, |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
314 self.githash_svn_dict.update(new_dict) | 314 self.githash_svn_dict.update(new_dict) |
315 return revisions | 315 return revisions |
316 | 316 |
317 def _GetSVNRevisionFromGitHashWithoutGitCheckout(self, git_sha1, depot): | 317 def _GetSVNRevisionFromGitHashWithoutGitCheckout(self, git_sha1, depot): |
318 json_url = GITHASH_TO_SVN_URL[depot] % git_sha1 | 318 json_url = GITHASH_TO_SVN_URL[depot] % git_sha1 |
319 try: | 319 try: |
320 response = urllib.urlopen(json_url) | 320 response = urllib.urlopen(json_url) |
321 except urllib.HTTPError as error: | 321 except urllib.HTTPError as error: |
322 msg = 'HTTP Error %d for %s' % (error.getcode(), git_sha1) | 322 msg = 'HTTP Error %d for %s' % (error.getcode(), git_sha1) |
323 return None | 323 return None |
324 data = json.loads(response.read()[4:]) | 324 try: |
325 response_data = response.read() | |
326 data = json.loads(response_data[4:]) | |
327 except ValueError: | |
328 print 'Response string for %s is "%s"' % (json_url, response_data) | |
329 raise ValueError | |
325 if 'message' in data: | 330 if 'message' in data: |
326 message = data['message'].split('\n') | 331 message = data['message'].split('\n') |
327 message = [line for line in message if line.strip()] | 332 message = [line for line in message if line.strip()] |
328 search_pattern = re.compile(SEARCH_PATTERN[depot]) | 333 search_pattern = re.compile(SEARCH_PATTERN[depot]) |
329 result = search_pattern.search(message[len(message)-1]) | 334 result = search_pattern.search(message[len(message)-1]) |
330 if result: | 335 if result: |
331 return result.group(1) | 336 return result.group(1) |
332 print 'Failed to get svn revision number for %s' % git_sha1 | 337 print 'Failed to get svn revision number for %s' % git_sha1 |
333 raise ValueError | 338 raise ValueError |
334 | 339 |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
835 for f in [_GetDownloadPath(revlist[down_pivot]), | 840 for f in [_GetDownloadPath(revlist[down_pivot]), |
836 _GetDownloadPath(revlist[up_pivot])]: | 841 _GetDownloadPath(revlist[up_pivot])]: |
837 try: | 842 try: |
838 os.unlink(f) | 843 os.unlink(f) |
839 except OSError: | 844 except OSError: |
840 pass | 845 pass |
841 sys.exit(0) | 846 sys.exit(0) |
842 | 847 |
843 rev = revlist[pivot] | 848 rev = revlist[pivot] |
844 | 849 |
845 return (revlist[minrev], revlist[maxrev]) | 850 return (revlist[minrev], revlist[maxrev], context) |
846 | 851 |
847 | 852 |
848 def GetBlinkDEPSRevisionForChromiumRevision(rev): | 853 def GetBlinkDEPSRevisionForChromiumRevision(rev): |
849 """Returns the blink revision that was in REVISIONS file at | 854 """Returns the blink revision that was in REVISIONS file at |
850 chromium revision |rev|.""" | 855 chromium revision |rev|.""" |
851 # . doesn't match newlines without re.DOTALL, so this is safe. | 856 # . doesn't match newlines without re.DOTALL, so this is safe. |
852 blink_re = re.compile(r'webkit_revision\D*(\d+)') | 857 blink_re = re.compile(r'webkit_revision\D*(\d+)') |
853 url = urllib.urlopen(DEPS_FILE % rev) | 858 url = urllib.urlopen(DEPS_FILE % rev) |
854 m = blink_re.search(url.read()) | 859 m = blink_re.search(url.read()) |
855 url.close() | 860 url.close() |
856 if m: | 861 if m: |
857 return int(m.group(1)) | 862 return int(m.group(1)) |
858 else: | 863 else: |
859 raise Exception('Could not get Blink revision for Chromium rev %d' % rev) | 864 raise Exception('Could not get Blink revision for Chromium rev %d' % rev) |
860 | 865 |
861 | 866 |
862 def GetBlinkRevisionForChromiumRevision(self, rev): | 867 def GetBlinkRevisionForChromiumRevision(self, rev): |
Robert Sesek
2014/08/12 21:41:24
Rename self -> context
pshenoy
2014/08/13 18:13:41
Done.
| |
863 """Returns the blink revision that was in REVISIONS file at | 868 """Returns the blink revision that was in REVISIONS file at |
864 chromium revision |rev|.""" | 869 chromium revision |rev|.""" |
865 def _IsRevisionNumber(revision): | 870 def _IsRevisionNumber(revision): |
866 if isinstance(revision, int): | 871 if isinstance(revision, int): |
867 return True | 872 return True |
868 else: | 873 else: |
869 return revision.isdigit() | 874 return revision.isdigit() |
870 if str(rev) in self.githash_svn_dict: | 875 if str(rev) in self.githash_svn_dict: |
871 rev = self.githash_svn_dict[str(rev)] | 876 rev = self.githash_svn_dict[str(rev)] |
872 file_url = '%s/%s%s/REVISIONS' % (self.base_url, | 877 file_url = '%s/%s%s/REVISIONS' % (self.base_url, |
873 self._listing_platform_dir, rev) | 878 self._listing_platform_dir, rev) |
874 url = urllib.urlopen(file_url) | 879 url = urllib.urlopen(file_url) |
875 data = json.loads(url.read()) | 880 try: |
881 response = url.read() | |
882 data = json.loads(response) | |
883 except ValueError: | |
884 print 'Response from %s: "%s"' % (file_url, response) | |
885 raise ValueError | |
876 url.close() | 886 url.close() |
877 if 'webkit_revision' in data: | 887 if 'webkit_revision' in data: |
878 blink_rev = data['webkit_revision'] | 888 blink_rev = data['webkit_revision'] |
879 if not _IsRevisionNumber(blink_rev): | 889 if not _IsRevisionNumber(blink_rev): |
880 blink_rev = self.GetSVNRevisionFromGitHash(blink_rev, 'blink') | 890 blink_rev = int(self.GetSVNRevisionFromGitHash(blink_rev, 'blink')) |
881 return blink_rev | 891 return blink_rev |
882 else: | 892 else: |
883 raise Exception('Could not get blink revision for cr rev %d' % rev) | 893 raise Exception('Could not get blink revision for cr rev %d' % rev) |
884 | 894 |
885 | 895 |
886 def FixChromiumRevForBlink(revisions_final, revisions, self, rev): | 896 def FixChromiumRevForBlink(revisions_final, revisions, self, rev): |
887 """Returns the chromium revision that has the correct blink revision | 897 """Returns the chromium revision that has the correct blink revision |
888 for blink bisect, DEPS and REVISIONS file might not match since | 898 for blink bisect, DEPS and REVISIONS file might not match since |
889 blink snapshots point to tip of tree blink. | 899 blink snapshots point to tip of tree blink. |
890 Note: The revisions_final variable might get modified to include | 900 Note: The revisions_final variable might get modified to include |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1082 print('Number of times to run (%d) must be greater than or equal to 1.' % | 1092 print('Number of times to run (%d) must be greater than or equal to 1.' % |
1083 opts.times) | 1093 opts.times) |
1084 parser.print_help() | 1094 parser.print_help() |
1085 return 1 | 1095 return 1 |
1086 | 1096 |
1087 if opts.asan: | 1097 if opts.asan: |
1088 evaluator = IsGoodASANBuild | 1098 evaluator = IsGoodASANBuild |
1089 else: | 1099 else: |
1090 evaluator = AskIsGoodBuild | 1100 evaluator = AskIsGoodBuild |
1091 | 1101 |
1092 (min_chromium_rev, max_chromium_rev) = Bisect( | 1102 (min_chromium_rev, max_chromium_rev, context) = Bisect( |
Robert Sesek
2014/08/12 20:50:11
Why do you need to return context if you're not us
pshenoy
2014/08/12 21:05:06
'context' is passed in GetBlinkRevisionForChromium
Robert Sesek
2014/08/12 21:41:24
Ah, makes sense. Why don't we switch from passing
pshenoy
2014/08/13 18:13:41
Done.
| |
1093 base_url, opts.archive, opts.official_builds, opts.aura, opts.asan, | 1103 base_url, opts.archive, opts.official_builds, opts.aura, opts.asan, |
1094 opts.use_local_repo, good_rev, bad_rev, opts.times, opts.command, | 1104 opts.use_local_repo, good_rev, bad_rev, opts.times, opts.command, |
1095 args, opts.profile, opts.flash_path, opts.pdf_path, | 1105 args, opts.profile, opts.flash_path, opts.pdf_path, |
1096 not opts.not_interactive, evaluator) | 1106 not opts.not_interactive, evaluator) |
1097 | 1107 |
1098 # Get corresponding blink revisions. | 1108 # Get corresponding blink revisions. |
1099 try: | 1109 try: |
1100 min_blink_rev = GetBlinkRevisionForChromiumRevision(context, | 1110 min_blink_rev = GetBlinkRevisionForChromiumRevision(context, |
1101 min_chromium_rev) | 1111 min_chromium_rev) |
1102 max_blink_rev = GetBlinkRevisionForChromiumRevision(context, | 1112 max_blink_rev = GetBlinkRevisionForChromiumRevision(context, |
(...skipping 26 matching lines...) Expand all Loading... | |
1129 | 1139 |
1130 print 'CHANGELOG URL:' | 1140 print 'CHANGELOG URL:' |
1131 if opts.official_builds: | 1141 if opts.official_builds: |
1132 print OFFICIAL_CHANGELOG_URL % (min_chromium_rev, max_chromium_rev) | 1142 print OFFICIAL_CHANGELOG_URL % (min_chromium_rev, max_chromium_rev) |
1133 else: | 1143 else: |
1134 print ' ' + CHANGELOG_URL % (min_chromium_rev, max_chromium_rev) | 1144 print ' ' + CHANGELOG_URL % (min_chromium_rev, max_chromium_rev) |
1135 | 1145 |
1136 | 1146 |
1137 if __name__ == '__main__': | 1147 if __name__ == '__main__': |
1138 sys.exit(main()) | 1148 sys.exit(main()) |
OLD | NEW |