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

Side by Side Diff: tools/findit/blame.py

Issue 617073010: [Findit] Add timestamp of CL commit and fix two bugs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 | tools/findit/crash_utils.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 (c) 2014 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2014 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 threading import Lock 5 from threading import Lock
6 6
7 from common import utils 7 from common import utils
8 import crash_utils 8 import crash_utils
9 9
10 10
11 class Blame(object): 11 class Blame(object):
12 """Represents a blame object. 12 """Represents a blame object.
13 13
14 The object contains blame information for one line of stack, and this 14 The object contains blame information for one line of stack, and this
15 information is shown when there are no CLs that change the crashing files. 15 information is shown when there are no CLs that change the crashing files.
16 Attributes: 16 Attributes:
17 line_content: The content of the line to find the blame for. 17 line_content: The content of the line to find the blame for.
18 component_name: The name of the component for this line. 18 component_name: The name of the component for this line.
19 stack_frame_index: The stack frame index of this file. 19 stack_frame_index: The stack frame index of this file.
20 file_name: The name of the file. 20 file_name: The name of the file.
21 line_number: The line that caused a crash. 21 line_number: The line that caused a crash.
22 author: The author of this line on the latest revision. 22 author: The author of this line on the latest revision.
23 crash_revision: The revision that caused the crash.
24 revision: The latest revision of this line before the crash revision. 23 revision: The latest revision of this line before the crash revision.
24 message: The commit message for the revision.
25 time: When the revision was committed.
25 url: The url of the change for the revision. 26 url: The url of the change for the revision.
26 range_start: The starting range of the regression for this component. 27 range_start: The starting range of the regression for this component.
27 range_end: The ending range of the regression. 28 range_end: The ending range of the regression.
28 29
29 """ 30 """
30 31
31 def __init__(self, line_content, component_name, stack_frame_index, 32 def __init__(self, line_content, component_name, stack_frame_index,
32 file_name, line_number, author, revision, message, 33 file_name, line_number, author, revision, message, time,
33 url, range_start, range_end): 34 url, range_start, range_end):
34 # Set all the variables from the arguments. 35 # Set all the variables from the arguments.
35 self.line_content = line_content 36 self.line_content = line_content
36 self.component_name = component_name 37 self.component_name = component_name
37 self.stack_frame_index = stack_frame_index 38 self.stack_frame_index = stack_frame_index
38 self.file = file_name 39 self.file = file_name
39 self.line_number = line_number 40 self.line_number = line_number
40 self.author = author 41 self.author = author
41 self.revision = revision 42 self.revision = revision
42 self.message = message 43 self.message = message
44 self.time = time
43 self.url = url 45 self.url = url
44 self.range_start = range_start 46 self.range_start = range_start
45 self.range_end = range_end 47 self.range_end = range_end
46 48
47 49
48 class BlameList(object): 50 class BlameList(object):
49 """Represents a list of blame objects. 51 """Represents a list of blame objects.
50 52
51 Thread-safe. 53 Thread-safe.
52 """ 54 """
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 128
127 # Parse blame information. 129 # Parse blame information.
128 parsed_blame_info = repository_parser.ParseBlameInfo( 130 parsed_blame_info = repository_parser.ParseBlameInfo(
129 component_path, file_path, crashed_line_number, crash_revision) 131 component_path, file_path, crashed_line_number, crash_revision)
130 132
131 # If it fails to retrieve information, do not do anything. 133 # If it fails to retrieve information, do not do anything.
132 if not parsed_blame_info: 134 if not parsed_blame_info:
133 return 135 return
134 136
135 # Create blame object from the parsed info and add it to the list. 137 # Create blame object from the parsed info and add it to the list.
136 (line_content, revision, author, url, message) = parsed_blame_info 138 (line_content, revision, author, url, message, time) = parsed_blame_info
137 blame = Blame(line_content, component_name, stack_frame_index, file_name, 139 blame = Blame(line_content, component_name, stack_frame_index, file_name,
138 crashed_line_number, author, revision, message, url, 140 crashed_line_number, author, revision, message, time, url,
139 range_start, range_end) 141 range_start, range_end)
140 142
141 with self.blame_list_lock: 143 with self.blame_list_lock:
142 self.blame_list.append(blame) 144 self.blame_list.append(blame)
143 145
144 def FilterAndSortBlameList(self): 146 def FilterAndSortBlameList(self):
145 """Filters and sorts the blame list.""" 147 """Filters and sorts the blame list."""
146 # Sort the blame list by its position in stack. 148 # Sort the blame list by its position in stack.
147 self.blame_list.sort(key=lambda blame: blame.stack_frame_index) 149 self.blame_list.sort(key=lambda blame: blame.stack_frame_index)
148 150
149 filtered_blame_list = [] 151 filtered_blame_list = []
150 152
151 for blame in self.blame_list: 153 for blame in self.blame_list:
152 # If regression information is available, check if it needs to be 154 # If regression information is available, check if it needs to be
153 # filtered. 155 # filtered.
154 if blame.range_start and blame.range_end: 156 if blame.range_start and blame.range_end:
155 157
156 # Discards results that are after the end of regression. 158 # Discards results that are after the end of regression.
157 if not utils.IsGitHash(blame.revision) and ( 159 if not utils.IsGitHash(blame.revision) and (
158 int(blame.range_end) <= int(blame.revision)): 160 int(blame.range_end) <= int(blame.revision)):
159 continue 161 continue
160 162
161 filtered_blame_list.append(blame) 163 filtered_blame_list.append(blame)
162 164
163 self.blame_list = filtered_blame_list 165 self.blame_list = filtered_blame_list
OLDNEW
« no previous file with comments | « no previous file | tools/findit/crash_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698