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..b1f0c7b787eade3dc6feef1e4ead6b47d957aa45 100644 |
| --- a/appengine/findit/crash/component.py |
| +++ b/appengine/findit/crash/component.py |
| @@ -5,6 +5,8 @@ |
| from collections import namedtuple |
| import re |
| +from libs.gitiles.diff import ChangeType |
| + |
| # TODO(http://crbug.com/659346): write the coverage tests. |
| class Component(namedtuple('Component', |
| @@ -23,7 +25,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 +36,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): |
|
chanli
2017/01/26 21:31:06
This function is similar to MatchesTouchedFile in
Sharu Jiang
2017/01/27 03:20:42
Since the ``Project`` and ``Component`` are 2 fund
|
| + """Returns true if the touched file belongs to this component.""" |
| + # TODO(ymzhang): 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(dep_path + path): |
| + return True |
| + |
| + return False |