Fix comment links for file attachments in diffs.

Review Request #13681 — Created March 29, 2024 and submitted — Latest diff uploaded

Information

Review Board
release-7.x

Reviewers

This change fixes the links for file attachments which are attached to
binary files in a diff. The Review UI implementation was previously just
linking to the file attachment page, but that's a pretty crummy
experience when the comments were made on the diff.

This is pretty complex because there are a lot of corner cases. In
particular, we have to deal with three annoying things:

  1. We sometimes elide the base commit ID or tip commit ID from the URL,
    depending on what commits are selected.
  2. When a review request has commit history, the attachment is uploaded
    for the commit-specific filediff, and then we do some magic to find
    it when the user is viewing the cumulative diff. In this case, we
    have to do the opposite and figure out if the user had commented on
    the file while viewing the cumulative diff so we can link back to
    that rather than the commit range.
  3. When we do that backwards lookup for annoying thing #2, we need to
    make sure that we set the anchor to the correct filediff ID.

Unit tests have been added to cover all of these corner cases.

  • Created a review request with a ton of comments on binary files across
    various revision and commit ranges. Checked that clicking on the
    filename listed in the comments correctly opened the corresponding
    diff view.
  • Ran unit tests.

Commits

Files