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

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

Issue 2607613002: Converting Region class to a namedtuple (Closed)
Patch Set: Created 3 years, 12 months 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
« no previous file with comments | « no previous file | appengine/findit/libs/gitiles/blame.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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 StackInfo
11 from crash.suspect import Suspect 12 from crash.suspect import Suspect
12 from crash.suspect import SuspectMap 13 from crash.suspect import SuspectMap
13 from crash.scorers.aggregated_scorer import AggregatedScorer 14 from crash.scorers.aggregated_scorer import AggregatedScorer
14 from crash.scorers.min_distance import MinDistance 15 from crash.scorers.min_distance import MinDistance
15 from crash.scorers.top_frame_index import TopFrameIndex 16 from crash.scorers.top_frame_index import TopFrameIndex
16 from crash.stacktrace import CallStack 17 from crash.stacktrace import CallStack
17 from crash.stacktrace import Stacktrace 18 from crash.stacktrace import Stacktrace
18 from libs.gitiles.diff import ChangeType 19 from libs.gitiles.diff import ChangeType
19 20
20 21
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 dep_to_file_to_changelogs = defaultdict(lambda: defaultdict(list)) 185 dep_to_file_to_changelogs = defaultdict(lambda: defaultdict(list))
185 reverted_cls = set() 186 reverted_cls = set()
186 187
187 for dep in stack_deps: 188 for dep in stack_deps:
188 # If a dep is not in regression range, than it cannot be the dep of 189 # If a dep is not in regression range, than it cannot be the dep of
189 # culprits. 190 # culprits.
190 dep_roll = regression_deps_rolls.get(dep) 191 dep_roll = regression_deps_rolls.get(dep)
191 if not dep_roll: 192 if not dep_roll:
192 continue 193 continue
193 194
194 dep_roll = regression_deps_rolls[dep]
195
196 repository.repo_url = dep_roll.repo_url 195 repository.repo_url = dep_roll.repo_url
197 changelogs = repository.GetChangeLogs(dep_roll.old_revision, 196 changelogs = repository.GetChangeLogs(dep_roll.old_revision,
198 dep_roll.new_revision) 197 dep_roll.new_revision)
199 198
200 if not changelogs: 199 for changelog in changelogs or []:
201 continue
202
203 for changelog in changelogs:
204 # When someone reverts, we need to skip both the CL doing 200 # When someone reverts, we need to skip both the CL doing
205 # the reverting as well as the CL that got reverted. If 201 # the reverting as well as the CL that got reverted. If
206 # ``reverted_revision`` is true, then this CL reverts another one, 202 # ``reverted_revision`` is true, then this CL reverts another one,
207 # so we skip it and save the CL it reverts in ``reverted_cls`` to 203 # so we skip it and save the CL it reverts in ``reverted_cls`` to
208 # be filtered out later. 204 # be filtered out later.
209 if changelog.reverted_revision: 205 if changelog.reverted_revision:
210 reverted_cls.add(changelog.reverted_revision) 206 reverted_cls.add(changelog.reverted_revision)
211 continue 207 continue
212 208
213 for touched_file in changelog.touched_files: 209 for touched_file in changelog.touched_files:
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 } 241 }
246 """ 242 """
247 dep_to_file_to_stack_infos = defaultdict(lambda: defaultdict(list)) 243 dep_to_file_to_stack_infos = defaultdict(lambda: defaultdict(list))
248 244
249 for callstack in stacktrace: 245 for callstack in stacktrace:
250 for frame in callstack: 246 for frame in callstack:
251 # We only care about those dependencies in crash stack. 247 # We only care about those dependencies in crash stack.
252 if frame.dep_path not in stack_deps: 248 if frame.dep_path not in stack_deps:
253 continue 249 continue
254 250
255 dep_to_file_to_stack_infos[frame.dep_path][frame.file_path].append(( 251 dep_to_file_to_stack_infos[frame.dep_path][frame.file_path].append(
256 frame, callstack.priority)) 252 StackInfo(frame, callstack.priority))
257 253
258 return dep_to_file_to_stack_infos 254 return dep_to_file_to_stack_infos
259 255
260 256
261 # TODO(katesonia): Remove the repository argument after refatoring cl committed. 257 # TODO(katesonia): Remove the repository argument after refatoring cl committed.
262 def FindSuspects(dep_to_file_to_changelogs, 258 def FindSuspects(dep_to_file_to_changelogs,
263 dep_to_file_to_stack_infos, 259 dep_to_file_to_stack_infos,
264 stack_deps, repository, 260 stack_deps, repository,
265 ignore_cls=None): 261 ignore_cls=None):
266 """Finds suspects by matching stacktrace and changelogs in regression range. 262 """Finds suspects by matching stacktrace and changelogs in regression range.
(...skipping 27 matching lines...) Expand all
294 repository.repo_url = stack_deps[dep].repo_url 290 repository.repo_url = stack_deps[dep].repo_url
295 blame = repository.GetBlame(touched_file_path, 291 blame = repository.GetBlame(touched_file_path,
296 stack_deps[dep].revision) 292 stack_deps[dep].revision)
297 293
298 # Generate/update each suspect(changelog) in changelogs, blame is used 294 # Generate/update each suspect(changelog) in changelogs, blame is used
299 # to calculate distance between touched lines and crashed lines in file. 295 # to calculate distance between touched lines and crashed lines in file.
300 suspects.GenerateSuspects( 296 suspects.GenerateSuspects(
301 touched_file_path, dep, stack_infos, changelogs, blame) 297 touched_file_path, dep, stack_infos, changelogs, blame)
302 298
303 return suspects.values() 299 return suspects.values()
OLDNEW
« no previous file with comments | « no previous file | appengine/findit/libs/gitiles/blame.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698