3914: Error displaying diff (only noticed with diffs generated from .sql files)

McK****@gmai***** (Google Code) (Is this you? Claim this profile.)
What version are you running?
Reviewboard 2.0.18

What's the URL of the page containing the problem?
https://[servername]/reviewboard/r/27/diff/1#index_header
https://[servername]/reviewboard/r/40/diff/1#2
(spans across multiple reviews and multiple files)

What steps will reproduce the problem?
1. Edit a .sql file in eclipse and use the eReviewboard plugin to commit a code review or generate a svn diff using command line tools
2. 50% of the time, the resulting review will display the following error when attempting to view the diff: "There was an error displaying this diff ..." 
3. If same diff is re-uploaded, sometimes there are no issues with showing the diff. 

What is the expected output? What do you see instead?
Expected: A visible diff view

Actual result: 
There was an error displaying this diff.
    The patch to '[path]/[filename].sql' didn't apply cleanly. The temporary files have been left in '/tmp/reviewboard.KBberp' for debugging purposes.
`patch` returned: 

     This may be a bug in the software, a temporary outage, or an issue
     with the format of your diff.

     Please try again, and if you still have trouble,
     contact support.

    Details
  
    Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/ReviewBoard-2.0.18-py2.6.egg/reviewboard/diffviewer/views.py", line 265, in get
    response = renderer.render_to_response(request)
  File "/usr/lib/python2.6/site-packages/ReviewBoard-2.0.18-py2.6.egg/reviewboard/diffviewer/renderers.py", line 56, in render_to_response
    return HttpResponse(self.render_to_string(request))
  File "/usr/lib/python2.6/site-packages/ReviewBoard-2.0.18-py2.6.egg/reviewboard/diffviewer/renderers.py", line 74, in render_to_string
    large_data=True)
  File "/usr/lib/python2.6/site-packages/Djblets-0.8.21-py2.6.egg/djblets/cache/backend.py", line 111, in cache_memoize
    data = lookup_callable()
  File "/usr/lib/python2.6/site-packages/ReviewBoard-2.0.18-py2.6.egg/reviewboard/diffviewer/renderers.py", line 73, in <lambda>
    lambda: self.render_to_string_uncached(request),
  File "/usr/lib/python2.6/site-packages/ReviewBoard-2.0.18-py2.6.egg/reviewboard/diffviewer/renderers.py", line 87, in render_to_string_uncached
    request=request)
  File "/usr/lib/python2.6/site-packages/ReviewBoard-2.0.18-py2.6.egg/reviewboard/diffviewer/diffutils.py", line 422, in populate_diff_chunks
    chunks = generator.get_chunks()
  File "/usr/lib/python2.6/site-packages/ReviewBoard-2.0.18-py2.6.egg/reviewboard/diffviewer/chunk_generator.py", line 156, in get_chunks
    large_data=True)
  File "/usr/lib/python2.6/site-packages/Djblets-0.8.21-py2.6.egg/djblets/cache/backend.py", line 111, in cache_memoize
    data = lookup_callable()
  File "/usr/lib/python2.6/site-packages/ReviewBoard-2.0.18-py2.6.egg/reviewboard/diffviewer/chunk_generator.py", line 155, in <lambda>
    lambda: list(self._get_chunks_uncached()),
  File "/usr/lib/python2.6/site-packages/ReviewBoard-2.0.18-py2.6.egg/reviewboard/diffviewer/chunk_generator.py", line 163, in _get_chunks_uncached
    new = get_patched_file(old, self.filediff, self.request)
  File "/usr/lib/python2.6/site-packages/ReviewBoard-2.0.18-py2.6.egg/reviewboard/diffviewer/diffutils.py", line 232, in get_patched_file
    return patch(diff, buffer, filediff.dest_file, request)
  File "/usr/lib/python2.6/site-packages/ReviewBoard-2.0.18-py2.6.egg/reviewboard/diffviewer/diffutils.py", line 168, in patch
    'output': stderr,
Exception: The patch to '[path]/[filename].sql' didn't apply cleanly. The temporary files have been left in '/tmp/reviewboard.KBberp' for debugging purposes.
`patch` returned: 

What operating system are you using? What browser?
Reviewboard is installed on Centos 6.6; users viewing the code review has Windows and are using Internet Explorer, Firefox, or Chrome (same error message for all 3 browser types). 

Please provide any additional information below.
This error seems to show up at random; there is no visible difference between the stored diffs for the ones that fail and the ones that succeed. I noticed comments about this sort of issue back in Reviewboard 1.6 (and the solution was that Reviewboard fixed it in a newer version), but we've had this issue since 2.0.15 and I upgraded reviewboard in an attempt to fix it (without any luck). It currently only seems to affect diff files that were generated from .sql files, and if the same diff is loaded up again, it is not always the same files that have issues being displayed.