Add start index in base differ class and update MyersDiff accordingly.
Review Request #11253 — Created Oct. 28, 2020 and updated — Latest diff uploaded
The current differ assumes the line index always starts at zero and the
get_opcodes()function inMyersDiffercalculates the line number base
on this assumption.However, one future differ option,
PatienceDiffer, which uses
MyersDifferto obtain the final diff, passes in portions of the overall
file seperately and the start index will not be line 0 for code chunks
that do not start at the head of the file. As a result, some index
varables needs to be set in the differ to keep track of which line
each code block starts at.This commit adds such two new parameters,
a_start_indexand
b_start_indexin the base differ class and updatesMyersDifferto
generate correct opcode after the new change.
Four new test cases are added to make sure
MyersDifferworks, given
different start indices for file a and b, for all the opertaions: equal,
replace, insert and delete. Also, another test case with same non-zero
start indices is added to make sureMyersDifferworks when the code
chunk is at the same location but not the start of the file.
