Changeset - 12ce88eece5f
[Not reviewed]
default
0 10 0
Mads Kiilerich - 9 years ago 2016-09-06 00:51:18
madski@unity3d.com
diff: correct handling of links to old filename in renames

There were links to the file at the parent revision ... but if the file had
been renamed, it used the wrong name.
10 files changed with 35 insertions and 32 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/changeset.py
Show inline comments
 
@@ -296,7 +296,7 @@ class ChangesetController(BaseRepoContro
 
                    url_fid = h.FID('', filename)
 
                    diff = diff_processor.as_html(enable_comments=enable_comments,
 
                                                  parsed_lines=[f])
 
                    file_diff_data[fid] = (url_fid, f['operation'], filename, diff, st)
 
                    file_diff_data[fid] = (url_fid, f['operation'], f['old_filename'], filename, diff, st)
 
            else:
 
                # downloads/raw we only need RAW diff nothing else
 
                diff = diff_processor.as_raw()
kallithea/controllers/compare.py
Show inline comments
 
@@ -288,6 +288,6 @@ class CompareController(BaseRepoControll
 
            fid = h.FID('', filename)
 
            diff = diff_processor.as_html(enable_comments=False,
 
                                          parsed_lines=[f])
 
            c.file_diff_data[fid] = (None, f['operation'], filename, diff, st)
 
            c.file_diff_data[fid] = (None, f['operation'], f['old_filename'], filename, diff, st)
 

	
 
        return render('compare/compare_diff.html')
kallithea/controllers/files.py
Show inline comments
 
@@ -683,13 +683,13 @@ class FilesController(BaseRepoController
 
            ign_whitespace_lcl = get_ignore_ws(fid, request.GET)
 

	
 
            lim = request.GET.get('fulldiff') or self.cut_off_limit
 
            c.a_rev, c.cs_rev, op, diff, st = diffs.wrapped_diff(filenode_old=node1,
 
            c.a_rev, c.cs_rev, a_path, diff, st, op = 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)
 
            c.file_diff_data = {fid: (fid, op, node1.path, diff, st)}
 
            c.file_diff_data = {fid: (fid, op, a_path, node2.path, diff, st)}
 

	
 
            return render('files/file_diff.html')
 

	
kallithea/controllers/pullrequests.py
Show inline comments
 
@@ -707,7 +707,7 @@ class PullrequestsController(BaseRepoCon
 
            fid = h.FID('', filename)
 
            diff = diff_processor.as_html(enable_comments=True,
 
                                          parsed_lines=[f])
 
            c.file_diff_data[fid] = (None, f['operation'], filename, diff, st)
 
            c.file_diff_data[fid] = (None, f['operation'], f['old_filename'], filename, diff, st)
 

	
 
        # inline comments
 
        c.inline_cnt = 0
kallithea/lib/diffs.py
Show inline comments
 
@@ -63,6 +63,7 @@ def wrapped_diff(filenode_old, filenode_
 
        filenode_old = FileNode(filenode_new.path, '', EmptyChangeset())
 

	
 
    op = None
 
    a_path = filenode_old.path # default, might be overriden by actual rename in diff
 
    if filenode_old.is_binary or filenode_new.is_binary:
 
        diff = wrap_to_table(_('Binary file'))
 
        stats = (0, 0)
 
@@ -79,6 +80,7 @@ def wrapped_diff(filenode_old, filenode_
 
        if _parsed: # there should be exactly one element, for the specified file
 
            f = _parsed[0]
 
            op = f['operation']
 
            a_path = f['old_filename']
 

	
 
        diff = diff_processor.as_html(enable_comments=enable_comments)
 
        stats = diff_processor.stat()
 
@@ -99,7 +101,7 @@ def wrapped_diff(filenode_old, filenode_
 
    cs1 = filenode_old.changeset.raw_id
 
    cs2 = filenode_new.changeset.raw_id
 

	
 
    return cs1, cs2, op, diff, stats
 
    return cs1, cs2, a_path, diff, stats, op
 

	
 

	
 
def get_gitdiff(filenode_old, filenode_new, ignore_whitespace=True, context=3):
 
@@ -476,6 +478,7 @@ class DiffProcessor(object):
 
                  if _op not in [MOD_FILENODE]])
 

	
 
            _files.append({
 
                'old_filename':     head['a_path'],
 
                'filename':         head['b_path'],
 
                'old_revision':     head['a_blob_id'],
 
                'new_revision':     head['b_blob_id'],
kallithea/templates/changeset/changeset.html
Show inline comments
 
@@ -168,7 +168,7 @@ ${self.repo_context_bar('changelog', c.c
 
              %endif
 
              </div>
 
              <div class="cs_files">
 
                %for fid, (url_fid, op, path, diff, stats) in file_diff_data.iteritems():
 
                %for fid, (url_fid, op, a_path, path, diff, stats) in file_diff_data.iteritems():
 
                    <div class="cs_${op}">
 
                      <div class="node">
 
                          <i class="icon-diff-${op}"></i>
kallithea/templates/changeset/changeset_range.html
Show inline comments
 
@@ -60,7 +60,7 @@ ${self.repo_context_bar('changelog')}
 
                %for cs in c.cs_ranges:
 
                    <div class="cur_cs">${h.link_to(h.show_id(cs),h.url('changeset_home',repo_name=c.cs_repo.repo_name,revision=cs.raw_id))}</div>
 
                    <% a_rev, cs_rev, file_diff_data = c.changes[cs.raw_id] %>
 
                    %for fid, (url_fid, op, path, diff, stats) in file_diff_data.iteritems():
 
                    %for fid, (url_fid, op, a_path, path, diff, stats) in file_diff_data.iteritems():
 
                        <div class="cs_${op}">
 
                            <div class="node">
 
                                <i class="icon-diff-${op}"></i>
kallithea/templates/changeset/diff_block.html
Show inline comments
 
@@ -7,54 +7,54 @@
 
    <span target="${'diff-container-%s' % (id(file_diff_data))}" class="diff-collapse-button">&uarr; ${_('Collapse Diff')} &uarr;</span>
 
</div>
 
<div class="diff-container" id="${'diff-container-%s' % (id(file_diff_data))}">
 
%for id_fid, (url_fid, op, filename, diff, stats) in file_diff_data.iteritems():
 
    ${diff_block_diffblock(id_fid, url_fid, op, filename, diff,
 
        a_repo_name, a_rev, a_ref_type, a_ref_name,
 
        cs_repo_name, cs_rev, cs_ref_type, cs_ref_name)}
 
%for id_fid, (url_fid, op, a_filename, cs_filename, diff, stats) in file_diff_data.iteritems():
 
    ${diff_block_diffblock(id_fid, url_fid, op, diff,
 
        a_repo_name, a_rev, a_ref_type, a_ref_name, a_filename,
 
        cs_repo_name, cs_rev, cs_ref_type, cs_ref_name, cs_filename)}
 
%endfor
 
</div>
 
</%def>
 

	
 
<%def name="diff_block_diffblock(id_fid, url_fid, op, filename, diff,
 
    a_repo_name, a_rev, a_ref_type, a_ref_name,
 
    cs_repo_name, cs_rev, cs_ref_type, cs_ref_name)"
 
<%def name="diff_block_diffblock(id_fid, url_fid, op, diff,
 
    a_repo_name, a_rev, a_ref_type, a_ref_name, a_filename,
 
    cs_repo_name, cs_rev, cs_ref_type, cs_ref_name, cs_filename)"
 
>
 
    <div id="${id_fid}_target" style="clear:both;margin-top:25px"></div>
 
    <div id="${id_fid}" class="diffblock margined comm">
 
        <div class="code-header">
 
            <div class="changeset_header">
 
                <div class="changeset_file">
 
                    ${h.safe_unicode(filename)} |
 
                    ${h.safe_unicode(cs_filename)} |
 
                    %if op == 'A':
 
                      ${_('Added')}
 
                      <a class="spantag" href="${h.url('files_home', repo_name=cs_repo_name, f_path=filename, revision=cs_rev)}">${h.short_ref(cs_ref_type, cs_ref_name)}</a>
 
                      <a class="spantag" href="${h.url('files_home', repo_name=cs_repo_name, f_path=cs_filename, revision=cs_rev)}">${h.short_ref(cs_ref_type, cs_ref_name)}</a>
 
                    %elif op == 'M':
 
                      <a class="spantag" href="${h.url('files_home', repo_name=a_repo_name, f_path=filename, revision=a_rev)}">${h.short_ref(a_ref_type, a_ref_name)}</a>
 
                      <a class="spantag" href="${h.url('files_home', repo_name=a_repo_name, f_path=a_filename, revision=a_rev)}">${h.short_ref(a_ref_type, a_ref_name)}</a>
 
                      <i class="icon-right"></i>
 
                      <a class="spantag" href="${h.url('files_home', repo_name=cs_repo_name, f_path=filename, revision=cs_rev)}">${h.short_ref(cs_ref_type, cs_ref_name)}</a>
 
                      <a class="spantag" href="${h.url('files_home', repo_name=cs_repo_name, f_path=cs_filename, revision=cs_rev)}">${h.short_ref(cs_ref_type, cs_ref_name)}</a>
 
                    %elif op == 'D':
 
                      ${_('Deleted')}
 
                      <a class="spantag" href="${h.url('files_home', repo_name=a_repo_name, f_path=filename, revision=a_rev)}">${h.short_ref(a_ref_type, a_ref_name)}</a>
 
                      <a class="spantag" href="${h.url('files_home', repo_name=a_repo_name, f_path=cs_filename, revision=a_rev)}">${h.short_ref(a_ref_type, a_ref_name)}</a>
 
                    %elif op == 'R':
 
                      ${_('Renamed')}
 
                      <a class="spantag" href="${h.url('files_home', repo_name=a_repo_name, f_path=filename, revision=a_rev)}">${h.short_ref(a_ref_type, a_ref_name)}</a>
 
                      <a class="spantag" href="${h.url('files_home', repo_name=a_repo_name, f_path=a_filename, revision=a_rev)}">${h.short_ref(a_ref_type, a_ref_name)}</a>
 
                      <i class="icon-right"></i>
 
                      <a class="spantag" href="${h.url('files_home', repo_name=cs_repo_name, f_path=filename, revision=cs_rev)}">${h.short_ref(cs_ref_type, cs_ref_name)}</a>
 
                      <a class="spantag" href="${h.url('files_home', repo_name=cs_repo_name, f_path=cs_filename, revision=cs_rev)}">${h.short_ref(cs_ref_type, cs_ref_name)}</a>
 
                    %else:
 
                      ${op}???
 
                    %endif
 
                </div>
 
                <div class="diff-actions">
 
                  <a href="${h.url('files_diff_home',repo_name=cs_repo_name,f_path=h.safe_unicode(filename),diff2=cs_rev,diff1=a_rev,diff='diff',fulldiff=1)}" class="tooltip" title="${_('Show full diff for this file')}">
 
                  <a href="${h.url('files_diff_home',repo_name=cs_repo_name,f_path=h.safe_unicode(cs_filename),diff2=cs_rev,diff1=a_rev,diff='diff',fulldiff=1)}" class="tooltip" title="${_('Show full diff for this file')}">
 
                      <i class="icon-file-code"></i>
 
                  </a>
 
                  <a href="${h.url('files_diff_2way_home',repo_name=cs_repo_name,f_path=h.safe_unicode(filename),diff2=cs_rev,diff1=a_rev,diff='diff',fulldiff=1)}" class="tooltip" title="${_('Show full side-by-side diff for this file')}">
 
                  <a href="${h.url('files_diff_2way_home',repo_name=cs_repo_name,f_path=h.safe_unicode(cs_filename),diff2=cs_rev,diff1=a_rev,diff='diff',fulldiff=1)}" class="tooltip" title="${_('Show full side-by-side diff for this file')}">
 
                      <i class="icon-docs"></i>
 
                  </a>
 
                  <a href="${h.url('files_diff_home',repo_name=cs_repo_name,f_path=h.safe_unicode(filename),diff2=cs_rev,diff1=a_rev,diff='raw')}" class="tooltip" title="${_('Raw diff')}">
 
                  <a href="${h.url('files_diff_home',repo_name=cs_repo_name,f_path=h.safe_unicode(cs_filename),diff2=cs_rev,diff1=a_rev,diff='raw')}" class="tooltip" title="${_('Raw diff')}">
 
                      <i class="icon-diff"></i>
 
                  </a>
 
                  <a href="${h.url('files_diff_home',repo_name=cs_repo_name,f_path=h.safe_unicode(filename),diff2=cs_rev,diff1=a_rev,diff='download')}" class="tooltip" title="${_('Download diff')}">
 
                  <a href="${h.url('files_diff_home',repo_name=cs_repo_name,f_path=h.safe_unicode(cs_filename),diff2=cs_rev,diff1=a_rev,diff='download')}" class="tooltip" title="${_('Download diff')}">
 
                      <i class="icon-floppy"></i>
 
                  </a>
 
                  ${c.ignorews_url(request.GET, url_fid)}
 
@@ -68,9 +68,9 @@
 
                </span>
 
            </div>
 
        </div>
 
        <div class="code-body full_f_path" data-f_path="${h.safe_unicode(filename)}">
 
        <div class="code-body full_f_path" data-f_path="${h.safe_unicode(cs_filename)}">
 
            ${diff|n}
 
            %if filename.rsplit('.')[-1] in ['png', 'gif', 'jpg', 'bmp']:
 
            %if cs_filename.rsplit('.')[-1] in ['png', 'gif', 'jpg', 'bmp']:
 
              <div class="btn btn-image-diff-show">Show images</div>
 
              %if op == 'M':
 
                <div id="${id_fid}_image-diff" class="btn btn-image-diff-swap" style="display:none">Press to swap images</div>
 
@@ -78,11 +78,11 @@
 
              <div style="font-size: 0">
 
                %if op in 'DM':
 
                  <img id="${id_fid}_image-diff-img-a" class="img-diff img-diff-swapable" style="display:none"
 
                      realsrc="${h.url('files_raw_home',repo_name=a_repo_name,revision=a_rev,f_path=filename)}" />
 
                      realsrc="${h.url('files_raw_home',repo_name=a_repo_name,revision=a_rev,f_path=a_filename)}" />
 
                %endif
 
                %if op in 'AM':
 
                  <img id="${id_fid}_image-diff-img-b" class="img-diff img-diff-swapable" style="display:none"
 
                      realsrc="${h.url('files_raw_home',repo_name=cs_repo_name,revision=cs_rev,f_path=filename)}" />
 
                      realsrc="${h.url('files_raw_home',repo_name=cs_repo_name,revision=cs_rev,f_path=cs_filename)}" />
 
                %endif
 
              </div>
 
            %endif
kallithea/templates/compare/compare_diff.html
Show inline comments
 
@@ -70,7 +70,7 @@ ${self.repo_context_bar('changelog')}
 
                  %if not c.file_diff_data:
 
                     <span class="empty_data">${_('No files')}</span>
 
                  %endif
 
                  %for fid, (url_fid, op, path, diff, stats) in c.file_diff_data.iteritems():
 
                  %for fid, (url_fid, op, a_path, path, diff, stats) in c.file_diff_data.iteritems():
 
                    <div class="cs_${op}">
 
                      <div class="node">
 
                          <i class="icon-diff-${op}"></i>
kallithea/templates/pullrequests/pullrequest_show.html
Show inline comments
 
@@ -334,7 +334,7 @@ ${self.repo_context_bar('showpullrequest
 
                %if not c.file_diff_data:
 
                   <span class="empty_data">${_('No files')}</span>
 
                %endif
 
                %for fid, (url_fid, op, path, diff, stats) in c.file_diff_data.iteritems():
 
                %for fid, (url_fid, op, a_path, path, diff, stats) in c.file_diff_data.iteritems():
 
                    <div class="cs_${op}">
 
                      <div class="node">
 
                          <i class="icon-diff-${op}"></i>
0 comments (0 inline, 0 general)