Jump to >


Diff processing and filtering logic.

CHUNK_RANGE_RE = re.compile(b'^@@ -(?P<orig_start>\\d+)(,(?P<orig_len>\\d+))? \\+(?P<new_start>\\d+)(,(?P<new_len>\\d+))? @@', re.MULTILINE)[source]

Regex for matching a diff chunk line.

Deprecated since version 3.0.18: This has been replaced with reviewboard.diffviewer.diffutils.CHUNK_RANGE_RE. Its group names differ from this version.

filter_interdiff_opcodes(opcodes, filediff_data, interfilediff_data, request=None)[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 3.0.18: Added the request argument, and added support for the version 2 algorithm from Review Board 4.0 (through the filter_interdiffs_v2_feature feature).

  • opcodes (list of tuple) – The list of opcodes to filter.

  • filediff_data (bytes) – The data from the filediff to filter.

  • interfilediff_data (bytes) – The data from the interfilediff to filter.

  • request (django.http.HttpRequest, optional) – The HTTP request from the client.


tuple – An opcode to render for the diff.


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.