Add rendering of binary file attachments in the diff viewer.

Review Request #4468 — Created Aug. 20, 2013 and submitted

Information

Review Board
master

Reviewers

Add rendering of binary file attachments in the diff viewer.

This introduces the ability to associate a FileAttachment with a
path, revision and repository. The diff viewer can make use of this to
render thumbnails for binary files.

There's no way yet of associating a file outside of modifying the
database. Later, there will be API and UI for this.

This work is based on Tina Yang's work, with some fixes and a change in
the association model. Previously, FileAttachments were associated with
FileDiffs, but have been changed in order to reduce the number of
duplicate files that exist in the database.
Generated a diff that introduced an image and modified another image.

Initially, I saw the standard "This is a binary file," except with the
Download links and the text in both the left-hand and right-hand sides.

I then manually associated file attachments with these files. They didn't
show up in the list of file attachments for the page, but they did show up
in the diff viewer in the appropriate places.

Description From Last Updated

There's a lot more spacing between the second and third boxes than between the first and second.

daviddavid

I really don't understand what this means.

daviddavid

'DiffSet' imported but unused

reviewbotreviewbot

'DiffSetHistory' imported but unused

reviewbotreviewbot

thenew -> the new

daviddavid

'AnonymousUser' imported but unused

reviewbotreviewbot

'Template' imported but unused

reviewbotreviewbot

'Context' imported but unused

reviewbotreviewbot

'Review' imported but unused

reviewbotreviewbot

'Tool' imported but unused

reviewbotreviewbot

Col: 80 E501 line too long (100 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (101 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (105 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (106 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (96 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (97 > 79 characters)

reviewbotreviewbot

local variable 'file_attachment' is assigned to but never used

reviewbotreviewbot

Col: 80 E501 line too long (101 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (102 > 79 characters)

reviewbotreviewbot

This comment is obsolete now, right?

daviddavid

Col: 80 E501 line too long (100 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (101 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (105 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (106 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (96 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (97 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (101 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (102 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (100 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (101 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (105 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (106 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (96 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (97 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (101 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (102 > 79 characters)

reviewbotreviewbot
reviewbot
  1. This is a review from Review Bot.
      Tool: PEP8 Style Checker
      Processed Files:
        reviewboard/reviews/views.py
        reviewboard/attachments/managers.py
        reviewboard/attachments/models.py
        reviewboard/attachments/evolutions/file_attachment_repo_info.py
        reviewboard/attachments/admin.py
        reviewboard/scmtools/git.py
        reviewboard/attachments/tests.py
        reviewboard/attachments/templatetags/attachments.py
        reviewboard/attachments/evolutions/__init__.py
      Ignored Files:
        reviewboard/templates/diffviewer/diff_file_fragment.html
        reviewboard/static/rb/css/reviews.less
        reviewboard/static/rb/css/diffviewer.less
        reviewboard/static/rb/js/diffviewer/views/diffReviewableView.js
        reviewboard/static/rb/js/views/reviewRequestEditorView.js
        reviewboard/templates/reviews/reviewable_page_data.js
        reviewboard/static/rb/js/pages/views/diffViewerPageView.js
    
    
  2. reviewboard/attachments/tests.py (Diff revision 1)
     
     
    Show all issues
    Col: 80
     E501 line too long (100 > 79 characters)
    
  3. reviewboard/attachments/tests.py (Diff revision 1)
     
     
    Show all issues
    Col: 80
     E501 line too long (101 > 79 characters)
    
  4. reviewboard/attachments/tests.py (Diff revision 1)
     
     
    Show all issues
    Col: 80
     E501 line too long (105 > 79 characters)
    
  5. reviewboard/attachments/tests.py (Diff revision 1)
     
     
    Show all issues
    Col: 80
     E501 line too long (106 > 79 characters)
    
  6. reviewboard/attachments/tests.py (Diff revision 1)
     
     
    Show all issues
    Col: 80
     E501 line too long (96 > 79 characters)
    
  7. reviewboard/attachments/tests.py (Diff revision 1)
     
     
    Show all issues
    Col: 80
     E501 line too long (97 > 79 characters)
    
  8. reviewboard/attachments/tests.py (Diff revision 1)
     
     
    Show all issues
    Col: 80
     E501 line too long (101 > 79 characters)
    
  9. reviewboard/attachments/tests.py (Diff revision 1)
     
     
    Show all issues
    Col: 80
     E501 line too long (102 > 79 characters)
    
  10. 
      
reviewbot
  1. This is a review from Review Bot.
      Tool: Pyflakes
      Processed Files:
        reviewboard/reviews/views.py
        reviewboard/attachments/managers.py
        reviewboard/attachments/models.py
        reviewboard/attachments/evolutions/file_attachment_repo_info.py
        reviewboard/attachments/admin.py
        reviewboard/scmtools/git.py
        reviewboard/attachments/tests.py
        reviewboard/attachments/templatetags/attachments.py
        reviewboard/attachments/evolutions/__init__.py
      Ignored Files:
        reviewboard/templates/diffviewer/diff_file_fragment.html
        reviewboard/static/rb/css/reviews.less
        reviewboard/static/rb/css/diffviewer.less
        reviewboard/static/rb/js/diffviewer/views/diffReviewableView.js
        reviewboard/static/rb/js/views/reviewRequestEditorView.js
        reviewboard/templates/reviews/reviewable_page_data.js
        reviewboard/static/rb/js/pages/views/diffViewerPageView.js
    
    
  2. reviewboard/attachments/models.py (Diff revision 1)
     
     
    Show all issues
     'DiffSet' imported but unused
    
  3. reviewboard/attachments/models.py (Diff revision 1)
     
     
    Show all issues
     'DiffSetHistory' imported but unused
    
  4. reviewboard/attachments/tests.py (Diff revision 1)
     
     
    Show all issues
     'AnonymousUser' imported but unused
    
  5. reviewboard/attachments/tests.py (Diff revision 1)
     
     
    Show all issues
     'Template' imported but unused
    
  6. reviewboard/attachments/tests.py (Diff revision 1)
     
     
    Show all issues
     'Context' imported but unused
    
  7. reviewboard/attachments/tests.py (Diff revision 1)
     
     
    Show all issues
     'Review' imported but unused
    
  8. reviewboard/attachments/tests.py (Diff revision 1)
     
     
    Show all issues
     'Tool' imported but unused
    
  9. reviewboard/attachments/tests.py (Diff revision 1)
     
     
    Show all issues
     local variable 'file_attachment' is assigned to but never used
    
  10. 
      
david
  1. 
      
  2. Show all issues
    There's a lot more spacing between the second and third boxes than between the first and second.
    1. Yep, looks like, but that wasn't introduced in this change. I'll get to it separately.
  3. reviewboard/attachments/managers.py (Diff revision 1)
     
     
     
     
     
     
     
    Show all issues
    I really don't understand what this means.
    1. "... will be based on the new or modified file introduced in the diff. Otherwise, it will be based on the original file."
      
      Is that better? Or still bad?
    2. I don't understand what "based on" means.
    3. The details of the FileAttachment being constructed will be [based on/come from/I don't know what word is best] one of the two revisions that a FileDiff stores.
      
      Each side-by-side diff in the diff viewer is backed by a FileDiff, and has a left side and a right side. The FileAttachment being created can be based on either the original file (left side) or modified file (right side).
    4. How about something like this:
      
      FileAttachments created from a FileDiff are used to represent changes to binary files which would otherwise not be displayed with the diff. An individual FileAttachment can represent either the original or modified copy of the file. If 'from_modified' is True, then this FileAttachment will be created using the information (filename, revision, etc.) for the modified version. If it is False, this FileAttachment will be created using the information for the original version.
  4. Show all issues
    thenew -> the new
  5. reviewboard/scmtools/git.py (Diff revision 1)
     
     
     
     
    Show all issues
    This comment is obsolete now, right?
  6. 
      
chipx86
reviewbot
  1. This is a review from Review Bot.
      Tool: PEP8 Style Checker
      Processed Files:
        reviewboard/reviews/views.py
        reviewboard/attachments/managers.py
        reviewboard/attachments/models.py
        reviewboard/attachments/evolutions/file_attachment_repo_info.py
        reviewboard/attachments/admin.py
        reviewboard/scmtools/git.py
        reviewboard/attachments/tests.py
        reviewboard/attachments/templatetags/attachments.py
        reviewboard/attachments/evolutions/__init__.py
      Ignored Files:
        reviewboard/templates/diffviewer/diff_file_fragment.html
        reviewboard/static/rb/css/reviews.less
        reviewboard/static/rb/css/diffviewer.less
        reviewboard/static/rb/js/diffviewer/views/diffReviewableView.js
        reviewboard/static/rb/js/views/reviewRequestEditorView.js
        reviewboard/templates/reviews/reviewable_page_data.js
        reviewboard/static/rb/js/pages/views/diffViewerPageView.js
    
    
  2. reviewboard/attachments/tests.py (Diff revision 2)
     
     
    Show all issues
    Col: 80
     E501 line too long (100 > 79 characters)
    
  3. reviewboard/attachments/tests.py (Diff revision 2)
     
     
    Show all issues
    Col: 80
     E501 line too long (101 > 79 characters)
    
  4. reviewboard/attachments/tests.py (Diff revision 2)
     
     
    Show all issues
    Col: 80
     E501 line too long (105 > 79 characters)
    
  5. reviewboard/attachments/tests.py (Diff revision 2)
     
     
    Show all issues
    Col: 80
     E501 line too long (106 > 79 characters)
    
  6. reviewboard/attachments/tests.py (Diff revision 2)
     
     
    Show all issues
    Col: 80
     E501 line too long (96 > 79 characters)
    
  7. reviewboard/attachments/tests.py (Diff revision 2)
     
     
    Show all issues
    Col: 80
     E501 line too long (97 > 79 characters)
    
  8. reviewboard/attachments/tests.py (Diff revision 2)
     
     
    Show all issues
    Col: 80
     E501 line too long (101 > 79 characters)
    
  9. reviewboard/attachments/tests.py (Diff revision 2)
     
     
    Show all issues
    Col: 80
     E501 line too long (102 > 79 characters)
    
  10. 
      
reviewbot
  1. This is a review from Review Bot.
      Tool: Pyflakes
      Processed Files:
        reviewboard/reviews/views.py
        reviewboard/attachments/managers.py
        reviewboard/attachments/models.py
        reviewboard/attachments/evolutions/file_attachment_repo_info.py
        reviewboard/attachments/admin.py
        reviewboard/scmtools/git.py
        reviewboard/attachments/tests.py
        reviewboard/attachments/templatetags/attachments.py
        reviewboard/attachments/evolutions/__init__.py
      Ignored Files:
        reviewboard/templates/diffviewer/diff_file_fragment.html
        reviewboard/static/rb/css/reviews.less
        reviewboard/static/rb/css/diffviewer.less
        reviewboard/static/rb/js/diffviewer/views/diffReviewableView.js
        reviewboard/static/rb/js/views/reviewRequestEditorView.js
        reviewboard/templates/reviews/reviewable_page_data.js
        reviewboard/static/rb/js/pages/views/diffViewerPageView.js
    
    
  2. 
      
chipx86
reviewbot
  1. This is a review from Review Bot.
      Tool: PEP8 Style Checker
      Processed Files:
        reviewboard/reviews/views.py
        reviewboard/attachments/managers.py
        reviewboard/attachments/models.py
        reviewboard/attachments/evolutions/file_attachment_repo_info.py
        reviewboard/attachments/admin.py
        reviewboard/scmtools/git.py
        reviewboard/attachments/tests.py
        reviewboard/attachments/templatetags/attachments.py
        reviewboard/attachments/evolutions/__init__.py
      Ignored Files:
        reviewboard/templates/diffviewer/diff_file_fragment.html
        reviewboard/static/rb/css/reviews.less
        reviewboard/static/rb/css/diffviewer.less
        reviewboard/static/rb/js/diffviewer/views/diffReviewableView.js
        reviewboard/static/rb/js/views/reviewRequestEditorView.js
        reviewboard/templates/reviews/reviewable_page_data.js
        reviewboard/static/rb/js/pages/views/diffViewerPageView.js
    
    
  2. reviewboard/attachments/tests.py (Diff revision 3)
     
     
    Show all issues
    Col: 80
     E501 line too long (100 > 79 characters)
    
  3. reviewboard/attachments/tests.py (Diff revision 3)
     
     
    Show all issues
    Col: 80
     E501 line too long (101 > 79 characters)
    
  4. reviewboard/attachments/tests.py (Diff revision 3)
     
     
    Show all issues
    Col: 80
     E501 line too long (105 > 79 characters)
    
  5. reviewboard/attachments/tests.py (Diff revision 3)
     
     
    Show all issues
    Col: 80
     E501 line too long (106 > 79 characters)
    
  6. reviewboard/attachments/tests.py (Diff revision 3)
     
     
    Show all issues
    Col: 80
     E501 line too long (96 > 79 characters)
    
  7. reviewboard/attachments/tests.py (Diff revision 3)
     
     
    Show all issues
    Col: 80
     E501 line too long (97 > 79 characters)
    
  8. reviewboard/attachments/tests.py (Diff revision 3)
     
     
    Show all issues
    Col: 80
     E501 line too long (101 > 79 characters)
    
  9. reviewboard/attachments/tests.py (Diff revision 3)
     
     
    Show all issues
    Col: 80
     E501 line too long (102 > 79 characters)
    
  10. 
      
reviewbot
  1. This is a review from Review Bot.
      Tool: Pyflakes
      Processed Files:
        reviewboard/reviews/views.py
        reviewboard/attachments/managers.py
        reviewboard/attachments/models.py
        reviewboard/attachments/evolutions/file_attachment_repo_info.py
        reviewboard/attachments/admin.py
        reviewboard/scmtools/git.py
        reviewboard/attachments/tests.py
        reviewboard/attachments/templatetags/attachments.py
        reviewboard/attachments/evolutions/__init__.py
      Ignored Files:
        reviewboard/templates/diffviewer/diff_file_fragment.html
        reviewboard/static/rb/css/reviews.less
        reviewboard/static/rb/css/diffviewer.less
        reviewboard/static/rb/js/diffviewer/views/diffReviewableView.js
        reviewboard/static/rb/js/views/reviewRequestEditorView.js
        reviewboard/templates/reviews/reviewable_page_data.js
        reviewboard/static/rb/js/pages/views/diffViewerPageView.js
    
    
  2. 
      
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed