• 
      

    Allow commit histories that modify the same file more than once

    Review Request #7043 — Created March 11, 2015 and submitted

    Information

    Review Board
    dvcs
    7fbed2e...

    Reviewers

    Previously, when uploading a commit history to a review request, it was
    impossible for your commit history to contain two commits which
    modified the same file. This is because the FileDiff processing
    checked the repository for the previous revisions of all files. In this
    case, the repository would report that the file did not exist at the
    given revision and validation would fail.

    Now we can check for file existence within our current set of uploaded
    DiffCommits. If we are unable to find an ancestor DiffCommit that
    contains the file at the correct revision, we fall back to the old
    behaviour of querying the repository. This allows linear commit
    histories that modify the same file to be validated and uploaded.

    NB: The diffviewer will not be able to show the FileDiff for such
    DiffSets. This will be addressed in a later patch that will land
    before this one.

    Ran unit tests.

    Posted a review request with commit history that modified the same file
    in two different commits; it was successful.

    Tried to view the review request's diff in the diff viewer; it was
    unsuccesful.

    Description From Last Updated

    How about using collections.defaultdict(list) here? That way you can skip conditional.

    david david

    In fact, it looks like this has a bug if the commit_id already exists (it doesn't append to the list …

    david david

    This looks unused.

    david david
    reviewbot
    1. Tool: Pyflakes
      Processed Files:
          reviewboard/diffviewer/models.py
          reviewboard/diffviewer/managers.py
          reviewboard/diffviewer/tests.py
          reviewboard/diffviewer/diffutils.py
      
      
      
      Tool: PEP8 Style Checker
      Processed Files:
          reviewboard/diffviewer/models.py
          reviewboard/diffviewer/managers.py
          reviewboard/diffviewer/tests.py
          reviewboard/diffviewer/diffutils.py
      
      
    2. 
        
    david
    1. 
        
    2. reviewboard/diffviewer/models.py (Diff revision 1)
       
       
      Show all issues

      How about using collections.defaultdict(list) here? That way you can skip conditional.

      1. See my comment on your next issue.

    3. reviewboard/diffviewer/models.py (Diff revision 1)
       
       
       
       
       
       
       
       
       
      Show all issues

      In fact, it looks like this has a bug if the commit_id already exists (it doesn't append to the list of parents). Using defaultdict would fix this.

      1. The reason I'm doing it this way is because of the case of commit validation. When we validate a commit, we do not save the new commit to the db so the commit will not show up in the dag (because it won't be in self.files in build_dag). However, when we are doing commit upload, the commit will be in the dag and we don't want to do unnecessary DB queries and have duplicate information in the dag.

      2. I've updated the documentation on the method to make it more clear that this is the desired behaviour.

    4. reviewboard/diffviewer/tests.py (Diff revision 1)
       
       
       
       
      Show all issues

      This looks unused.

    5. 
        
    brennie
    reviewbot
    1. Tool: Pyflakes
      Processed Files:
          reviewboard/diffviewer/models.py
          reviewboard/diffviewer/managers.py
          reviewboard/diffviewer/tests.py
          reviewboard/diffviewer/diffutils.py
      
      
      
      Tool: PEP8 Style Checker
      Processed Files:
          reviewboard/diffviewer/models.py
          reviewboard/diffviewer/managers.py
          reviewboard/diffviewer/tests.py
          reviewboard/diffviewer/diffutils.py
      
      
    2. 
        
    david
    1. Ship It!
    2. 
        
    brennie
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to dvcs (2131f48)