Add start index in base differ class and update MyersDiff accordingly.

Review Request #11253 — Created Oct. 29, 2020 and updated

bnie
Review Board
release-4.0.x
reviewboard

The current differ assumes the line index always starts at zero and the get_opcodes() function in MyersDiffer 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 updates MyersDiffer 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 sure MyersDiffer works when the code chunk is at the same location but not the start of the file.

Summary
Added two more parameter to indicate start index of a and b file, and modified
Description From Last Updated

The review request should be limited to 79 characters per line.

keanwengkeanweng

You might also want to add the Students group to the Reviewers.

keanwengkeanweng

E128 continuation line under-indented for visual indent

reviewbotreviewbot

E251 unexpected spaces around keyword / parameter equals

reviewbotreviewbot

E251 unexpected spaces around keyword / parameter equals

reviewbotreviewbot

E251 unexpected spaces around keyword / parameter equals

reviewbotreviewbot

E251 unexpected spaces around keyword / parameter equals

reviewbotreviewbot
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

bnie
Review request changed

Commits:

Summary
-
Added two more parameter to indicate start index of a and b file, and modified
+
Added two more parameter to indicate start index of a and b file, and modified

Diff:

Revision 2 (+140 -14)

Show changes

Checks run (2 succeeded)

flake8 passed.
JSHint passed.
keanweng
  1. 
      
  2. The review request should be limited to 79 characters per line.

  3. You might also want to add the Students group to the Reviewers.

  4. 
      
Loading...