What version are you running?
1.0.9
What steps will reproduce the problem?
1. Add, say, a carriage return character \r directly to a file under perforce
2. Post a review with this edited file in the perforce changelist
3. patch will have trouble understanding the diff, as it will have \n\n in the middle of the diff
Please provide any additional information below.
I got round this by adding the two lines below (after line 104 in diffutils.py)
diff = convert_line_endings(diff)
--> # filter any strings of \n characters >= 2 in the middle of the diff
--> diff = re.sub(r'\n{2,}(.)', r'\n\1', diff)
This was a temporary fix for me - it doesn't capture the additions to the file in this pathological case, but it stops the exception generated when patch returns a failure (and if there were other genuine differences in the file, these would appear normally in the diff view)
I also noticed that diffutils.py has the following lines of code at line 79
temp = data.replace('\r\r\n', '\n')
temp = data.replace('\r\n', '\n')
temp = temp.replace('\r', '\n')
Shouldn't the second line be ?
temp = temp.replace('\r\n', '\n')