Comment serialization cleanup part 7: Change diff comment format.
Review Request #13661 — Created March 21, 2024 and submitted
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 theline
andnum_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.
Summary | ID |
---|---|
7929db2ad40d313998b201468cfb0748f4c4a370 |
Description | From | Last Updated |
---|---|---|
undefined name 'DiffSet' Column: 14 Error code: F821 |
reviewbot | |
dictionary key 'index' repeated with different values Column: 17 Error code: F601 |
reviewbot | |
These don't support generics on Python 3.8. |
chipx86 | |
Version Added? |
chipx86 | |
This should use :file:. |
chipx86 | |
Version Added? |
chipx86 | |
These should be documented. |
chipx86 | |
This needs to be the full module path. |
chipx86 | |
These are missing docs. |
chipx86 | |
This isn't specific to this change, but while I'm here... I think the parent class should take generics for the … |
chipx86 | |
Looks like we're missing typing for this (unless it's in a base class?) |
chipx86 | |
Is this covered by the previous typing changes? |
chipx86 | |
Can we work toward keyword-only arguments for these constructors? |
chipx86 | |
Should DiffReviewUI just take these as keyword arguments? |
chipx86 | |
Should be :file:. |
chipx86 | |
Should probably be import type. |
chipx86 | |
Missing docs. |
chipx86 | |
Missing docs. |
chipx86 | |
Do we not get these types from the serialized data? |
chipx86 |
- Commits:
-
Summary ID 1e636e0b9bb8903c7ac41447a8aa5a19df5bf49e 4e9969b11926532077f99eea528468d226749ab0 - Diff:
-
Revision 2 (+656 -488)
Checks run (2 succeeded)
- Commits:
-
Summary ID 4e9969b11926532077f99eea528468d226749ab0 b3bbd465cadefabdebe8889e52e8e78af1a5c736 - Diff:
-
Revision 3 (+650 -488)
Checks run (2 succeeded)
- Commits:
-
Summary ID b3bbd465cadefabdebe8889e52e8e78af1a5c736 65f2b3ec80596e9f37b07af04491900a072e75c9 - Diff:
-
Revision 4 (+648 -488)
Checks run (2 succeeded)
- Commits:
-
Summary ID 65f2b3ec80596e9f37b07af04491900a072e75c9 eccf16d6ba6db3cd1f762f452036d8981c1a0dc0 - Diff:
-
Revision 5 (+656 -514)
Checks run (2 succeeded)
-
-
-
-
-
-
-
This isn't specific to this change, but while I'm here...
I think the parent class should take generics for the comment type and serialized comment type. That way there's no need to cast everywhere, and callers can always get the right typing when requesting comment types, when accepting a type of the base class.
-
-
-
-
-
-
-
-
- Commits:
-
Summary ID eccf16d6ba6db3cd1f762f452036d8981c1a0dc0 a77a665aee03ebd376e3ca28e2af2f32b627c82f - Diff:
-
Revision 6 (+716 -516)
Checks run (2 succeeded)
- Commits:
-
Summary ID a77a665aee03ebd376e3ca28e2af2f32b627c82f 05f855636d5d2e8ed5a24eb75487ce33bc5cd474 - Diff:
-
Revision 7 (+728 -518)
Checks run (2 succeeded)
- Commits:
-
Summary ID 05f855636d5d2e8ed5a24eb75487ce33bc5cd474 7929db2ad40d313998b201468cfb0748f4c4a370 - Diff:
-
Revision 8 (+734 -518)