| 48 | |
| 49 | @staticmethod |
| 50 | def from_diff_raw_line(line: RawDiffLine, a_dir: str, b_dir: str): |
| 51 | status = line.status |
| 52 | # A, C (copy), D, M, R, T (change in type), U (unmerged), X (bug) |
| 53 | if status == 'A': |
| 54 | return LocalFileDiff(a_dir, '', b_dir, line.path, is_move=False, num_add=line.num_add, num_delete=line.num_delete) |
| 55 | if status == 'D': |
| 56 | return LocalFileDiff(a_dir, line.path, b_dir, '', is_move=False, num_add=line.num_add, num_delete=line.num_delete) |
| 57 | if line.dst_path: |
| 58 | return LocalFileDiff(a_dir, line.path, b_dir, line.dst_path, is_move=True, num_add=line.num_add, num_delete=line.num_delete) |
| 59 | dst_path = os.path.join(b_dir, os.path.relpath(line.path, a_dir)) |
| 60 | return LocalFileDiff(a_dir, line.path, b_dir, dst_path, is_move=False, num_add=line.num_add, num_delete=line.num_delete) |