Fix diff fragments with rebased interdiffs

Review Request #7188 — Created April 9, 2015 and submitted — Latest diff uploaded

Information

Review Board
release-2.5.x
bf64e65...

Reviewers

Previously diff fragments of a rebased interdiff would sometimes not be
renderable. This was due to there being blank lines in chunks because of
the upstream changes being filtered out. This broke some assumptions
about the existence of line numbers in equals chunks.

We are now more careful about our assumptions and check for the presence
of the line numbers themselves instead of checking the chunk's change
type. The diff fragments now render correctly. A test has been added to
ensure that this does not regress.

We also are more careful when determining headers that can be
expanded to for a fragment because when chunks get merged together by
the opcode generator, the headers may end up in the wrong chunk. A test
has been added to ensure that the correct headers are returned when this
occurs.

Diff header expansion now correctly compares the line numbers of each
header. Previously, the virtual element was being compared (instead of
line), which wasn't a key in either dict and so the comparsion was
being ignored silently. This results in left and right expansion headers
with different lines with the same code correctly being seperated.

I also noticed that the terms virtual line number and unified number
were being used to refer to the same thing, so all references to unified
line numbers have been changed to refer to virtual line numbers for
consistency's sake.

Ran unit tests.

Uploaded two diffs to my development server. The second diff was rebased
off a later change and then modified. I created an issue on a section
just after a half blank chunk in the interdiff. The fragment was not
rendered without the patch applied and rendered correctly with the patch
applied. The expansion links also worked correctly with the patch
applied.

The provided tests fail without this patch applied.