# HG changeset patch # User Mads Kiilerich # Date 2020-06-18 14:25:23 # Node ID 4bf9d7f182531cc8f51d1891ea729afd51ca2edb # Parent 6f1e2514495874db492397a6563bcc015d1a0c86 diff: fix ignorews/context link to use the right target as anchor The value in url_fid might not be a valid anchor. For changesets, url_fid would be like 'C--9c390eb52cd6' even though the actual target included the changeset hash and were like 'C-1536d03b4869-9c390eb52cd6'. For pullrequests and compare, it wouldn't link to anything at all, even though there was a target like 'C--56535da5df40'. Instead, pass id_fid as anchor value as a separate argument. That one is a valid anchor. diff --git a/kallithea/controllers/changeset.py b/kallithea/controllers/changeset.py --- a/kallithea/controllers/changeset.py +++ b/kallithea/controllers/changeset.py @@ -70,7 +70,7 @@ def get_ignore_ws(fid, GET): return ig_ws_global -def _ignorews_url(GET, fileid=None): +def _ignorews_url(GET, fileid=None, anchor=None): fileid = str(fileid) if fileid else None params = defaultdict(list) _update_with_GET(params, GET) @@ -96,7 +96,7 @@ def _ignorews_url(GET, fileid=None): if ln_ctx: params[ctx_key] += [ctx_val] - params['anchor'] = fileid + params['anchor'] = anchor icon = h.literal('') return h.link_to(icon, h.url.current(**params), title=lbl, **{'data-toggle': 'tooltip'}) @@ -122,7 +122,7 @@ def get_line_ctx(fid, GET): return 3 -def _context_url(GET, fileid=None): +def _context_url(GET, fileid=None, anchor=None): """ Generates url for context lines @@ -156,7 +156,7 @@ def _context_url(GET, fileid=None): lbl = _('Increase diff context to %(num)s lines') % {'num': ln_ctx} - params['anchor'] = fileid + params['anchor'] = anchor icon = h.literal('') return h.link_to(icon, h.url.current(**params), title=lbl, **{'data-toggle': 'tooltip'}) 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 @@ -65,8 +65,8 @@ - ${c.ignorews_url(request.GET, url_fid)} - ${c.context_url(request.GET, url_fid)} + ${c.ignorews_url(request.GET, url_fid, id_fid)} + ${c.context_url(request.GET, url_fid, id_fid)}
${_('Show inline comments')}