# HG changeset patch # User Mads Kiilerich # Date 1365555516 -7200 # Node ID 46d5811262b6ad7d39c7702cbedaf946abf9cc97 # Parent 0d22458bd360a423d0f0f9470a897dee60917a14 diff parser: show multiple messages ... and fix stats for non-git chunks diff -r 0d22458bd360 -r 46d5811262b6 rhodecode/lib/diffs.py --- a/rhodecode/lib/diffs.py Wed Apr 10 02:55:38 2013 +0200 +++ b/rhodecode/lib/diffs.py Wed Apr 10 02:58:36 2013 +0200 @@ -358,39 +358,43 @@ op = None stats = None - msg = None + msgs = [] if not head['a_file'] and head['b_file']: op = 'A' + stats = ['b', NEW_FILENODE] + msgs.append('new file') elif head['a_file'] and head['b_file']: op = 'M' + stats = ['b', MOD_FILENODE] elif head['a_file'] and not head['b_file']: op = 'D' + stats = ['b', DEL_FILENODE] + msgs.append('deleted file') else: if head['deleted_file_mode']: op = 'D' stats = ['b', DEL_FILENODE] - msg = 'deleted file' + msgs.append('deleted file') elif head['new_file_mode']: op = 'A' stats = ['b', NEW_FILENODE] - msg = 'new file %s' % head['new_file_mode'] + msgs.append('new file %s' % head['new_file_mode']) else: if head['new_mode'] and head['old_mode']: + op = 'M' stats = ['b', CHMOD_FILENODE] - op = 'M' - msg = ('modified file chmod %s => %s' + msgs.append('modified file chmod %s => %s' % (head['old_mode'], head['new_mode'])) - elif (head['rename_from'] and head['rename_to'] + if (head['rename_from'] and head['rename_to'] and head['rename_from'] != head['rename_to']): - stats = ['b', RENAMED_FILENODE] op = 'M' - msg = ('file renamed from %s to %s' + stats = ['b', RENAMED_FILENODE] # might overwrite CHMOD_FILENODE + msgs.append('file renamed from %s to %s' % (head['rename_from'], head['rename_to'])) - else: + if op is None: + op = 'M' stats = ['b', MOD_FILENODE] - op = 'M' - msg = 'modified file' if head['a_file'] or head['b_file']: # a real diff try: @@ -403,16 +407,15 @@ break else: # GIT binary patch (or empty diff) chunks = [] - if not msg: # don't overwrite more important message - msg = 'binary diff not shown' + msgs.append('binary diff not shown') # or no diff because it was a rename or chmod or add/remove of empty file - if msg: + if msgs: chunks.insert(0, [{ 'old_lineno': '', 'new_lineno': '', 'action': 'binary', 'line': msg, - }]) + } for msg in msgs]) _files.append({ 'filename': head['b_path'],