[PATCH RFC] hgweb: improve annotate flow

Patrick Mézard pmezard at gmail.com
Sun Nov 20 06:44:16 CST 2011


Le 19/11/11 00:56, Laurens Holst a écrit :
> Op 18-11-2011 21:15, Patrick Mézard schreef:
>> Le 18/11/11 19:55, Laurens Holst a écrit :
>>> Op 18-11-2011 19:37, Patrick Mézard schreef:
>>>> It actually exists but there is nothing to scroll so it gives
>>>> the impression the anchor is not there. Just look for
>>>> 'id="t1.372"' in the page source. That said, the anchor
>>>> generation is a little ad-hoc and I would not be surprised to
>>>> find bugs in this area with complicated patches mixing binaries
>>>> and renames.
>>>> 
>>>> Also, Javascript could be used here to highlight the target
>>>> line or the target hunk and avoid this no-scroll issue (or even
>>>> CSS if the id passed as a parameter as well).
>>> Actually there’s an easier way to do this, without scripting; If
>>> you move the ID from the<a>  tag to the<td>  tag, you can use the
>>> CSS :target pseudo-class to highlight the line, something like:
>>> 
>>> td:target { background-color: yellow }
>> Thanks, I have updated the demo server. And mpm link now looks
>> like:
>> 
>> http://mezard.eu/hg/hg-does-it-look-good-for-you/rev/5868dd69fb03/#t1.372
>
>> 
> Hey,
> 
> Looks good!
> 
> However it could still use some improvement though: Because you have
> two separate IDs now, if you click on a line number to make a link
> now, it doesn’t get highlighted. Also if you click on ‘ann’ the line
> in the annotate view doesn’t get highlighted.
> 
> You should remove the ID from the <a> tag entirely, and just have the
> ID on the <td> (annotate view) or <div> (rev view). Then consistently
> any link pointing to a line number will highlight the target. So as
> to not break existing links you should use the original ID scheme for
> this (l1.20).

This is not that simple. My new IDs are really (index of touched file in changeset, line number) tuples. They are trivial to generate from the annotate view (and not *too* expensive since reading we only need extra reads of the changelog). They are easy to generate in the changeset view because diffs are designed to make it easy to retrieve modified line numbers. The original IDs (l1.20) are (diff file index, line number in file level diff block). While the file index is not a problem, generating the diff line numbers is not trivial from the annotate process because annotate blocks are post-processed (hunk merging for instance, depending on the number of context lines) to make diff blocks.

--
Patrick Mézard


More information about the Mercurial-devel mailing list