Commit 8d9a76e0 authored by stgao's avatar stgao Committed by Commit bot

[Findit] Add timestamp of CL commit and fix two bugs.

Two bug fixed:
1. NormalizePath for components.
2. Add expected line separators in reasons.

NOTRY=true

Review URL: https://codereview.chromium.org/617073010

Cr-Commit-Position: refs/heads/master@{#297881}
parent fd619f2a
......@@ -20,8 +20,9 @@ class Blame(object):
file_name: The name of the file.
line_number: The line that caused a crash.
author: The author of this line on the latest revision.
crash_revision: The revision that caused the crash.
revision: The latest revision of this line before the crash revision.
message: The commit message for the revision.
time: When the revision was committed.
url: The url of the change for the revision.
range_start: The starting range of the regression for this component.
range_end: The ending range of the regression.
......@@ -29,7 +30,7 @@ class Blame(object):
"""
def __init__(self, line_content, component_name, stack_frame_index,
file_name, line_number, author, revision, message,
file_name, line_number, author, revision, message, time,
url, range_start, range_end):
# Set all the variables from the arguments.
self.line_content = line_content
......@@ -40,6 +41,7 @@ class Blame(object):
self.author = author
self.revision = revision
self.message = message
self.time = time
self.url = url
self.range_start = range_start
self.range_end = range_end
......@@ -133,9 +135,9 @@ class BlameList(object):
return
# Create blame object from the parsed info and add it to the list.
(line_content, revision, author, url, message) = parsed_blame_info
(line_content, revision, author, url, message, time) = parsed_blame_info
blame = Blame(line_content, component_name, stack_frame_index, file_name,
crashed_line_number, author, revision, message, url,
crashed_line_number, author, revision, message, time, url,
range_start, range_end)
with self.blame_list_lock:
......
......@@ -224,17 +224,11 @@ def NormalizePath(path, parsed_deps):
# 'Source' but chromium uses 'src/', and blink component path is
# 'src/third_party/WebKit/Source', so add 'Source/' in front of the
# normalized path.
if not (lower_normalized_path.startswith('src/') or
lower_normalized_path.startswith('source/')):
if (lower_component_path.endswith('src/') or
lower_component_path.endswith('source/')):
if (lower_component_path == 'src/third_party/webkit/source' and
not lower_normalized_path.startswith('source/')):
normalized_path = (current_component_path.split('/')[-2] + '/' +
normalized_path)
else:
normalized_path = 'src/' + normalized_path
component_name = parsed_deps[component_path]['name']
return (component_path, component_name, normalized_path)
......@@ -528,15 +522,16 @@ def MatchListToResultList(matches):
revision_url = match.revision_url
component_name = match.component_name
author = match.author
reason = match.reason
reason = match.reason.strip()
review_url = match.review_url
reviewers = match.reviewers
# For matches, line content do not exist.
line_content = None
message = match.message
time = match.time
result = Result(suspected_cl, revision_url, component_name, author, reason,
review_url, reviewers, line_content, message)
review_url, reviewers, line_content, message, time)
result_list.append(result)
return result_list
......@@ -561,6 +556,7 @@ def BlameListToResultList(blame_list):
reason = (
'The CL last changed line %s of file %s, which is stack frame %d.' %
(blame.line_number, blame.file, blame.stack_frame_index))
time = blame.time
# Blame object does not have review url and reviewers.
review_url = None
reviewers = None
......@@ -568,7 +564,7 @@ def BlameListToResultList(blame_list):
message = blame.message
result = Result(suspected_cl, revision_url, component_name, author, reason,
review_url, reviewers, line_content, message)
review_url, reviewers, line_content, message, time)
result_list.append(result)
return result_list
......@@ -495,7 +495,7 @@ def CombineMatches(matches):
continue
# Combine the reason if the current match is already in there.
found_match.reason += match.reason
found_match.reason += '\n' + match.reason
if match.min_distance < found_match.min_distance:
found_match.min_distance = match.min_distance
found_match.min_distance_info = match.min_distance_info
......@@ -503,10 +503,11 @@ def CombineMatches(matches):
for stack_index, cl, match in combined_matches:
if match.min_distance_info:
file_name, min_crashed_line, min_changed_line = match.min_distance_info
match.reason += \
('\nMinimum distance from crash line to modified line: %d. '
'(file: %s, crashed on: %d, modified: %d).\n' %
(match.min_distance, file_name, min_crashed_line, min_changed_line))
match.reason = match.reason.strip()
match.reason += (
'\nMinimum distance from crash line to modified line: %d. '
'(file: %s, crashed on: %d, modified: %d).' %
(match.min_distance, file_name, min_crashed_line, min_changed_line))
return combined_matches
......
......@@ -93,6 +93,8 @@ class GitParser(ParserInterface):
author = trs[1].getElementsByTagName(
'td')[0].firstChild.nodeValue.split('<')[0]
revision['author'] = author
revision['time'] = trs[1].getElementsByTagName(
'td')[0].firstChild.nodeValue
# Retrive and set message.
revision['message'] = pre.firstChild.nodeValue
......@@ -183,6 +185,7 @@ class GitParser(ParserInterface):
# Set author, message and URL of this CL.
revision['author'] = json_revision['author']['name']
revision['time'] = json_revision['author']['time']
revision['message'] = json_revision['message']
revision['url'] = url
......@@ -283,7 +286,8 @@ class GitParser(ParserInterface):
(revision_info, _) = self.ParseChangelog(component, revision, revision)
message = revision_info[revision]['message']
return (content, revision, author, revision_url, message)
time = revision_info[revision]['time']
return (content, revision, author, revision_url, message, time)
# Return none if the region does not exist.
return None
......@@ -39,6 +39,7 @@ class Match(object):
review_url: The codereview URL that reviews this CL.
reviewers: The list of people that reviewed this CL.
reason: The reason why this CL is suspected.
time: When this CL was committed.
"""
REVERT_PATTERN = re.compile(r'(revert\w*) r?(\d+)', re.I)
......@@ -60,6 +61,7 @@ class Match(object):
self.review_url = ''
self.reviewers = []
self.reason = None
self.time = revision['time']
def ParseMessage(self, message, codereview_api_url):
"""Parses the message.
......
......@@ -6,7 +6,7 @@
class Result(object):
def __init__(self, suspected_cl, revision_url, component_name, author,
reason, review_url, reviewers, line_content, message):
reason, review_url, reviewers, line_content, message, time):
self.suspected_cl = suspected_cl
self.revision_url = revision_url
self.component_name = component_name
......@@ -16,3 +16,4 @@ class Result(object):
self.reviewers = reviewers
self.line_content = line_content
self.commit_message = message
self.time = time
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment