Prevent publishing of drafts with same commits

Review Request #7011 — Created March 5, 2015 and submitted

Information

Review Board
dvcs
5b8c863...

Reviewers

Before support for commit histories was added, it was sufficient to
check if a change description had any modified fields to determine if
an actual change was present. However, the DiffField is marked as
changed if there is a new diff available. In the case of a squashed
review request, this is sufficient because the API will not allow you
to upload an identical diff. However, with multiple commit review
requests, where each commit is uploaded individually, it becomes more
difficult because we do not know the number of commits before
publishing is attempted.

To address this issue, we now determine if only the DiffField has
been marked as changed and current DiffSet has diff commits. In this
case, we know that the DiffCommits haven't changed and therefore the
publish should not be allowed.

Added a unit test to capture this behaviour.

We now also use fewer database queries in the case where the history
was previously squashed and no longer is.

Ran units tests.

Created a review request with commit history. Upadated the review
request with the same set of commits and tried to publish the review
request draft, but was not able to.

The provided unit test fails without the patch and passes with it.

Description From Last Updated

local variable 'diff_commit' is assigned to but never used

reviewbotreviewbot

Col: 47 E127 continuation line over-indented for visual indent

reviewbotreviewbot
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/reviews/builtin_fields.py
        reviewboard/reviews/models/review_request_draft.py
    
    
    
    Tool: Pyflakes
    Processed Files:
        reviewboard/reviews/builtin_fields.py
        reviewboard/reviews/models/review_request_draft.py
    
    
  2. 
      
brennie
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/reviews/builtin_fields.py
        reviewboard/reviews/models/review_request_draft.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/reviews/builtin_fields.py
        reviewboard/reviews/models/review_request_draft.py
    
    
  2. 
      
brennie
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/reviews/builtin_fields.py
        reviewboard/reviews/models/review_request_draft.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/reviews/builtin_fields.py
        reviewboard/reviews/models/review_request_draft.py
    
    
  2. 
      
brennie
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/reviews/builtin_fields.py
        reviewboard/reviews/tests.py
        reviewboard/reviews/models/review_request_draft.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/reviews/builtin_fields.py
        reviewboard/reviews/tests.py
        reviewboard/reviews/models/review_request_draft.py
    
    
  2. reviewboard/reviews/tests.py (Diff revision 4)
     
     
    Show all issues
     local variable 'diff_commit' is assigned to but never used
    
  3. 
      
brennie
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/reviews/builtin_fields.py
        reviewboard/reviews/tests.py
        reviewboard/reviews/models/review_request_draft.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/reviews/builtin_fields.py
        reviewboard/reviews/tests.py
        reviewboard/reviews/models/review_request_draft.py
    
    
  2. reviewboard/reviews/tests.py (Diff revision 5)
     
     
    Show all issues
    Col: 47
     E127 continuation line over-indented for visual indent
    
  3. 
      
brennie
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/reviews/builtin_fields.py
        reviewboard/reviews/tests.py
        reviewboard/reviews/models/review_request_draft.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/reviews/builtin_fields.py
        reviewboard/reviews/tests.py
        reviewboard/reviews/models/review_request_draft.py
    
    
  2. 
      
brennie
david
  1. Ship It!
  2. 
      
david
  1. Oh, one little nit in your description:

    "We now also use less database queries" -> should be "fewer database queries"

  2. 
      
brennie
brennie
Review request changed
Status:
Completed
Change Summary:
Pushed to dvcs (f374f66)