Fix patching of files with a trailing "\r" when the diff expects no newline

Review Request #286 — Created March 2, 2008 and submitted — Latest diff uploaded

Information

Review Board SVN (deprecated)
trunk
386

Reviewers

Files without a newline come out of perforce with a trailing "\r". Diff indicates "No newline at end of file" when the last line contains only a \r at the end. However, our newline normalizer converted all \r's to \n's, which meant that patch saw a newline when it expected none. We now strip that last \n if the last character was previously a \r.
Added unit tests which reproduce this problem. Haven't tested in a production environment yet but it should work.

It remains to be seen if this breaks anything on Windows hosts. We can probably account for that if it does.
/trunk/reviewboard/diffviewer/diffutils.py
/trunk/reviewboard/diffviewer/tests.py
/trunk/reviewboard/diffviewer/testdata/diffs/context/README.nonewline.diff
/trunk/reviewboard/diffviewer/testdata/diffs/unified/README.nonewline.diff
/trunk/reviewboard/diffviewer/testdata/new_src/README.nonewline
/trunk/reviewboard/diffviewer/testdata/orig_src/README.nonewline
Loading...