diff options
author | Florent Xicluna <florent.xicluna@gmail.com> | 2012-06-13 18:07:43 +0200 |
---|---|---|
committer | Florent Xicluna <florent.xicluna@gmail.com> | 2012-06-13 18:07:43 +0200 |
commit | 0811d09b12650e39735d44f56c0387df897a7a5b (patch) | |
tree | 19dae6462462a7dc84a266c3abce093018f08857 | |
parent | 2950476dc648206597a3bc98a890985e3d31c1c3 (diff) | |
download | pep8-0811d09b12650e39735d44f56c0387df897a7a5b.tar.gz |
Show also the errors in the diff context. Pass the option '--unified 0' to the diff or VCS program to keep the previous behaviour.
-rwxr-xr-x | pep8.py | 19 |
1 files changed, 8 insertions, 11 deletions
@@ -1158,23 +1158,20 @@ def mute_string(text): def parse_udiff(diff, patterns=None, parent='.'): rv = {} - lastrow = path = None + path = nrows = None for line in diff.splitlines(): - if lastrow: - if line[:1] == '+': - rv[path].add(row) - if row == lastrow: - lastrow = None - elif line[:1] != '-': - row += 1 + if nrows: + if line[:1] != '-': + nrows -= 1 + continue + if line[:3] == '@@ ': + row, nrows = [int(g) for g in HUNK_REGEX.match(line).groups()] + rv[path].update(range(row, row + nrows)) elif line[:3] == '+++': path = line[4:].split('\t', 1)[0] if path[:2] == 'b/': path = path[2:] rv[path] = set() - elif line[:3] == '@@ ': - row, nrows = [int(g) for g in HUNK_REGEX.match(line).groups()] - lastrow = nrows and (row + nrows - 1) or None return dict([(os.path.join(parent, path), rows) for (path, rows) in rv.items() if rows and filename_match(path, patterns)]) |