Fix diff attachment and default reviewers for post-commit review.

Review Request #8539 — Created Nov. 15, 2016 and submitted

Information

Review Board
release-2.5.x
b4dccff...

Reviewers

We had a very, very old bug with post-commit review where the diffs from
the posted commit would be attached to the Review Request's diffset
history, rather than the draft. This made the diff accessible to
superusers who had access to the review request, which wasn't a big
deal, but more importantly it meant the diff wasn't accessible via the
draft API and default reviewers would not apply.

This change fixes this by redoing some of that logic. Formerly, the code
for updating was assuming it would be called on either the draft or
review request, but in practice now it's only ever called on the draft,
so that has moved into ReviewRequestDraft and has been updated to
associate there instead of the review request history.

That also required some new code that figured out a suitable revision
for the diffset. Since that's already been done in two other places, the
logic has been centralized (and optimized to reduce the data returned
from an SQL query).

Some unit tests were added and others moved around to test against the
draft instead of review request.

Unit tests pass.

Tested post-commit review with default reviewers. It worked.

Description From Last Updated

'DiffSet' imported but unused

reviewbotreviewbot

'InvalidChangeNumberError' imported but unused

reviewbotreviewbot

undefined name 'InvalidChangeNumberError'

reviewbotreviewbot

undefined name 'InvalidChangeNumberError'

reviewbotreviewbot

Move this into the try block?

daviddavid
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/reviews/tests/test_review_request_manager.py
        reviewboard/scmtools/models.py
        reviewboard/reviews/tests/test_review_request_draft.py
        reviewboard/diffviewer/models.py
        reviewboard/reviews/tests/test_review_request.py
        reviewboard/reviews/models/review_request_draft.py
        reviewboard/diffviewer/tests.py
        reviewboard/reviews/forms.py
        reviewboard/reviews/managers.py
        reviewboard/reviews/models/base_review_request_details.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/reviews/tests/test_review_request_manager.py
        reviewboard/scmtools/models.py
        reviewboard/reviews/tests/test_review_request_draft.py
        reviewboard/diffviewer/models.py
        reviewboard/reviews/tests/test_review_request.py
        reviewboard/reviews/models/review_request_draft.py
        reviewboard/diffviewer/tests.py
        reviewboard/reviews/forms.py
        reviewboard/reviews/managers.py
        reviewboard/reviews/models/base_review_request_details.py
    
    
  2. Show all issues
     'DiffSet' imported but unused
    
  3. Show all issues
     'InvalidChangeNumberError' imported but unused
    
  4. Show all issues
     undefined name 'InvalidChangeNumberError'
    
  5. Show all issues
     undefined name 'InvalidChangeNumberError'
    
  6. 
      
chipx86
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/reviews/tests/test_review_request_manager.py
        reviewboard/scmtools/models.py
        reviewboard/reviews/tests/test_review_request_draft.py
        reviewboard/diffviewer/models.py
        reviewboard/reviews/tests/test_review_request.py
        reviewboard/reviews/models/review_request_draft.py
        reviewboard/diffviewer/tests.py
        reviewboard/reviews/forms.py
        reviewboard/reviews/managers.py
        reviewboard/reviews/models/base_review_request_details.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/reviews/tests/test_review_request_manager.py
        reviewboard/scmtools/models.py
        reviewboard/reviews/tests/test_review_request_draft.py
        reviewboard/diffviewer/models.py
        reviewboard/reviews/tests/test_review_request.py
        reviewboard/reviews/models/review_request_draft.py
        reviewboard/diffviewer/tests.py
        reviewboard/reviews/forms.py
        reviewboard/reviews/managers.py
        reviewboard/reviews/models/base_review_request_details.py
    
    
  2. 
      
david
  1. 
      
  2. reviewboard/diffviewer/models.py (Diff revision 2)
     
     
    Show all issues

    Move this into the try block?

    1. No need. It's not querying anything at that point. It's just an attribute access for the relation. The except wouldn't even cover it.

    2. I understand that, but the variable assignment only exists to make the line that is within the try fit in our text width. Given that, I think we should keep it together with where it's used.

    3. Turns out it fits fine at this indentation level, so I'm just merging the statements. This was nested further in the original code.

  3. 
      
chipx86
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/reviews/tests/test_review_request_manager.py
        reviewboard/scmtools/models.py
        reviewboard/reviews/tests/test_review_request_draft.py
        reviewboard/diffviewer/models.py
        reviewboard/reviews/tests/test_review_request.py
        reviewboard/reviews/models/review_request_draft.py
        reviewboard/diffviewer/tests.py
        reviewboard/reviews/forms.py
        reviewboard/reviews/managers.py
        reviewboard/reviews/models/base_review_request_details.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/reviews/tests/test_review_request_manager.py
        reviewboard/scmtools/models.py
        reviewboard/reviews/tests/test_review_request_draft.py
        reviewboard/diffviewer/models.py
        reviewboard/reviews/tests/test_review_request.py
        reviewboard/reviews/models/review_request_draft.py
        reviewboard/diffviewer/tests.py
        reviewboard/reviews/forms.py
        reviewboard/reviews/managers.py
        reviewboard/reviews/models/base_review_request_details.py
    
    
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-2.5.x (3fa69a0)