| 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 _INFINITY = 1000 | 5 _INFINITY = 1000 |
| 6 | 6 |
| 7 | 7 |
| 8 class Result(object): | 8 class Result(object): |
| 9 """Represents findit culprit result.""" | 9 """Represents findit culprit result.""" |
| 10 | 10 |
| 11 def __init__(self, changelog, dep_path, component, | 11 def __init__(self, changelog, dep_path, |
| 12 confidence=None, reason=None): | 12 confidence=None, reason=None): |
| 13 self.changelog = changelog | 13 self.changelog = changelog |
| 14 self.dep_path = dep_path | 14 self.dep_path = dep_path |
| 15 self.component = component | |
| 16 self.confidence = confidence | 15 self.confidence = confidence |
| 17 self.reason = reason | 16 self.reason = reason |
| 18 | 17 |
| 19 self.file_to_stack_infos = {} | 18 self.file_to_stack_infos = {} |
| 20 | 19 |
| 21 def ToDict(self): | 20 def ToDict(self): |
| 22 return { | 21 return { |
| 23 'url': self.changelog.commit_url, | 22 'url': self.changelog.commit_url, |
| 24 'review_url': self.changelog.code_review_url, | 23 'review_url': self.changelog.code_review_url, |
| 25 'revision': self.changelog.revision, | 24 'revision': self.changelog.revision, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 45 | 44 |
| 46 return '\n'.join(lines) | 45 return '\n'.join(lines) |
| 47 | 46 |
| 48 def __str__(self): | 47 def __str__(self): |
| 49 return self.ToString() | 48 return self.ToString() |
| 50 | 49 |
| 51 | 50 |
| 52 class MatchResult(Result): | 51 class MatchResult(Result): |
| 53 """Represents findit culprit result got from match algorithm.""" | 52 """Represents findit culprit result got from match algorithm.""" |
| 54 | 53 |
| 55 def __init__(self, changelog, dep_path, component, | 54 def __init__(self, changelog, dep_path, |
| 56 confidence=None, reason=None): | 55 confidence=None, reason=None): |
| 57 super(MatchResult, self).__init__( | 56 super(MatchResult, self).__init__( |
| 58 changelog, dep_path, component, confidence, reason) | 57 changelog, dep_path, confidence, reason) |
| 59 | 58 |
| 60 self.min_distance = _INFINITY | 59 self.min_distance = _INFINITY |
| 61 | 60 |
| 62 def Update(self, file_path, stack_infos, blame): | 61 def Update(self, file_path, stack_infos, blame): |
| 63 """Updates a match result with file path and its stack_infos and blame. | 62 """Updates a match result with file path and its stack_infos and blame. |
| 64 | 63 |
| 65 When a file_path is found both shown in stacktrace and touched by | 64 When a file_path is found both shown in stacktrace and touched by |
| 66 the revision of this result, update result with the information of | 65 the revision of this result, update result with the information of |
| 67 this file. | 66 this file. |
| 68 | 67 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 frames. | 124 frames. |
| 126 changelogs (list): List of Changelog objects in the dep in regression | 125 changelogs (list): List of Changelog objects in the dep in regression |
| 127 range which touched the file. | 126 range which touched the file. |
| 128 blame (Blame): Blame of the file. | 127 blame (Blame): Blame of the file. |
| 129 """ | 128 """ |
| 130 for changelog in changelogs: | 129 for changelog in changelogs: |
| 131 if self.ignore_cls and changelog.revision in self.ignore_cls: | 130 if self.ignore_cls and changelog.revision in self.ignore_cls: |
| 132 continue | 131 continue |
| 133 | 132 |
| 134 if changelog.revision not in self: | 133 if changelog.revision not in self: |
| 135 # TODO(katesonia): Enable component classifier later. Get it from | 134 self[changelog.revision] = MatchResult(changelog, dep_path) |
| 136 # file_path and dep_path. | |
| 137 component = '' | |
| 138 self[changelog.revision] = MatchResult(changelog, dep_path, component) | |
| 139 | 135 |
| 140 match_result = self[changelog.revision] | 136 match_result = self[changelog.revision] |
| 141 | 137 |
| 142 match_result.Update(file_path, stack_infos, blame) | 138 match_result.Update(file_path, stack_infos, blame) |
| OLD | NEW |