| 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 | 7 |
| 8 from common import chrome_dependency_fetcher | 8 from common import chrome_dependency_fetcher |
| 9 from crash import crash_util | 9 from crash import crash_util |
| 10 from crash.results import MatchResults | 10 from crash.results import MatchResults |
| 11 from crash.scorers.aggregated_scorer import AggregatedScorer | 11 from crash.scorers.aggregated_scorer import AggregatedScorer |
| 12 from crash.scorers.min_distance import MinDistance | 12 from crash.scorers.min_distance import MinDistance |
| 13 from crash.scorers.top_frame_index import TopFrameIndex | 13 from crash.scorers.top_frame_index import TopFrameIndex |
| 14 from crash.stacktrace import CallStack | 14 from crash.stacktrace import CallStack |
| 15 from crash.stacktrace import Stacktrace | 15 from crash.stacktrace import Stacktrace |
| 16 from lib.gitiles.diff import ChangeType | 16 from lib.gitiles.diff import ChangeType |
| 17 | 17 |
| 18 # TODO(wrengr): make this a namedtuple. | 18 # TODO(http://crbug.com/661822): convert this into a namedtuple. |
| 19 class ChangelistClassifier(object): | 19 class ChangelistClassifier(object): |
| 20 def __init__(self, repository, | 20 def __init__(self, repository, |
| 21 top_n_frames, top_n_results=3, confidence_threshold=0.999): | 21 top_n_frames, top_n_results=3, confidence_threshold=0.999): |
| 22 """Args: | 22 """Args: |
| 23 repository (Repository): the Git repository for getting CLs to classify. | 23 repository (Repository): the Git repository for getting CLs to classify. |
| 24 top_n_frames (int): how many frames of each callstack to look at. | 24 top_n_frames (int): how many frames of each callstack to look at. |
| 25 top_n_results (int): maximum number of results to return. | 25 top_n_results (int): maximum number of results to return. |
| 26 confidence_threshold (float): In [0,1], above which we only return | 26 confidence_threshold (float): In [0,1], above which we only return |
| 27 the first result. | 27 the first result. |
| 28 """ | 28 """ |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 | 301 |
| 302 blame = repository.GetBlame(touched_file_path, | 302 blame = repository.GetBlame(touched_file_path, |
| 303 stack_deps[dep].revision) | 303 stack_deps[dep].revision) |
| 304 | 304 |
| 305 # Generate/update each result(changelog) in changelogs, blame is used | 305 # Generate/update each result(changelog) in changelogs, blame is used |
| 306 # to calculate distance between touched lines and crashed lines in file. | 306 # to calculate distance between touched lines and crashed lines in file. |
| 307 match_results.GenerateMatchResults( | 307 match_results.GenerateMatchResults( |
| 308 touched_file_path, dep, stack_infos, changelogs, blame) | 308 touched_file_path, dep, stack_infos, changelogs, blame) |
| 309 | 309 |
| 310 return match_results.values() | 310 return match_results.values() |
| OLD | NEW |