# HG changeset patch # User Mads Kiilerich # Date 2016-09-06 00:51:18 # Node ID 12ce88eece5f44efeffd40baecc79d7397e8fb08 # Parent 4034992774fadd24721b07218dcf905a28cda250 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. diff --git a/kallithea/controllers/changeset.py b/kallithea/controllers/changeset.py --- a/kallithea/controllers/changeset.py +++ b/kallithea/controllers/changeset.py @@ -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() diff --git a/kallithea/controllers/compare.py b/kallithea/controllers/compare.py --- a/kallithea/controllers/compare.py +++ b/kallithea/controllers/compare.py @@ -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') diff --git a/kallithea/controllers/files.py b/kallithea/controllers/files.py --- a/kallithea/controllers/files.py +++ b/kallithea/controllers/files.py @@ -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') diff --git a/kallithea/controllers/pullrequests.py b/kallithea/controllers/pullrequests.py --- a/kallithea/controllers/pullrequests.py +++ b/kallithea/controllers/pullrequests.py @@ -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 diff --git a/kallithea/lib/diffs.py b/kallithea/lib/diffs.py --- a/kallithea/lib/diffs.py +++ b/kallithea/lib/diffs.py @@ -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'], diff --git a/kallithea/templates/changeset/changeset.html b/kallithea/templates/changeset/changeset.html --- a/kallithea/templates/changeset/changeset.html +++ b/kallithea/templates/changeset/changeset.html @@ -168,7 +168,7 @@ ${self.repo_context_bar('changelog', c.c %endif
- %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():
diff --git a/kallithea/templates/changeset/changeset_range.html b/kallithea/templates/changeset/changeset_range.html --- a/kallithea/templates/changeset/changeset_range.html +++ b/kallithea/templates/changeset/changeset_range.html @@ -60,7 +60,7 @@ ${self.repo_context_bar('changelog')} %for cs in c.cs_ranges:
${h.link_to(h.show_id(cs),h.url('changeset_home',repo_name=c.cs_repo.repo_name,revision=cs.raw_id))}
<% 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():
diff --git a/kallithea/templates/changeset/diff_block.html b/kallithea/templates/changeset/diff_block.html --- a/kallithea/templates/changeset/diff_block.html +++ b/kallithea/templates/changeset/diff_block.html @@ -7,54 +7,54 @@ ↑ ${_('Collapse Diff')} ↑
-%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
-<%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)" >
-
+
${diff|n} - %if filename.rsplit('.')[-1] in ['png', 'gif', 'jpg', 'bmp']: + %if cs_filename.rsplit('.')[-1] in ['png', 'gif', 'jpg', 'bmp']:
Show images
%if op == 'M': @@ -78,11 +78,11 @@
%if op in 'DM': + realsrc="${h.url('files_raw_home',repo_name=a_repo_name,revision=a_rev,f_path=a_filename)}" /> %endif %if op in 'AM': + realsrc="${h.url('files_raw_home',repo_name=cs_repo_name,revision=cs_rev,f_path=cs_filename)}" /> %endif
%endif diff --git a/kallithea/templates/compare/compare_diff.html b/kallithea/templates/compare/compare_diff.html --- a/kallithea/templates/compare/compare_diff.html +++ b/kallithea/templates/compare/compare_diff.html @@ -70,7 +70,7 @@ ${self.repo_context_bar('changelog')} %if not c.file_diff_data: ${_('No files')} %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():
diff --git a/kallithea/templates/pullrequests/pullrequest_show.html b/kallithea/templates/pullrequests/pullrequest_show.html --- a/kallithea/templates/pullrequests/pullrequest_show.html +++ b/kallithea/templates/pullrequests/pullrequest_show.html @@ -334,7 +334,7 @@ ${self.repo_context_bar('showpullrequest %if not c.file_diff_data: ${_('No files')} %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():