4365: Diffs where symlinks are removed don't get applied cleanly

totte

What version are you running?

2.5.3

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

https://example.org/reviewboard/r/32/diff/1#index_header

What steps will reproduce the problem?

In an existing git repository...
1. $ touch README
2. $ ln -s README symlink_to_README
3. $ git add --all
4. $ git commit -m "Add README and a link to it"
5. $ git push
6. $ git rm symlink_to_README
7. $ git commit -m "Remove link to README"
8. $ rbt post -d -p
9. Go to the URL for the diff

What is the expected output? What do you see instead?

I'd expect the diff to apply cleanly. Instead this error is displayed for the change (notice that there is apparently no output for patch):

There was an error displaying this diff.

The patch to 'symlink_to_README' didn't apply cleanly. The temporary files have been left in '/tmp/reviewboard.wfmt3y' 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.

Traceback:

Traceback (most recent call last):
  File "/srv/www/reviewboard/local/lib/python2.7/site-packages/reviewboard/diffviewer/views.py", line 275, in get
    response = renderer.render_to_response(request)
  File "/srv/www/reviewboard/local/lib/python2.7/site-packages/reviewboard/diffviewer/renderers.py", line 56, in render_to_response
return HttpResponse(self.render_to_string(request))
  File "/srv/www/reviewboard/local/lib/python2.7/site-packages/reviewboard/diffviewer/renderers.py", line 74, in render_to_string
large_data=True)
  File "/srv/www/reviewboard/local/lib/python2.7/site-packages/djblets/cache/backend.py", line 295, in cache_memoize
compress_large_data))
  File "/srv/www/reviewboard/local/lib/python2.7/site-packages/djblets/cache/backend.py", line 249, in cache_memoize_iter
items = items_or_callable()
  File "/srv/www/reviewboard/local/lib/python2.7/site-packages/djblets/cache/backend.py", line 292, in <lambda>
lambda: [lookup_callable()],
  File "/srv/www/reviewboard/local/lib/python2.7/site-packages/reviewboard/diffviewer/renderers.py", line 73, in <lambda>
lambda: self.render_to_string_uncached(request),
  File "/srv/www/reviewboard/local/lib/python2.7/site-packages/reviewboard/diffviewer/renderers.py", line 87, in render_to_string_uncached
request=request)
  File "/srv/www/reviewboard/local/lib/python2.7/site-packages/reviewboard/diffviewer/diffutils.py", line 422, in populate_diff_chunks
chunks = list(generator.get_chunks())
  File "/srv/www/reviewboard/local/lib/python2.7/site-packages/reviewboard/diffviewer/chunk_generator.py", line 756, in get_chunks
for chunk in super(DiffChunkGenerator, self).get_chunks(cache_key):
  File "/srv/www/reviewboard/local/lib/python2.7/site-packages/reviewboard/diffviewer/chunk_generator.py", line 107, in get_chunks
large_data=True)
  File "/srv/www/reviewboard/local/lib/python2.7/site-packages/djblets/cache/backend.py", line 295, in cache_memoize
compress_large_data))
  File "/srv/www/reviewboard/local/lib/python2.7/site-packages/djblets/cache/backend.py", line 249, in cache_memoize_iter
items = items_or_callable()
  File "/srv/www/reviewboard/local/lib/python2.7/site-packages/djblets/cache/backend.py", line 292, in <lambda>
lambda: [lookup_callable()],
  File "/srv/www/reviewboard/local/lib/python2.7/site-packages/reviewboard/diffviewer/chunk_generator.py", line 106, in <lambda>
lambda: list(self.get_chunks_uncached()),
  File "/srv/www/reviewboard/local/lib/python2.7/site-packages/reviewboard/diffviewer/chunk_generator.py", line 763, in get_chunks_uncached
new = get_patched_file(old, self.filediff, self.request)
  File "/srv/www/reviewboard/local/lib/python2.7/site-packages/reviewboard/diffviewer/diffutils.py", line 232, in get_patched_file
return patch(diff, buffer, filediff.dest_file, request)
  File "/srv/www/reviewboard/local/lib/python2.7/site-packages/reviewboard/diffviewer/diffutils.py", line 168, in patch
'output': stderr,
Exception: The patch to 'symlink_to_README' didn't apply cleanly. The temporary files have been left in '/tmp/reviewboard.wfmt3y' for debugging purposes.
`patch` returned:

What operating system are you using? What browser?

Debian 8 "Jessie" with Iceweasel 38.7.0esr-1~deb8u1.

Please provide any additional information below.

patch 2.7.5-1 is installed on the server.

ejohansson
#1 ejohansson

I ran into this problem as well and posted a propsed patch to the mailing list:
https://groups.google.com/d/msg/reviewboard/WDE37CHeS_0/tpeJnYTeBAAJ

If that seems like the way to go I can post it for review.

ejohansson
#2 ejohansson

Fixed in 3.0: https://reviews.reviewboard.org/r/8785/

david
#3 david
  • -New
    +Fixed