Changeset - 79676fef1ae0
[Not reviewed]
default
0 2 0
Mads Kiilerich (kiilerix) - 9 years ago 2016-09-05 22:51:18
mads@kiilerich.com
diff: show correct operation for file diffs instead of '???'

Fix issue seen on the url $repo/diff/$filename?diff2=hash2&diff1=hash2 .

Drop returning unused size from diffs.wrapped_diff and return the operation
instead.
2 files changed with 12 insertions and 8 deletions:
0 comments (0 inline, 0 general) First comment
kallithea/controllers/files.py
Show inline comments
 
@@ -683,13 +683,12 @@ class FilesController(BaseRepoController
 
            ign_whitespace_lcl = get_ignore_ws(fid, request.GET)
 

	
 
            lim = request.GET.get('fulldiff') or self.cut_off_limit
 
            _, cs1, cs2, diff, st = diffs.wrapped_diff(filenode_old=node1,
 
            cs1, cs2, op, diff, st = diffs.wrapped_diff(filenode_old=node1,
 
                                         filenode_new=node2,
 
                                         cut_off_limit=lim,
 
                                         ignore_whitespace=ign_whitespace_lcl,
 
                                         line_context=line_context_lcl,
 
                                         enable_comments=False)
 
            op = ''
 
            filename = node1.path
 
            cs_changes = {
 
                'fid': [cs1, cs2, op, filename, diff, st]
kallithea/lib/diffs.py
Show inline comments
 
@@ -62,27 +62,32 @@ def wrapped_diff(filenode_old, filenode_
 
    if filenode_old is None:
 
        filenode_old = FileNode(filenode_new.path, '', EmptyChangeset())
 

	
 
    op = None
 
    if filenode_old.is_binary or filenode_new.is_binary:
 
        diff = wrap_to_table(_('Binary file'))
 
        stats = (0, 0)
 
        size = 0
 

	
 
    elif cut_off_limit != -1 and (cut_off_limit is None or
 
    (filenode_old.size < cut_off_limit and filenode_new.size < cut_off_limit)):
 
    elif cut_off_limit != -1 and (
 
            cut_off_limit is None or
 
            (filenode_old.size < cut_off_limit and filenode_new.size < cut_off_limit)):
 

	
 
        f_gitdiff = get_gitdiff(filenode_old, filenode_new,
 
                                ignore_whitespace=ignore_whitespace,
 
                                context=line_context)
 
        diff_processor = DiffProcessor(f_gitdiff, format='gitdiff')
 
        _parsed = diff_processor.prepare()
 
        if _parsed: # there should be exactly one element, for the specified file
 
            f = _parsed[0]
 
            op = f['operation']
 

	
 
        diff = diff_processor.as_html(enable_comments=enable_comments)
 
        stats = diff_processor.stat()
 
        size = len(diff or '')
 

	
 
    else:
 
        diff = wrap_to_table(_('Changeset was too big and was cut off, use '
 
                               'diff menu to display this diff'))
 
        stats = (0, 0)
 
        size = 0
 

	
 
    if not diff:
 
        submodules = filter(lambda o: isinstance(o, SubModuleNode),
 
                            [filenode_new, filenode_old])
 
@@ -94,7 +99,7 @@ def wrapped_diff(filenode_old, filenode_
 
    cs1 = filenode_old.changeset.raw_id
 
    cs2 = filenode_new.changeset.raw_id
 

	
 
    return size, cs1, cs2, diff, stats
 
    return cs1, cs2, op, diff, stats
 

	
 

	
 
def get_gitdiff(filenode_old, filenode_new, ignore_whitespace=True, context=3):
0 comments (0 inline, 0 general) First comment
You need to be logged in to comment. Login now