reviewboard.diffviewer.processors¶
Diff processing and filtering logic.
Note
Functions in here are considered internal API for the diff processing logic. Signatures and behavior may change without a deprecation process.
- filter_interdiff_opcodes(*, opcodes: Iterable[tuple[str, int, int, int, int]], differ: Differ, filediff_orig_lines: Sequence[str], interfilediff_orig_lines: Sequence[str], request: HttpRequest | None = None) Iterator[tuple[str, int, int, int, int]][source]¶
Filter the opcodes for an interdiff to remove unnecessary lines.
An interdiff may contain lines of code that have changed as the result of updates to the tree between the time that the first and second diff were created. This leads to some annoyances when reviewing.
This function will filter the opcodes to remove as much of this as possible. It will only output non-“equal” opcodes if it falls into the ranges of lines dictated in the uploaded diff files.
Changed in version 8.0:
Support for the v1 and v2 interdiff filtering algorithms have been removed. This now uses the v3 algorithm for dual-phase splitting, range considerations, and consistent differs, which produces more reliable results.
Added
filediff_orig_lines,interfilediff_orig_lines, anddifferparameters, used for the v3 algorithm.Removed the old
filediff_dataandinterfilediff_dataparameters.
Changed in version 3.0.18: Added the
requestargument, and added support for the version 2 algorithm from Review Board 4.0 (through thefilter_interdiffs_v2_featurefeature).- Parameters:
differ (
reviewboard.diffviewer.differ.Differ, optional) –The differ used for the interdiff comparison.
This is used to retrieve opcodes for the patched versions of both ends of the interdiff.
New in version 8.0.
filediff_orig_lines (
listofstr, optional) –The lines of the original file before the filediff was applied.
New in version 8.0.
interfilediff_orig_lines (
listofstr, optional) –The lines of the original file before the interfilediff was applied.
New in version 8.0.
request (
django.http.HttpRequest, optional) – The HTTP request from the client.
- Yields:
tuple– An opcode to render for the diff.
- post_process_filtered_equals(opcodes)[source]¶
Post-processes filtered-equal and equal chunks from interdiffs.
Any filtered-out “filtered-equal” chunks will get turned back into “equal” chunks and merged into any prior equal chunks. Likewise, simple “equal” chunks will also get merged.
“equal” chunks that have any indentation information will remain their own chunks, with nothing merged in.