Add start index in base differ class and update MyersDiff accordingly.
Review Request #11253 — Created Oct. 28, 2020 and updated
The current differ assumes the line index always starts at zero and the
get_opcodes()
function inMyersDiffer
calculates the line number base
on this assumption.However, one future differ option,
PatienceDiffer
, which uses
MyersDiffer
to 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_index
and
b_start_index
in the base differ class and updatesMyersDiffer
to
generate correct opcode after the new change.
Four new test cases are added to make sure
MyersDiffer
works, 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 sureMyersDiffer
works when the code
chunk is at the same location but not the start of the file.
Summary | ID |
---|---|
39038ac9d7385bbaf916b4cd11f68ad00dd8268f | |
678fb08f92a145a7f6baf65b7edbdc53d10bc784 |
Description | From | Last Updated |
---|---|---|
The review request should be limited to 79 characters per line. |
keanweng | |
You might also want to add the Students group to the Reviewers. |
keanweng | |
I'm not too familiar with the MyersDiff so I can't really comment on the code. However, I downloaded the patch … |
keanweng | |
E128 continuation line under-indented for visual indent |
reviewbot | |
E251 unexpected spaces around keyword / parameter equals |
reviewbot | |
E251 unexpected spaces around keyword / parameter equals |
reviewbot | |
E251 unexpected spaces around keyword / parameter equals |
reviewbot | |
E251 unexpected spaces around keyword / parameter equals |
reviewbot | |
For readability, let's use keyword arguments and begin the arguments on the next line (4 spaces indented). Same below. |
chipx86 | |
Can you add ad ocstring here? I know the other function doesn't have it, but it predates our modern doc … |
chipx86 |
- Commits:
-
Summary ID 424109a22d204b6c579dc178a9bffc1ab1610a08 3995352b38e41105fce1d514d7088a649b1e0a37
Checks run (2 succeeded)
- Description:
-
~ The current differ assumes the line index always starts at zero and the
get_opcodes()
function inMyersDiffer
calculates the line number base on this assumption.~ The current differ assumes the line index always starts at zero and the
+ get_opcodes()
function inMyersDiffer
calculates the line number base+ on this assumption. ~ However, one future differ option,
PatienceDiffer
, which usesMyersDiffer
to 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.~ However, one future differ option,
PatienceDiffer
, which uses+ MyersDiffer
to 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_index
andb_start_index
in the base differ class and updatesMyersDiffer
to generate correct opcode after the new change.~ This commit adds such two new parameters,
a_start_index
and+ b_start_index
in the base differ class and updatesMyersDiffer
to+ generate correct opcode after the new change. - Testing Done:
-
~ Four new test cases are added to make sure
MyersDiffer
works, 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 sureMyersDiffer
works when the code chunk is at the same location but not the start of the file.~ Four new test cases are added to make sure
MyersDiffer
works, 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 sure MyersDiffer
works when the code+ chunk is at the same location but not the start of the file. - Groups:
-
This looks great. Small stylistic stuff, and then let's land this! :)
-
For readability, let's use keyword arguments and begin the arguments on the next line (4 spaces indented).
Same below.
-
Can you add ad ocstring here? I know the other function doesn't have it, but it predates our modern doc standards.
- Change Summary:
-
Added doc string to test function and used keyword argument in all test cases.
- Commits:
-
Summary ID 3995352b38e41105fce1d514d7088a649b1e0a37 39038ac9d7385bbaf916b4cd11f68ad00dd8268f 678fb08f92a145a7f6baf65b7edbdc53d10bc784