Show diffs for text file attachments.
Review Request #7123 — Created March 25, 2015 and submitted
When viewing diffs of text file attachments, they're now rendered as if they were actual diffs. We use the same diff chunk generation and rendering logic, and commenting abilities. This carries over to renderable text files as well. Rendered Markdown is diffed as well. We even show the changes within lines, though only text changes and not formatting. Comment thumbnails are shown based on the render state. The thumbnails show the diffed contents just like for actual diff comments. Some of the diff-specific JavaScript code is now made more general-purpose, and lives in TextCommentRowSelector. This is primarily the row finding code. There's also a convenience function around it for finding the beginning and end rows for a line range, needed for both the diff viewer and the text attachment review UI.
Tested viewing individual revisions and revision ranges for various text
files and for Markdown files (rendered and source).Tested commenting on lines within these, both single lines and spanning
multiple lines. I checked commenting on the first line and last lines of
the files, to test boundary issues.Tested that the thumbnails matched the right lines and the right view mode
for plain text and Markdown, on both the review dialog and the reviews.
Description | From | Last Updated |
---|---|---|
Seems to be missing a left border. |
david | |
Col: 80 E501 line too long (80 > 79 characters) |
reviewbot | |
This could be much more nicely written as: if f: return get_chunks_in_range(f['chunks'], first_line, num_lines) else: return [] |
david | |
In this case I think makes more sense than parens. |
david | |
This needs a var definition. |
david | |
This should be a // comment. Same for other one-line comments below. |
david | |
Can we use the context manager form here? |
david |
- Change Summary:
-
Fixed a line length issue.
- Commit:
-
6abd07f2d109f9354440fb57411b8849610256d94e9d0f84c57cc9069398eb5d9e12798356efaaf9
- Diff:
-
Revision 2 (+491 -272)
-
Tool: PEP8 Style Checker Processed Files: reviewboard/reviews/views.py reviewboard/diffviewer/templatetags/difftags.py reviewboard/reviews/chunk_generators.py reviewboard/reviews/ui/text.py reviewboard/reviews/ui/markdownui.py reviewboard/diffviewer/diffutils.py Ignored Files: reviewboard/static/rb/css/pages/text-review-ui.less reviewboard/templates/diffviewer/diff_file_fragment.html reviewboard/templates/reviews/ui/text_comment_thumbnail.html reviewboard/static/rb/js/diffviewer/views/diffReviewableView.js reviewboard/templates/reviews/ui/text.html reviewboard/templates/reviews/ui/_text_table.html reviewboard/static/rb/js/views/textBasedReviewableView.js reviewboard/static/rb/js/views/textCommentRowSelector.js Tool: Pyflakes Processed Files: reviewboard/reviews/views.py reviewboard/diffviewer/templatetags/difftags.py reviewboard/reviews/chunk_generators.py reviewboard/reviews/ui/text.py reviewboard/reviews/ui/markdownui.py reviewboard/diffviewer/diffutils.py Ignored Files: reviewboard/static/rb/css/pages/text-review-ui.less reviewboard/templates/diffviewer/diff_file_fragment.html reviewboard/templates/reviews/ui/text_comment_thumbnail.html reviewboard/static/rb/js/diffviewer/views/diffReviewableView.js reviewboard/templates/reviews/ui/text.html reviewboard/templates/reviews/ui/_text_table.html reviewboard/static/rb/js/views/textBasedReviewableView.js reviewboard/static/rb/js/views/textCommentRowSelector.js
- Change Summary:
-
- Fixed borders on text diffs.
- Cleaned up the logic around the chunk range iterator.
- Switch to a
\
for a line continuation. - Added a missing
var
. - Changed single-line comments in JavaScript code to use
//
.
- Commit:
-
4e9d0f84c57cc9069398eb5d9e12798356efaaf98d0f95cc0bcff7bb23ff445921e7f9cc1785a498
- Diff:
-
Revision 3 (+505 -275)
-
Tool: PEP8 Style Checker Processed Files: reviewboard/reviews/ui/markdownui.py reviewboard/reviews/chunk_generators.py reviewboard/reviews/ui/text.py reviewboard/diffviewer/templatetags/difftags.py reviewboard/diffviewer/diffutils.py Ignored Files: reviewboard/static/rb/css/pages/text-review-ui.less reviewboard/templates/diffviewer/diff_file_fragment.html reviewboard/templates/reviews/ui/text_comment_thumbnail.html reviewboard/static/rb/js/diffviewer/views/diffReviewableView.js reviewboard/templates/reviews/ui/text.html reviewboard/templates/reviews/ui/_text_table.html reviewboard/static/rb/js/views/textBasedReviewableView.js reviewboard/static/rb/js/views/textCommentRowSelector.js Tool: Pyflakes Processed Files: reviewboard/reviews/ui/markdownui.py reviewboard/reviews/chunk_generators.py reviewboard/reviews/ui/text.py reviewboard/diffviewer/templatetags/difftags.py reviewboard/diffviewer/diffutils.py Ignored Files: reviewboard/static/rb/css/pages/text-review-ui.less reviewboard/templates/diffviewer/diff_file_fragment.html reviewboard/templates/reviews/ui/text_comment_thumbnail.html reviewboard/static/rb/js/diffviewer/views/diffReviewableView.js reviewboard/templates/reviews/ui/text.html reviewboard/templates/reviews/ui/_text_table.html reviewboard/static/rb/js/views/textBasedReviewableView.js reviewboard/static/rb/js/views/textCommentRowSelector.js
- Change Summary:
-
- Switched to using a context manager for file closing. (Note that Django's File field doesn't do the open for you, so we still have to do that.)
- Changed the body of
get_file_chunks_in_range
to just return the nested generator.
- Commit:
-
8d0f95cc0bcff7bb23ff445921e7f9cc1785a4986cb37533165f29aa4c7afd97c577be36e2ae8424
- Diff:
-
Revision 4 (+507 -275)
-
Tool: Pyflakes Processed Files: reviewboard/reviews/ui/markdownui.py reviewboard/reviews/chunk_generators.py reviewboard/reviews/ui/text.py reviewboard/diffviewer/templatetags/difftags.py reviewboard/diffviewer/diffutils.py Ignored Files: reviewboard/static/rb/css/pages/text-review-ui.less reviewboard/templates/diffviewer/diff_file_fragment.html reviewboard/templates/reviews/ui/text_comment_thumbnail.html reviewboard/static/rb/js/diffviewer/views/diffReviewableView.js reviewboard/templates/reviews/ui/text.html reviewboard/templates/reviews/ui/_text_table.html reviewboard/static/rb/js/views/textBasedReviewableView.js reviewboard/static/rb/js/views/textCommentRowSelector.js Tool: PEP8 Style Checker Processed Files: reviewboard/reviews/ui/markdownui.py reviewboard/reviews/chunk_generators.py reviewboard/reviews/ui/text.py reviewboard/diffviewer/templatetags/difftags.py reviewboard/diffviewer/diffutils.py Ignored Files: reviewboard/static/rb/css/pages/text-review-ui.less reviewboard/templates/diffviewer/diff_file_fragment.html reviewboard/templates/reviews/ui/text_comment_thumbnail.html reviewboard/static/rb/js/diffviewer/views/diffReviewableView.js reviewboard/templates/reviews/ui/text.html reviewboard/templates/reviews/ui/_text_table.html reviewboard/static/rb/js/views/textBasedReviewableView.js reviewboard/static/rb/js/views/textCommentRowSelector.js