1340: Patch fails to generate diff on server when the source file does not end with newline char

lucray.*******@gmai***** (Google Code) (Is this you? Claim this profile.)
Oct. 5, 2009
What version are you running?
1.0.3 with RBTools 0.2 beta2

What's the URL of the page containing the problem?


What steps will reproduce the problem?
1. Create a file which ends with e.g. '}' instead of an empty line
2. Create the review with post-review (we use perforce)
3.

What is the expected output? What do you see instead?
The diff contains something similar to this:

}--- //depot/
+++ //depot/

Patch misses the new file and puts the whole line inside the previous diff.
Adding a newline char before the diff file like this does not solve the
issue completely since the newline char is not in the depot file.

}
--- //depot/
+++ //depot/


What operating system are you using? What browser?


Please provide any additional information below.
Here is the call stack:

Diff currently unavailable.
Error: The patch to '//depot/*' didn't apply cleanly. The temporary files
have been left in '/tmp/reviewboard.Svq_sy' for debugging purposes. `patch`
returned: patching file /tmp/reviewboard.Svq_sy/tmpgqqll5 Hunk #3 FAILED at
32. 1 out of 3 hunks FAILED -- saving rejects to file
/tmp/reviewboard.Svq_sy/tmpgqqll5-new.rej
Details

Traceback (most recent call last):
  File
"/usr/lib/python2.5/site-packages/ReviewBoard-1.0.3.1-py2.5.egg/reviewboard/diffviewer/views.py",
line 213, in view_diff_fragment
    file = get_requested_diff_file()
  File
"/usr/lib/python2.5/site-packages/ReviewBoard-1.0.3.1-py2.5.egg/reviewboard/diffviewer/views.py",
line 189, in get_requested_diff_file
    get_chunks)
  File
"/usr/lib/python2.5/site-packages/ReviewBoard-1.0.3.1-py2.5.egg/reviewboard/diffviewer/diffutils.py",
line 623, in get_diff_files
    large_data=True)
  File
"/usr/lib/python2.5/site-packages/Djblets-0.5.3-py2.5.egg/djblets/util/misc.py",
line 162, in cache_memoize
    data = lookup_callable()
  File
"/usr/lib/python2.5/site-packages/ReviewBoard-1.0.3.1-py2.5.egg/reviewboard/diffviewer/diffutils.py",
line 622, in <lambda>
    enable_syntax_highlighting),
  File
"/usr/lib/python2.5/site-packages/ReviewBoard-1.0.3.1-py2.5.egg/reviewboard/diffviewer/diffutils.py",
line 345, in get_chunks
    new = get_patched_file(old, filediff)
  File
"/usr/lib/python2.5/site-packages/ReviewBoard-1.0.3.1-py2.5.egg/reviewboard/diffviewer/diffutils.py",
line 261, in get_patched_file
    return patch(filediff.diff, buffer, filediff.dest_file)
  File
"/usr/lib/python2.5/site-packages/ReviewBoard-1.0.3.1-py2.5.egg/reviewboard/diffviewer/diffutils.py",
line 129, in patch
    (filename, tempdir, patch_output))
Exception: The patch to '//depot/*' didn't apply cleanly. The temporary
files have been left in '/tmp/reviewboard.Svq_sy' for debugging purposes.
`patch` returned: patching file /tmp/reviewboard.Svq_sy/tmpgqqll5
Hunk #3 FAILED at 32.
1 out of 3 hunks FAILED -- saving rejects to file
/tmp/reviewboard.Svq_sy/tmpgqqll5-new.rej
david
#1 david
Fixed in rbtools 3b21dce. Thanks!
  • +Fixed
#2 lucray.*******@gmai***** (Google Code) (Is this you? Claim this profile.)
Hi,

I had attempted the same fix in the postreview script before submitting the issue.
But I noticed that patch seems to work correctly in most cases but not all. I think
this is due to the fact that patch thinks the added newline is part of the file in
the repository... but that's not the case.

Kind regards,

Luc