changeset 4507:cd9bb3e07e68

diff: don't group diffs based on the kind of change We do no longer show the content of deleted files so there is no longer any reason to put them at the end. Keeping all changes sorted by file name makes it easier to review.
author Mads Kiilerich <madski@unity3d.com>
date Mon, 08 Sep 2014 13:38:56 +0200
parents ac752047284f
children 362652e72e29
files kallithea/lib/diffs.py kallithea/tests/models/test_diff_parsers.py
diffstat 2 files changed, 34 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/diffs.py	Mon Sep 08 13:38:56 2014 +0200
+++ b/kallithea/lib/diffs.py	Mon Sep 08 13:38:56 2014 +0200
@@ -473,10 +473,8 @@
                 'stats':            stats,
             })
 
-        sorter = lambda info: {'A': 0, 'M': 1, 'D': 2}.get(info['operation'])
-
         if not inline_diff:
-            return diff_container(sorted(_files, key=sorter))
+            return diff_container(_files)
 
         # highlight inline changes
         for diff_data in _files:
@@ -494,7 +492,7 @@
                 except StopIteration:
                     pass
 
-        return diff_container(sorted(_files, key=sorter))
+        return diff_container(_files)
 
     def _parse_udiff(self, inline_diff=True):
         raise NotImplementedError()
--- a/kallithea/tests/models/test_diff_parsers.py	Mon Sep 08 13:38:56 2014 +0200
+++ b/kallithea/tests/models/test_diff_parsers.py	Mon Sep 08 13:38:56 2014 +0200
@@ -87,16 +87,27 @@
           'binary': True,
           'ops': {NEW_FILENODE: 'new file 100644',
                   BIN_FILENODE: 'binary diff not shown'}}),
+        ('img/baseline-20px.png', 'D',
+         {'added': 0,
+          'deleted': 0,
+          'binary': True,
+          'ops': {DEL_FILENODE: 'deleted file',
+                  BIN_FILENODE: 'binary diff not shown'}}),
+        ('index.html', 'M',
+         {'added': 3,
+          'deleted': 2,
+          'binary': False,
+          'ops': {MOD_FILENODE: 'modified file'}}),
+        ('js/global.js', 'D',
+         {'added': 0,
+          'deleted': 75,
+          'binary': False,
+          'ops': {DEL_FILENODE: 'deleted file'}}),
         ('js/jquery/hashgrid.js', 'A',
          {'added': 340,
           'deleted': 0,
           'binary': False,
           'ops': {NEW_FILENODE: 'new file 100755'}}),
-        ('index.html', 'M',
-         {'added': 3,
-          'deleted': 2,
-          'binary': False,
-          'ops': {MOD_FILENODE: 'modified file'}}),
         ('less/docs.less', 'M',
          {'added': 34,
           'deleted': 0,
@@ -112,17 +123,6 @@
           'deleted': 10,
           'binary': False,
           'ops': {MOD_FILENODE: 'modified file'}}),
-        ('img/baseline-20px.png', 'D',
-         {'added': 0,
-          'deleted': 0,
-          'binary': True,
-          'ops': {DEL_FILENODE: 'deleted file',
-                  BIN_FILENODE: 'binary diff not shown'}}),
-        ('js/global.js', 'D',
-         {'added': 0,
-          'deleted': 75,
-          'binary': False,
-          'ops': {DEL_FILENODE: 'deleted file'}})
     ],
     'git_diff_chmod.diff': [
         ('work-horus.xls', 'M',
@@ -153,16 +153,27 @@
           'binary': True,
           'ops': {NEW_FILENODE: 'new file 100644',
                   BIN_FILENODE: 'binary diff not shown'}}),
+        ('img/baseline-20px.png', 'D',
+         {'added': 0,
+          'deleted': 0,
+          'binary': True,
+          'ops': {DEL_FILENODE: 'deleted file',
+                  BIN_FILENODE: 'binary diff not shown'}}),
+        ('index.html', 'M',
+         {'added': 3,
+          'deleted': 2,
+          'binary': False,
+          'ops': {MOD_FILENODE: 'modified file'}}),
+        ('js/global.js', 'D',
+         {'added': 0,
+          'deleted': 75,
+          'binary': False,
+          'ops': {DEL_FILENODE: 'deleted file'}}),
         ('js/jquery/hashgrid.js', 'A',
          {'added': 340,
           'deleted': 0,
           'binary': False,
           'ops': {NEW_FILENODE: 'new file 100755'}}),
-        ('index.html', 'M',
-         {'added': 3,
-          'deleted': 2,
-          'binary': False,
-          'ops': {MOD_FILENODE: 'modified file'}}),
         ('less/docs.less', 'M',
          {'added': 34,
           'deleted': 0,
@@ -178,17 +189,6 @@
           'deleted': 10,
           'binary': False,
           'ops': {MOD_FILENODE: 'modified file'}}),
-        ('img/baseline-20px.png', 'D',
-         {'added': 0,
-          'deleted': 0,
-          'binary': True,
-          'ops': {DEL_FILENODE: 'deleted file',
-                  BIN_FILENODE: 'binary diff not shown'}}),
-        ('js/global.js', 'D',
-         {'added': 0,
-          'deleted': 75,
-          'binary': False,
-          'ops': {DEL_FILENODE: 'deleted file'}}),
     ],
     'diff_with_diff_data.diff': [
         ('vcs/backends/base.py', 'M',