| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import logging | 5 import logging |
| 6 from collections import defaultdict | 6 from collections import defaultdict |
| 7 from collections import namedtuple | 7 from collections import namedtuple |
| 8 | 8 |
| 9 from common import chrome_dependency_fetcher | 9 from common import chrome_dependency_fetcher |
| 10 from crash import crash_util | 10 from crash import crash_util |
| 11 from crash.suspect import Suspect | 11 from crash.suspect import Suspect |
| 12 from crash.suspect import Suspects | 12 from crash.suspect import SuspectMap |
| 13 from crash.scorers.aggregated_scorer import AggregatedScorer | 13 from crash.scorers.aggregated_scorer import AggregatedScorer |
| 14 from crash.scorers.min_distance import MinDistance | 14 from crash.scorers.min_distance import MinDistance |
| 15 from crash.scorers.top_frame_index import TopFrameIndex | 15 from crash.scorers.top_frame_index import TopFrameIndex |
| 16 from crash.stacktrace import CallStack | 16 from crash.stacktrace import CallStack |
| 17 from crash.stacktrace import Stacktrace | 17 from crash.stacktrace import Stacktrace |
| 18 from libs.gitiles.diff import ChangeType | 18 from libs.gitiles.diff import ChangeType |
| 19 | 19 |
| 20 | 20 |
| 21 class ChangelistClassifier(namedtuple('ChangelistClassifier', | 21 class ChangelistClassifier(namedtuple('ChangelistClassifier', |
| 22 ['repository', 'top_n_frames', 'top_n_results', 'confidence_threshold'])): | 22 ['repository', 'top_n_frames', 'top_n_results', 'confidence_threshold'])): |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 to a list of stack information of this file. A file may occur in several | 279 to a list of stack information of this file. A file may occur in several |
| 280 frames, one stack info consist of a StackFrame and the callstack priority | 280 frames, one stack info consist of a StackFrame and the callstack priority |
| 281 of it. | 281 of it. |
| 282 stack_deps (dict): Represents all the dependencies shown in the crash stack. | 282 stack_deps (dict): Represents all the dependencies shown in the crash stack. |
| 283 repository (Repository): Repository to get changelogs and blame from. | 283 repository (Repository): Repository to get changelogs and blame from. |
| 284 ignore_cls (set): Set of reverted revisions. | 284 ignore_cls (set): Set of reverted revisions. |
| 285 | 285 |
| 286 Returns: | 286 Returns: |
| 287 A list of ``Suspect`` instances with confidence and reason unset. | 287 A list of ``Suspect`` instances with confidence and reason unset. |
| 288 """ | 288 """ |
| 289 suspects = Suspects(ignore_cls) | 289 suspects = SuspectMap(ignore_cls) |
| 290 | 290 |
| 291 for dep, file_to_stack_infos in dep_to_file_to_stack_infos.iteritems(): | 291 for dep, file_to_stack_infos in dep_to_file_to_stack_infos.iteritems(): |
| 292 file_to_changelogs = dep_to_file_to_changelogs[dep] | 292 file_to_changelogs = dep_to_file_to_changelogs[dep] |
| 293 | 293 |
| 294 for crashed_file_path, stack_infos in file_to_stack_infos.iteritems(): | 294 for crashed_file_path, stack_infos in file_to_stack_infos.iteritems(): |
| 295 for touched_file_path, changelogs in file_to_changelogs.iteritems(): | 295 for touched_file_path, changelogs in file_to_changelogs.iteritems(): |
| 296 if not crash_util.IsSameFilePath(crashed_file_path, touched_file_path): | 296 if not crash_util.IsSameFilePath(crashed_file_path, touched_file_path): |
| 297 continue | 297 continue |
| 298 | 298 |
| 299 repository.repo_url = stack_deps[dep].repo_url | 299 repository.repo_url = stack_deps[dep].repo_url |
| 300 blame = repository.GetBlame(touched_file_path, | 300 blame = repository.GetBlame(touched_file_path, |
| 301 stack_deps[dep].revision) | 301 stack_deps[dep].revision) |
| 302 | 302 |
| 303 # Generate/update each suspect(changelog) in changelogs, blame is used | 303 # Generate/update each suspect(changelog) in changelogs, blame is used |
| 304 # to calculate distance between touched lines and crashed lines in file. | 304 # to calculate distance between touched lines and crashed lines in file. |
| 305 suspects.GenerateSuspects( | 305 suspects.GenerateSuspects( |
| 306 touched_file_path, dep, stack_infos, changelogs, blame) | 306 touched_file_path, dep, stack_infos, changelogs, blame) |
| 307 | 307 |
| 308 return suspects.values() | 308 return suspects.values() |
| OLD | NEW |