Comment serialization cleanup part 7: Change diff comment format.

Review Request #13661 — Created March 21, 2024 and submitted — Latest diff uploaded

Information

Review Board
release-7.x

Reviewers

The diff comment serialization worked very differently from file
attachment and screenshot comment serialization. This change updates
that to match.

The structure used to be:

[
    {
        "linenum": X,
        "num_lines": Y,
        "comments": [
            ... comments ...
        ]
    },
    ...
]

Now it's:

{
    "X-Y": [
        ... comments ...
    ]
}

The object keys in the new format are used to group all comments on the
same block together, but are otherwise opaque. Instead, like we do for
file attachments, we'll pick the line and num_lines values out of
the first comment in the list.

It's arguable that the diff format was better than the one used for file
attachments, since the line number and number of lines for each block
really should be serialized separately from the individual comments.
Unfortunately, the file attachment format isn't easily changeable because
extensions that add Review UIs exist in the wild, and we need to
maintain compatibility there.

  • Loaded a diff with existing comments and saw that they all appeared
    correctly.
  • Ran python tests.
  • Ran js-tests.

Commits

Files