| 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 from collections import namedtuple | 5 from collections import namedtuple |
| 6 | 6 |
| 7 |
| 8 # TODO(wrengr): we should change things to use integers with None as |
| 9 # \"infinity\", rather than using floats. |
| 7 # TODO(http://crbug.com/644476): this class needs a better name. | 10 # TODO(http://crbug.com/644476): this class needs a better name. |
| 8 class AnalysisInfo(namedtuple('AnalysisInfo', | 11 class AnalysisInfo(namedtuple('AnalysisInfo', |
| 9 ['min_distance', 'min_distance_frame'])): | 12 ['min_distance', 'min_distance_frame'])): |
| 10 __slots__ = () | 13 __slots__ = () |
| 11 | 14 |
| 12 | 15 |
| 13 # TODO(wrengr): it's not clear why the ``priority`` is stored at all, | 16 # TODO(wrengr): it's not clear why the ``priority`` is stored at all, |
| 14 # given that every use in this file discards it. ``Result.file_to_stack_infos`` | 17 # given that every use in this file discards it. ``Result.file_to_stack_infos`` |
| 15 # should just store pointers directly to the frames themselves rather | 18 # should just store pointers directly to the frames themselves rather |
| 16 # than needing this intermediate object. | 19 # than needing this intermediate object. |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 range, then the difference between those points. Otherwise, returns | 140 range, then the difference between those points. Otherwise, returns |
| 138 zero (because the ranges overlap).""" | 141 zero (because the ranges overlap).""" |
| 139 assert end1 >= start1 | 142 assert end1 >= start1 |
| 140 assert end2 >= start2 | 143 assert end2 >= start2 |
| 141 # There are six possible cases, but in all the cases where the two | 144 # There are six possible cases, but in all the cases where the two |
| 142 # ranges overlap, the latter two differences will be negative. | 145 # ranges overlap, the latter two differences will be negative. |
| 143 return max(0, start2 - end1, start1 - end2) | 146 return max(0, start2 - end1, start1 - end2) |
| 144 | 147 |
| 145 | 148 |
| 146 class MatchResults(dict): | 149 class MatchResults(dict): |
| 147 """A dict indexing MatchResult with its revision.""" | 150 """A map from revisions to the MatchResult object for that revision.""" |
| 148 | 151 |
| 149 def __init__(self, ignore_cls=None): | 152 def __init__(self, ignore_cls=None): |
| 150 super(MatchResults, self).__init__() | 153 super(MatchResults, self).__init__() |
| 151 self._ignore_cls = ignore_cls | 154 self._ignore_cls = ignore_cls |
| 152 | 155 |
| 153 def GenerateMatchResults(self, file_path, dep_path, | 156 def GenerateMatchResults(self, file_path, dep_path, |
| 154 stack_infos, changelogs, blame): | 157 stack_infos, changelogs, blame): |
| 155 """Generates match results. | 158 """Compute match results from a list of CLs, and store them. |
| 156 | 159 |
| 157 Match results are generated based on newly found file path, its stack_infos, | 160 Match results are generated based on newly found file path, its stack_infos, |
| 158 and all the changelogs that touched this file in the dep in regression | 161 and all the changelogs that touched this file in the dep in regression |
| 159 ranges, those reverted changelogs should be ignored. | 162 ranges, those reverted changelogs should be ignored. |
| 160 | 163 |
| 161 Args: | 164 Args: |
| 162 file_path (str): File path of the crashed file. | 165 file_path (str): File path of the crashed file. |
| 163 dep_path (str): Path of the dependency of the file. | 166 dep_path (str): Path of the dependency of the file. |
| 164 stack_infos (list): List of stack_info dicts, represents frames of this | 167 stack_infos (list): List of stack_info dicts, represents frames of this |
| 165 file and the callstack priorities of those frames. | 168 file and the callstack priorities of those frames. |
| 166 changelogs (list): List of Changelog objects in the dep in regression | 169 changelogs (list): List of Changelog objects in the dep in regression |
| 167 range which touched the file. | 170 range which touched the file. |
| 168 blame (Blame): Blame of the file. | 171 blame (Blame): Blame of the file. |
| 169 """ | 172 """ |
| 170 for changelog in changelogs: | 173 for changelog in changelogs: |
| 171 if self._ignore_cls and changelog.revision in self._ignore_cls: | 174 if self._ignore_cls and changelog.revision in self._ignore_cls: |
| 172 continue | 175 continue |
| 173 | 176 |
| 174 if changelog.revision not in self: | 177 if changelog.revision not in self: |
| 175 self[changelog.revision] = MatchResult(changelog, dep_path) | 178 self[changelog.revision] = MatchResult(changelog, dep_path) |
| 176 | 179 |
| 177 match_result = self[changelog.revision] | 180 match_result = self[changelog.revision] |
| 178 match_result.Update(file_path, stack_infos, blame) | 181 match_result.Update(file_path, stack_infos, blame) |
| OLD | NEW |