Fix casting queryset to list before finished querying

Review Request #206 — Created Dec. 9, 2016 and updated

guest3710
Review Board
ab459d0...
guest3710
A recent merge introduced a bug where the `FileDiff` queryset in
`get_diff_files` was cast to a list before excluding the filediff
ancestors, which is an operation that expects a queryset. This has been
fixed.


  • 2
  • 0
  • 3
  • 1
  • 6
Description From Last Updated
fqwfqwf guest3679 guest3679
Aha a multi-line comment guest5735 guest5735
guest3889
  1. Ship It!
  2. 
      
guest5406
  1. Ship It!
  2. 
      
guest9536
  1. 
      
  2. this is an issue

  3. reviewboard/diffviewer/diffutils.py (Diff revision 1)
     
     

    this is a test comment

  4. 
      
guest3679
guest3679
  1. 
      
  2. fqwfqwf

  3. 
      
guest6863
  1. 
      
  2. reviewboard/diffviewer/diffutils.py (Diff revision 1)
     
     

    My comment

  3. 
      
guest5735
  1. 
      
  2. reviewboard/diffviewer/diffutils.py (Diff revision 1)
     
     

    Test comment here

  3. 
      
guest5735
  1. 
      
  2. reviewboard/diffviewer/diffutils.py (Diff revision 1)
     
     
     
     
     

    Aha a multi-line comment

  3. 
      
guest3629
  1. Ship It!
  2. 
      
guest6879
  1. Ship It!
  2. 
      
guest4426
  1. test

  2. 
      
guest9270
  1. 
      
  2. reviewboard/diffviewer/diffutils.py (Diff revision 1)
     
     
     

    This could be on one line

  3. 
      
guest2895
  1. testreviewcomment

  2. 
      
guest2895
  1. def get_diff_files(diffset, filediff=None, interdiffset=None,

    def get_diff_files(diffset, filediff=None, interdiffset=None,

                   interfilediff=None, base_commit_id=None, tip_commit_id=None,
    
                   interfilediff=None, base_commit_id=None, tip_commit_id=None,
    
                   request=None):
    
                   request=None):
    
    """Return a list of files that will be displayed in a diff
    
    """Return a list of files that will be displayed in a diff
    
    This will go through the given diffset/interdiffset, or a given filediff
    
    This will go through the given diffset/interdiffset, or a given filediff
    
    within that diffset, and generate the list of files that will be
    
    within that diffset, and generate the list of files that will be
    
    displayed. This file list will contain a bunch of metadata on the files,
    
    displayed. This file list will contain a bunch of metadata on the files,
    
    such as the index, original/modified names, revisions, associated
    
    such as the index, original/modified names, revisions, associated
    
    filediffs/diffsets, and so on.
    
    filediffs/diffsets, and so on.
    
    This can be used along with :py:func:`populate_diff_chunks` to build a full
    
    This can be used along with :py:func:`populate_diff_chunks` to build a full
    
    list containing all diff chunks used for rendering a side-by-side diff.
    
    list containing all diff chunks used for rendering a side-by-side diff.
    
    Args:
    
    Args:
    
        diffset (reviewboard.diffviewer.models.DiffSet):
    
        diffset (reviewboard.diffviewer.models.DiffSet):
    
            The diffset containing the files to return.
    
            The diffset containing the files to return.
    
        filediff (reviewboard.diffviewer.models.FileDiff, optional):
    
        filediff (reviewboard.diffviewer.models.FileDiff, optional):
    
            A specific file in the diff to return information for.
    
            A specific file in the diff to return information for.
    
        interdiffset (reviewboard.diffviewer.models.DiffSet, optional):
    
        interdiffset (reviewboard.diffviewer.models.DiffSet, optional):
    
            A second diffset used for an interdiff range.
    
            A second diffset used for an interdiff range.
    
        interfilediff (reviewboard.diffviewer.models.FileDiff, optional):
    
        interfilediff (reviewboard.diffviewer.models.FileDiff, optional):
    
            A second specific file in ``interdiffset`` used to return
    
            A second specific file in ``interdiffset`` used to return
    
            information for. This should be provided if ``filediff`` and
    
            information for. This should be provided if ``filediff`` and
    
            ``interdiffset`` are both provided. If it's ``None`` in this
    
            ``interdiffset`` are both provided. If it's ``None`` in this
    
            case, then the diff will be shown as reverted for this file.
    
            case, then the diff will be shown as reverted for this file.
    
        request (django.http.HttpRequest):
    
        request (django.http.HttpRequest):
    
            The current HTTP request.
    
            The current HTTP request.
    
    Returns:
    
    Returns:
    
        list of dict:
    
        list of dict:
    
        A list of dictionaries containing information on the files to show
    
        A list of dictionaries containing information on the files to show
    
        in the diff, in the order in which they would be shown.
    
        in the diff, in the order in which they would be shown.
    
    """
    
    """
    
    assert not interdiffset or (not base_commit_id and not tip_commit_id)
    
    assert not interdiffset or (not base_commit_id and not tip_commit_id)
    
    have_diffset_commits = diffset.diff_commit_count
    
    have_diffset_commits = diffset.diff_commit_count
    
    diffset_file_graph = None
    
    diffset_file_graph = None
    
    if filediff:
    
    if filediff:
    
        filediffs = [filediff]
    
        filediffs = [filediff]
    
        if interdiffset:
    
        if interdiffset:
    
            log_timer = log_timed("Generating diff file info for "
    
            log_timer = log_timed("Generating diff file info for "
    
                                  "interdiffset ids %s-%s, filediff %s" %
    
                                  "interdiffset ids %s-%s, filediff %s" %
    
                                  (diffset.id, interdiffset.id, filediff.id),
    
                                  (diffset.id, interdiffset.id, filediff.id),
    
                                  request=request)
    
                                  request=request)
    
        else:
    
        else:
    
            log_timer = log_timed("Generating diff file info for "
    
            log_timer = log_timed("Generating diff file info for "
    
                                  "diffset id %s, filediff %s" %
    
                                  "diffset id %s, filediff %s" %
    
                                  (diffset.id, filediff.id),
    
                                  (diffset.id, filediff.id),
    
                                  request=request)
    
                                  request=request)
    
    else:
    
    else:
    
        if have_diffset_commits:
    
        if have_diffset_commits:
    
            diffset_file_graph = diffset.build_file_history_graph()
    
            diffset_file_graph = diffset.build_file_history_graph()
    
            if tip_commit_id:
    
            if tip_commit_id:
    
                commit_range = diffset.get_commit_interval(base_commit_id,
    
                commit_range = diffset.get_commit_interval(base_commit_id,
    
                                                           tip_commit_id)
    
                                                           tip_commit_id)
    
                filediffs = diffset.files.select_related().filter(
    
                filediffs = diffset.files.select_related().filter(
    
                    diff_commit__in=commit_range.all())
    
                    diff_commit__in=commit_range.all())
    
            else:
    
            else:
    
                filediffs = diffset.files.select_related().all()
    
                filediffs = diffset.files.select_related().all()
    
  2. 
      
guest2895
  1. 
      
  2. 
      
guest2895
  1. Ship It!
  2. 
      
Loading...