MozReview: Return `FileDiff` list sorted by default model sorting (pk) (Bug 1248008) r=smacleod
authorPiotr Zalewa <pzalewa@mozilla.com>
Fri, 06 Jan 2017 12:59:31 +0100
changeset 70 dfbc927623b7aa5a99b6a90681f762d4b43e8e66
parent 69 75a7c1033075182ebd1a8ea0de5078053ce505e4
child 71 bc491b5efdb738ca352ae0e15cd012492568621b
push id39
push usersmacleod@mozilla.com
push dateThu, 16 Feb 2017 15:15:51 +0000
reviewerssmacleod
bugs1248008
MozReview: Return `FileDiff` list sorted by default model sorting (pk) (Bug 1248008) r=smacleod MozReview is adding a commit message `FileDiff` which has to be displayed as the first one from the set. Sorting by dest_filename would be causing issues when paging is involved. MozReview-Commit-ID: 4iQs3hBbfSC
reviewboard/reviewboard/diffviewer/diffutils.py
--- a/reviewboard/reviewboard/diffviewer/diffutils.py
+++ b/reviewboard/reviewboard/diffviewer/diffutils.py
@@ -399,20 +399,22 @@ def get_diff_files(diffset, filediff=Non
 
         if force_interdiff:
             f['force_interdiff_revision'] = interdiffset.revision
 
         files.append(f)
 
     log_timer.done()
 
-    if len(files) == 1:
-        return files
-    else:
-        return get_sorted_filediffs(files, key=lambda f: f['filediff'])
+    # MozReview is adding a commit message filediff which has to be the first
+    # from the set. Sorting by dest_filename would cause issues when paging
+    # is involved. Since the filediff's are already in a logical order when
+    # sorted by id (which they should be here) removing this sort shouldn't
+    # make UX worse.
+    return files
 
 
 def populate_diff_chunks(files, enable_syntax_highlighting=True,
                          request=None):
     """Populates a list of diff files with chunk data.
 
     This accepts a list of files (generated by get_diff_files) and generates
     diff chunk data for each file in the list. The chunk data is stored in