Skip to content

Commit

Permalink
[Findit] Fix blame for GIT and uptake bug fix.
Browse files Browse the repository at this point in the history
NOTRY=true

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

Cr-Commit-Position: refs/heads/master@{#292319}
  • Loading branch information
stgaochromium authored and Commit bot committed Aug 28, 2014
1 parent e17795c commit 270213e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
3 changes: 3 additions & 0 deletions tools/findit/blame.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ def __GenerateBlameEntry(self, repository_parser, stack_frame,
file_path = stack_frame.file_path
crashed_line_number = stack_frame.crashed_line_range[0]

if file_path.startswith(component_path):
file_path = file_path[len(component_path):]

# Parse blame information.
parsed_blame_info = repository_parser.ParseBlameInfo(
component_path, file_path, crashed_line_number, crash_revision)
Expand Down
5 changes: 5 additions & 0 deletions tools/findit/chromium_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import base64
import json
import os
import re
import time
import urllib2

Expand All @@ -14,6 +15,7 @@
_THIS_DIR = os.path.abspath(os.path.dirname(__file__))
CONFIG = json.loads(open(os.path.join(_THIS_DIR,
'deps_config.json'), 'r').read())
OLD_GIT_URL_PATTERN = re.compile(r'https?://git.chromium.org/(.*)')


class _VarImpl(object):
Expand Down Expand Up @@ -147,6 +149,9 @@ def GetChromiumComponents(chromium_revision,

name = _GetComponentName(component_path, host_dirs)
repository, revision = component_repo_url.split('@')
match = OLD_GIT_URL_PATTERN.match(repository)
if match:
repository = 'https://chromium.googlesource.com/%s' % match.group(1)
is_git_hash = utils.IsGitHash(revision)
if is_git_hash:
repository_type = 'git'
Expand Down
4 changes: 2 additions & 2 deletions tools/findit/crash_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def GetDataFromURL(url, retries=10, sleep_time=0.1, timeout=5):
# Retrieves data from URL.
try:
status_code, data = utils.GetHttpClient().Get(url, timeout=timeout)
except IOError:
except IOError as e:
status_code = -1
data = None

Expand Down Expand Up @@ -370,7 +370,7 @@ def PrettifyFrameInfo(frame_indices, functions):
"""Return a string to represent the frames with functions."""
frames = []
for frame_index, function in zip(frame_indices, functions):
frames.append('frame #%s, function "%s"' % (frame_index, function))
frames.append('frame #%s, "%s"' % (frame_index, function.split('(')[0]))
return '; '.join(frames)


Expand Down
12 changes: 6 additions & 6 deletions tools/findit/findit_for_crash.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,8 @@ def GenerateReasonForMatches(matches):
pretty_file_names = crash_utils.PrettifyList(file_names)

# Add the reason, break because we took care of the rest of the files.
file_string += '(%s)' % crash_utils.PrettifyFrameInfo(
stack_frame_indices, function_list)
file_string += ('(and is part of stack %s)' %
crash_utils.PrettifyFrameInfo(stack_frame_indices, function_list))
reason.append(file_string % pretty_file_names)
break

Expand Down Expand Up @@ -522,8 +522,8 @@ def CombineMatches(matches):
if match.min_distance_info:
file_name, min_crashed_line, min_changed_line = match.min_distance_info
match.reason += \
('Minimum distance from crashed line to changed line: %d. '
'(File: %s, Crashed on: %d, Changed: %d).\n' %
('\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))

return combined_matches
Expand Down Expand Up @@ -668,8 +668,8 @@ def FindItForCrash(stacktrace_list,

if result:
return_message = (
'No CL in the regression changes the crashed files. The result is '
'the blame information.')
'No CL in the regression range changes the crashed files. '
'The result is the blame information.')

# When findit could not find any CL that changes file in stacktrace or if
# if cannot get any blame information, return a message saying that no
Expand Down
7 changes: 7 additions & 0 deletions tools/findit/stacktrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,13 @@ def __GenerateStackFrame(self, stack_frame_index, line, build_type,

# Return a new stack frame object with the parsed information.
file_name = file_path.split('/')[-1]

# If we have the common stack frame index pattern, then use it
# since it is more reliable.
index_match = re.match('\s*#(\d+)\s.*', line)
if index_match:
stack_frame_index = int(index_match.group(1))

return StackFrame(stack_frame_index, component_path, component_name,
file_name, function, file_path, crashed_line_range)

Expand Down

0 comments on commit 270213e

Please sign in to comment.