Changeset - 8df1bc51aa9c
[Not reviewed]
beta
0 1 0
Mads Kiilerich - 13 years ago 2013-04-10 03:00:20
madski@unity3d.com
diff parser: prefer git headers over old unified diff headers

Makes the diff show both rename and chmod info and the diff.
1 file changed with 9 insertions and 12 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/diffs.py
Show inline comments
 
@@ -357,24 +357,12 @@ class DiffProcessor(object):
 
            head, diff = self._get_header(raw_diff)
 

	
 
            op = None
 
            stats = 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]
 
                    msgs.append('deleted file')
 
                elif head['new_file_mode']:
 
                    op = 'A'
 
@@ -389,12 +377,21 @@ class DiffProcessor(object):
 
                    if (head['rename_from'] and head['rename_to']
 
                          and head['rename_from'] != head['rename_to']):
 
                        op = 'M'
 
                        stats = ['b', RENAMED_FILENODE] # might overwrite CHMOD_FILENODE
 
                        msgs.append('file renamed from %s to %s'
 
                                      % (head['rename_from'], head['rename_to']))
 
                if op is None: # fall back: detect missed old style add or remove
 
                    if not head['a_file'] and head['b_file']:
 
                        op = 'A'
 
                        stats = ['b', NEW_FILENODE]
 
                        msgs.append('new file')
 
                    elif head['a_file'] and not head['b_file']:
 
                        op = 'D'
 
                        stats = ['b', DEL_FILENODE]
 
                        msgs.append('deleted file')
 
                    if op is None:
 
                        op = 'M'
 
                        stats = ['b', MOD_FILENODE]
 

	
 
            if head['a_file'] or head['b_file']: # a real diff
 
                try:
0 comments (0 inline, 0 general)