Chromium Code Reviews| Index: appengine/findit/crash/component.py |
| diff --git a/appengine/findit/crash/component.py b/appengine/findit/crash/component.py |
| index 5e1c7a66ab75cce7d17c01ed7433157183a78918..70eb10a255d7a036cf594c44919add57db685388 100644 |
| --- a/appengine/findit/crash/component.py |
| +++ b/appengine/findit/crash/component.py |
| @@ -3,8 +3,11 @@ |
| # found in the LICENSE file. |
| from collections import namedtuple |
| +import os |
| import re |
| +from libs.gitiles.diff import ChangeType |
| + |
| # TODO(http://crbug.com/659346): write the coverage tests. |
| class Component(namedtuple('Component', |
| @@ -23,7 +26,6 @@ class Component(namedtuple('Component', |
| re.compile(path_regex), |
| re.compile(function_regex) if function_regex else None) |
| - |
| def MatchesStackFrame(self, frame): |
| """Returns true if this component matches the frame.""" |
| if not self.path_regex.match(frame.dep_path + frame.file_path): |
| @@ -35,6 +37,16 @@ class Component(namedtuple('Component', |
| return True |
| return self.function_regex.match(frame.function) |
| - def MatchesFile(self, file_path): |
| - """Returns true if this component matches file path.""" |
| - return self.path_regex.match(file_path) |
| + def MatchesTouchedFile(self, dep_path, touched_file): |
| + """Returns true if the touched file belongs to this component.""" |
| + # TODO(crbug.com/685884): use component of new path as default. RENAME might |
| + # need to return two (old path new path may have different components) |
| + if touched_file.change_type == ChangeType.DELETE: |
| + path = touched_file.old_path |
| + else: |
| + path = touched_file.new_path |
| + |
| + if self.path_regex.match(os.path.join(dep_path, path)): |
|
lijeffrey
2017/01/27 15:42:20
how about just return path.regex.match(...)
Sharu Jiang
2017/01/27 18:39:04
Done.
|
| + return True |
| + |
| + return False |