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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 return None | 262 return None |
263 data = json.loads(response.read()[4:]) | 263 data = json.loads(response.read()[4:]) |
264 if 'message' in data: | 264 if 'message' in data: |
265 message = data['message'].split('\n') | 265 message = data['message'].split('\n') |
266 message = [line for line in message if line.strip()] | 266 message = [line for line in message if line.strip()] |
267 search_pattern = re.compile(SEARCH_PATTERN[depot]) | 267 search_pattern = re.compile(SEARCH_PATTERN[depot]) |
268 result = search_pattern.search(message[len(message)-1]) | 268 result = search_pattern.search(message[len(message)-1]) |
269 if result: | 269 if result: |
270 return result.group(1) | 270 return result.group(1) |
271 print 'Failed to get svn revision number for %s' % git_sha1 | 271 print 'Failed to get svn revision number for %s' % git_sha1 |
272 return None | 272 raise ValueError |
273 | 273 |
274 def _GetSVNRevisionFromGitHashFromGitCheckout(self, git_sha1, depot): | 274 def _GetSVNRevisionFromGitHashFromGitCheckout(self, git_sha1, depot): |
275 def _RunGit(command, path): | 275 def _RunGit(command, path): |
276 command = ['git'] + command | 276 command = ['git'] + command |
277 if path: | 277 if path: |
278 original_path = os.getcwd() | 278 original_path = os.getcwd() |
279 os.chdir(path) | 279 os.chdir(path) |
280 shell = sys.platform.startswith('win') | 280 shell = sys.platform.startswith('win') |
281 proc = subprocess.Popen(command, shell=shell, stdout=subprocess.PIPE, | 281 proc = subprocess.Popen(command, shell=shell, stdout=subprocess.PIPE, |
282 stderr=subprocess.PIPE) | 282 stderr=subprocess.PIPE) |
283 (output, _) = proc.communicate() | 283 (output, _) = proc.communicate() |
284 | 284 |
285 if path: | 285 if path: |
286 os.chdir(original_path) | 286 os.chdir(original_path) |
287 return (output, proc.returncode) | 287 return (output, proc.returncode) |
288 | 288 |
289 path = None | 289 path = None |
290 if depot == 'blink': | 290 if depot == 'blink': |
291 path = os.path.join(os.getcwd(), 'third_party', 'WebKit') | 291 path = os.path.join(os.getcwd(), 'third_party', 'WebKit') |
292 if os.path.basename(os.getcwd()) == 'src': | 292 if os.path.basename(os.getcwd()) == 'src': |
293 command = ['svn', 'find-rev', git_sha1] | 293 command = ['svn', 'find-rev', git_sha1] |
294 (git_output, return_code) = _RunGit(command, path) | 294 (git_output, return_code) = _RunGit(command, path) |
295 if not return_code: | 295 if not return_code: |
296 return git_output.strip('\n') | 296 return git_output.strip('\n') |
297 return None | 297 raise ValueError |
298 else: | 298 else: |
299 print ('Script should be run from src folder. ' + | 299 print ('Script should be run from src folder. ' + |
300 'Eg: python tools/bisect-builds.py -g 280588 -b 280590' + | 300 'Eg: python tools/bisect-builds.py -g 280588 -b 280590' + |
301 '--archive linux64 --use-local-repo') | 301 '--archive linux64 --use-local-repo') |
302 sys.exit(1) | 302 sys.exit(1) |
303 | 303 |
304 def GetSVNRevisionFromGitHash(self, git_sha1, depot='chromium'): | 304 def GetSVNRevisionFromGitHash(self, git_sha1, depot='chromium'): |
305 if not self.use_local_repo: | 305 if not self.use_local_repo: |
306 return self._GetSVNRevisionFromGitHashWithoutGitCheckout(git_sha1, depot) | 306 return self._GetSVNRevisionFromGitHashWithoutGitCheckout(git_sha1, depot) |
307 else: | 307 else: |
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1002 "you might also want to do a Blink bisect.") | 1002 "you might also want to do a Blink bisect.") |
1003 | 1003 |
1004 print 'CHANGELOG URL:' | 1004 print 'CHANGELOG URL:' |
1005 if opts.official_builds: | 1005 if opts.official_builds: |
1006 print OFFICIAL_CHANGELOG_URL % (min_chromium_rev, max_chromium_rev) | 1006 print OFFICIAL_CHANGELOG_URL % (min_chromium_rev, max_chromium_rev) |
1007 else: | 1007 else: |
1008 print ' ' + CHANGELOG_URL % (min_chromium_rev, max_chromium_rev) | 1008 print ' ' + CHANGELOG_URL % (min_chromium_rev, max_chromium_rev) |
1009 | 1009 |
1010 if __name__ == '__main__': | 1010 if __name__ == '__main__': |
1011 sys.exit(main()) | 1011 sys.exit(main()) |
OLD | NEW |