Split DiffChunkGenerator into a general-purpose RawDiffChunkGenerator.
Review Request #7093 — Created March 19, 2015 and submitted
DiffChunkGenerator
is a very useful and powerful class for producing a
set of chunks we can directly use for rendering diffs. To use it, it
required the whole diff machinery:FileDiff
models,DiffSet
,
repositories, the patching process, etc. That made it impractical for
any usage beyond showing diffs of files in a repository.This change splits the heavy processing out into a
RawDiffChunkGenerator
class, which can be used to generate chunks from any two strings.
DiffChunkGenerator
subclassesRawDiffChunkGenerator
, doing all the work
of handling interdiffs and generating suitable content fromFileDiffs
to
pass down to theRawDiffChunkGenerator
functions.Along with this,
DiffOpcodeGenerator
no longer needsFileDiff
s as well.
It only ever needed the diff content stored on them, for interdiff
processing, so we just pass that directly inDiffChunkGenerator
.
Browsed diffs and interdiffs, comparing them to versions without the path.
This covered all types of changes, including indentation. I didn't see any
differences in behavior.Tested with raw strings, and got chunks out of them.
Unit tests pass.
Description | From | Last Updated |
---|---|---|
Col: 1 E303 too many blank lines (3) |
reviewbot | |
'os' imported but unused |
reviewbot | |
"Generate" |
brennie | |
I know this isn't in the change, but aren't there also "replace" chunks? |
brennie | |
You should use encoding_list=None and assign encoding_list to [] if it is None in the function. |
brennie | |
"Generate" |
brennie | |
Again, replace sections? |
brennie | |
"Create" |
brennie | |
Should be "Return". |
brennie | |
Line needs b'' |
brennie | |
Blank line between these. |
brennie |
- Change Summary:
-
Fixed ReviewBot complaints.
- Commit:
-
22d54eb4bab793b8871a4a74b8c3617bdb614ea2b3996d6ecdbcb3f929ce584b21dba22c2514f5ca
-
Tool: Pyflakes Processed Files: reviewboard/diffviewer/opcode_generator.py reviewboard/diffviewer/tests.py reviewboard/diffviewer/chunk_generator.py reviewboard/diffviewer/diffutils.py Tool: PEP8 Style Checker Processed Files: reviewboard/diffviewer/opcode_generator.py reviewboard/diffviewer/tests.py reviewboard/diffviewer/chunk_generator.py reviewboard/diffviewer/diffutils.py
- Change Summary:
-
- Changed some docstrings.
- Fixed some defaults.
- Added some missing blank lines.
- Commit:
-
b3996d6ecdbcb3f929ce584b21dba22c2514f5ca3b0ad74ab108c5e8ca5319c720942287820cb5a7
-
Tool: Pyflakes Processed Files: reviewboard/diffviewer/opcode_generator.py reviewboard/diffviewer/tests.py reviewboard/diffviewer/chunk_generator.py reviewboard/diffviewer/diffutils.py Tool: PEP8 Style Checker Processed Files: reviewboard/diffviewer/opcode_generator.py reviewboard/diffviewer/tests.py reviewboard/diffviewer/chunk_generator.py reviewboard/diffviewer/diffutils.py