Allow empty parent diffs
Review Request #10122 — Created Aug. 20, 2018 and submitted
If a review request was uploaded with a
FileDiff
that contained a
parent diff that creates a 0 byte file, we would previously be unable to
generate the pre-patch file due to a limitation ofpatch(1)
. To work
around this, when we encounter a specific error from patch (that is,
when it only finds what it considers garbage in the input), we check to
see if the parent diff is empty and if so we return an empty buffer.
Future calls willget_original_file
for that file will have no extra
database query overhead as the results of this (which costs at least two
queries) will be cached with theFileDiff
.
- Ran unit tests.
- Uploaded a commit that contained a
FileDiff
that created a 0 byte
file. With this patch applied, I was able to view the diff.
Description | From | Last Updated |
---|---|---|
E127 continuation line over-indented for visual indent |
reviewbot | |
E501 line too long (90 > 79 characters) |
reviewbot | |
E501 line too long (83 > 79 characters) |
reviewbot | |
W391 blank line at end of file |
reviewbot | |
Can you move the parens to be around the string instead? Same effect, but keeps the string nicely grouped together. |
chipx86 | |
I think this would all be better as a method on FileDiff. |
chipx86 | |
No parens around these equality checks. |
chipx86 | |
Blank line between these. |
chipx86 | |
Missing a test docstring. |
chipx86 | |
Can you pass these as keyword arguments? |
chipx86 | |
Can you add a comment saying why we're doing this again? |
chipx86 | |
Here, too. |
chipx86 | |
W503 line break before binary operator |
reviewbot | |
Did you mean for the next clause to be outside of these parens, or should the parens go away? |
chipx86 | |
Given the previous issue, I think we need better test coverage for the various cases here. |
chipx86 | |
F821 undefined name 'parent_fiel' |
reviewbot |
- Commit:
-
5f0986b32f9f5d0c959c36a953ae9a48ca3734a95d1dca176a720d93d7a2468ab26b476937774797
Checks run (2 succeeded)
- Change Summary:
-
Addressed issues.
- Commit:
-
5d1dca176a720d93d7a2468ab26b476937774797d8f3828b243e890fd1e651a38dfa490f2f092347
- Change Summary:
-
Flake8
- Commit:
-
d8f3828b243e890fd1e651a38dfa490f2f0923471de1cb8b86790e93d96705e70472a733bd4d20cc
Checks run (2 succeeded)
- Change Summary:
-
Addressed Christian's feedback.
- Commit:
-
1de1cb8b86790e93d96705e70472a733bd4d20ccd2ed2e7e724e621196001231aa7c3c4ea09f6da4
Checks run (2 succeeded)
- Change Summary:
-
Addressed Christian's feedback.
- Commit:
-
d2ed2e7e724e621196001231aa7c3c4ea09f6da42082106b7f627bd42347005dd995f2aac70ae747