Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Side by Side Diff: appengine/findit/crash/suspect.py

Issue 2586343002: renamed the "Suspects" class to "SuspectMap", to reduce confusion. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 7
8 # TODO(wrengr): we should change things to use integers with None as 8 # TODO(wrengr): we should change things to use integers with None as
9 # \"infinity\", rather than using floats. 9 # \"infinity\", rather than using floats.
10 # TODO(http://crbug.com/644476): this class needs a better name. 10 # TODO(http://crbug.com/644476): this class needs a better name.
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 zero (because the ranges overlap).""" 159 zero (because the ranges overlap)."""
160 assert end1 >= start1, ValueError( 160 assert end1 >= start1, ValueError(
161 'the first range is empty: %d < %d' % (end1, start1)) 161 'the first range is empty: %d < %d' % (end1, start1))
162 assert end2 >= start2, ValueError( 162 assert end2 >= start2, ValueError(
163 'the second range is empty: %d < %d' % (end2, start2)) 163 'the second range is empty: %d < %d' % (end2, start2))
164 # There are six possible cases, but in all the cases where the two 164 # There are six possible cases, but in all the cases where the two
165 # ranges overlap, the latter two differences will be negative. 165 # ranges overlap, the latter two differences will be negative.
166 return max(0, start2 - end1, start1 - end2) 166 return max(0, start2 - end1, start1 - end2)
167 167
168 168
169 class Suspects(dict): 169 class SuspectMap(dict):
170 """A map from revisions to the ``Suspect`` object for that revision.""" 170 """A map from revisions to the ``Suspect`` object for that revision."""
171 171
172 def __init__(self, ignore_cls=None): 172 def __init__(self, ignore_cls=None):
173 super(Suspects, self).__init__() 173 super(SuspectMap, self).__init__()
174 self._ignore_cls = ignore_cls 174 self._ignore_cls = ignore_cls
175 175
176 def GenerateSuspects(self, file_path, dep_path, stack_infos, changelogs, 176 def GenerateSuspects(self, file_path, dep_path, stack_infos, changelogs,
177 blame): 177 blame):
178 """Compute suspects from a list of CLs, and store them. 178 """Compute suspects from a list of CLs, and store them in this map.
179 179
180 Suspects are generated based on newly found file path, its stack_infos, 180 Suspects are generated based on newly found file path, its stack_infos,
181 and all the changelogs that touched this file in the dep in regression 181 and all the changelogs that touched this file in the dep in regression
182 ranges, those reverted changelogs should be ignored. 182 ranges, those reverted changelogs should be ignored.
183 183
184 Args: 184 Args:
185 file_path (str): File path of the crashed file. 185 file_path (str): File path of the crashed file.
186 dep_path (str): Path of the dependency of the file. 186 dep_path (str): Path of the dependency of the file.
187 stack_infos (list): List of stack_info dicts, represents frames of this 187 stack_infos (list): List of stack_info dicts, represents frames of this
188 file and the callstack priorities of those frames. 188 file and the callstack priorities of those frames.
189 changelogs (list): List of Changelog objects in the dep in regression 189 changelogs (list): List of Changelog objects in the dep in regression
190 range which touched the file. 190 range which touched the file.
191 blame (Blame): Blame of the file. 191 blame (Blame): Blame of the file.
192 """ 192 """
193 for changelog in changelogs: 193 for changelog in changelogs:
194 if self._ignore_cls and changelog.revision in self._ignore_cls: 194 if self._ignore_cls and changelog.revision in self._ignore_cls:
195 continue 195 continue
196 196
197 if changelog.revision not in self: 197 if changelog.revision not in self:
198 self[changelog.revision] = Suspect(changelog, dep_path) 198 self[changelog.revision] = Suspect(changelog, dep_path)
199 199
200 _UpdateSuspect(self[changelog.revision], file_path, stack_infos, blame) 200 _UpdateSuspect(self[changelog.revision], file_path, stack_infos, blame)
OLDNEW
« no previous file with comments | « appengine/findit/crash/changelist_classifier.py ('k') | appengine/findit/crash/test/crash_test_suite.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698