• 
      

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

    Review Request #11253 — Created Oct. 28, 2020 and updated — Latest diff uploaded

    Information

    Review Board
    release-4.0.x

    Reviewers

    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.

    Commits

    Files