(self, diff, commit, is_merge_commit,
old_fname=None, new_fname=None)
| 176 | get_contents(self.repo, commit, fname), ext='.java') |
| 177 | |
| 178 | def _first_phase(self, diff, commit, is_merge_commit, |
| 179 | old_fname=None, new_fname=None): |
| 180 | |
| 181 | if ((old_fname and self.fname_filter(old_fname)) or |
| 182 | (new_fname and self.fname_filter(new_fname))): |
| 183 | |
| 184 | # on add, rename, modify: update_roots = [new_root] |
| 185 | # on delete: update_roots = [] |
| 186 | update_roots = [] |
| 187 | |
| 188 | # on add: modified_func = {} |
| 189 | # on rename, modify, delete: modified_func is computed by |
| 190 | # parsing patch and call get_changed_functions |
| 191 | modified_func = {} |
| 192 | |
| 193 | # do not need to parse patch if on add |
| 194 | if old_fname is not None: |
| 195 | additions, deletions = self.parse_patch(diff.diff) |
| 196 | if additions is None or deletions is None: |
| 197 | return -1 |
| 198 | |
| 199 | old_root = self._get_xml_root(commit.parents[0], old_fname) |
| 200 | if old_root is None: |
| 201 | return -1 |
| 202 | |
| 203 | if self.lang == 'c': |
| 204 | modified_func = get_changed_functions( |
| 205 | *get_func_ranges_c(old_root), additions, deletions) |
| 206 | elif self.lang == 'java': |
| 207 | modified_func = get_changed_functions( |
| 208 | *get_func_ranges_java(old_root), additions, deletions) |
| 209 | |
| 210 | # parse new src to tree |
| 211 | if new_fname is not None: |
| 212 | new_root = self._get_xml_root(commit, new_fname) |
| 213 | if new_root is None: |
| 214 | return -1 |
| 215 | update_roots.append(new_root) |
| 216 | |
| 217 | # update call graph |
| 218 | # if on delete, then new_func is expected to be an empty dict |
| 219 | if self.lang == 'c': |
| 220 | new_func = update_call_graph_c( |
| 221 | self.G, update_roots, modified_func) |
| 222 | elif self.lang == 'java': |
| 223 | new_func = update_call_graph_java( |
| 224 | self.G, update_roots, modified_func, env=self.env) |
| 225 | |
| 226 | # only update self.history for non-merge commit |
| 227 | if not is_merge_commit: |
| 228 | for func_name in new_func: |
| 229 | self.history[commit.hexsha][func_name] = \ |
| 230 | new_func[func_name] |
| 231 | |
| 232 | for func_name in modified_func: |
| 233 | self.history[commit.hexsha][func_name] = \ |
| 234 | modified_func[func_name] |
| 235 |
no test coverage detected