Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix --diff failing on one-line hunks #137

Merged
merged 1 commit into from

2 participants

Gunnlaugur Thor Briem Florent Xicluna
Gunnlaugur Thor Briem

Without this fix, pep8 --diff fails uncleanly on diff hunks where either
the old or the new hunk is just one line and the patch omits the ,1

Compact fix for jcrocholl#127 — there is another pull request for it but that's a little verbose

Gunnlaugur Thor Briem gthb Fix --diff failing on one-line hunks
Without this fix, pep8 --diff fails uncleanly on diff hunks where either
the old or the new hunk is just one line and the patch omits the `,1`

Compact fix for jcrocholl#127
3a275ec
Florent Xicluna florentx merged commit 60b70eb into from
Florent Xicluna
Collaborator

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 8, 2012
  1. Gunnlaugur Thor Briem

    Fix --diff failing on one-line hunks

    gthb authored
    Without this fix, pep8 --diff fails uncleanly on diff hunks where either
    the old or the new hunk is just one line and the patch omits the `,1`
    
    Compact fix for jcrocholl#127
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +2 −2 pep8.py
4 pep8.py
View
@@ -152,7 +152,7 @@ def blank_lines(logical_line, blank_lines, indent_level, line_number)
r'|'.join(KEYWORDS))
OPERATOR_REGEX = re.compile(r'(?:[^\s])(\s*)(?:[-+*/|!<=>%&^]+)(\s*)')
LAMBDA_REGEX = re.compile(r'\blambda\b')
-HUNK_REGEX = re.compile(r'^@@ -\d+,\d+ \+(\d+),(\d+) @@.*$')
+HUNK_REGEX = re.compile(r'^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@.*$')
# Work around Python < 2.6 behaviour, which does not generate NL after
# a comment which is on a line by itself.
@@ -1117,7 +1117,7 @@ def parse_udiff(diff, patterns=None, parent='.'):
nrows -= 1
continue
if line[:3] == '@@ ':
- row, nrows = [int(g) for g in HUNK_REGEX.match(line).groups()]
+ row, nrows = [int(g or '1') 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]
Something went wrong with that request. Please try again.