• 
      

    Allow empty parent diffs

    Review Request #10122 — Created Aug. 20, 2018 and submitted

    Information

    Review Board
    release-3.0.x
    397fea1...

    Reviewers

    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 of patch(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 will get_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 the FileDiff.

    • 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

    reviewbotreviewbot

    E501 line too long (90 > 79 characters)

    reviewbotreviewbot

    E501 line too long (83 > 79 characters)

    reviewbotreviewbot

    W391 blank line at end of file

    reviewbotreviewbot

    Can you move the parens to be around the string instead? Same effect, but keeps the string nicely grouped together.

    chipx86chipx86

    I think this would all be better as a method on FileDiff.

    chipx86chipx86

    No parens around these equality checks.

    chipx86chipx86

    Blank line between these.

    chipx86chipx86

    Missing a test docstring.

    chipx86chipx86

    Can you pass these as keyword arguments?

    chipx86chipx86

    Can you add a comment saying why we're doing this again?

    chipx86chipx86

    Here, too.

    chipx86chipx86

    W503 line break before binary operator

    reviewbotreviewbot

    Did you mean for the next clause to be outside of these parens, or should the parens go away?

    chipx86chipx86

    Given the previous issue, I think we need better test coverage for the various cases here.

    chipx86chipx86

    F821 undefined name 'parent_fiel'

    reviewbotreviewbot
    Checks run (1 failed, 1 succeeded)
    flake8 failed.
    JSHint passed.

    flake8

    brennie
    chipx86
    1. 
        
    2. reviewboard/diffviewer/diffutils.py (Diff revision 2)
       
       
       
      Show all issues

      Can you move the parens to be around the string instead? Same effect, but keeps the string nicely grouped together.

    3. reviewboard/diffviewer/diffutils.py (Diff revision 2)
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
      Show all issues

      I think this would all be better as a method on FileDiff.

    4. reviewboard/diffviewer/diffutils.py (Diff revision 2)
       
       
       
      Show all issues

      No parens around these equality checks.

    5. reviewboard/diffviewer/diffutils.py (Diff revision 2)
       
       
       
      Show all issues

      Blank line between these.

    6. Show all issues

      Missing a test docstring.

    7. Show all issues

      Can you pass these as keyword arguments?

    8. Show all issues

      Can you add a comment saying why we're doing this again?

    9. Show all issues

      Here, too.

      1. That is, keyword arguments.

    10. 
        
    brennie
    Review request changed
    Change Summary:

    Addressed issues.

    Commit:
    5d1dca176a720d93d7a2468ab26b476937774797
    d8f3828b243e890fd1e651a38dfa490f2f092347

    Checks run (1 failed, 1 succeeded)

    flake8 failed.
    JSHint passed.

    flake8

    brennie
    chipx86
    1. 
        
    2. reviewboard/diffviewer/diffutils.py (Diff revision 4)
       
       
      Show all issues

      Did you mean for the next clause to be outside of these parens, or should the parens go away?

    3. 
        
    brennie
    chipx86
    1. 
        
    2. reviewboard/diffviewer/diffutils.py (Diff revision 5)
       
       
       
      Show all issues

      Given the previous issue, I think we need better test coverage for the various cases here.

      1. If parent_moved is True then is_parent_diff_empty will also be True.

    3. 
        
    brennie
    Review request changed
    Change Summary:

    Addressed Christian's feedback.

    Commit:
    d2ed2e7e724e621196001231aa7c3c4ea09f6da4
    2082106b7f627bd42347005dd995f2aac70ae747

    Checks run (1 failed, 1 succeeded)

    flake8 failed.
    JSHint passed.

    flake8

    brennie
    chipx86
    1. Ship It!
    2. 
        
    brennie
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-3.0.x (503b9bf)