[PATCH RFC V2] hgweb: code selection without line numbers in file source view

Matt Mackall mpm at selenic.com
Sun Jun 30 19:01:29 CDT 2013


On Thu, 2013-06-27 at 17:34 +0400, Alexander Plavin wrote:
> -  <div class="parity{parity} source"><a href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}</div>'
> +  <li class="parity{parity} source" id="{lineid}"><div>{ifeq(strip(line, '\r\n'), '', ' ', '')}{strip(line|escape, "\r\n")}</div></li>'

This is, in my opinion, the worst sort of thing you can do as a software
engineer.

Here you have broken a perfectly good, working feature (anchor links)
to introduce another. You have taken one step back and one step forward
in a different direction. In some very real sense, your net progress is
_worse than zero_ because you've taken away something that some people
already rely on[1] and replaced it with something that none of your
users currently rely on. 

In doing so, you've given people a good reason to dread upgrading. Make
this sort of trade-off a dozen times in a development cycle, and you're
now developing the sort of software I absolutely loathe.

In fact, this is the sort of thing we call a 'regression' on our BTS,
and automatically bump to a higher priority than other issues. It's the
sort of (rare) thing we delay releases for and do large reverts to fix.


I think at this point we need to step back and look at the prerequisites
for what you're trying to do here:

- correct display:
   - indentation [2]
   - embedded whitespace
   - monospace
- anchor links
+ nice cut and paste
   + no line numbers
   + correct embedded whitespace

If you have to mangle the whitespace to get rid of the line numbers, I
don't really see the point in trying: you can't paste it into your
editor without editing anyway.

I put together this test case on Friday:

 http://www.selenic.com/space.html

..and it does not look at all promising, especially with tabs.

Since the exisiting <pre> style seems to mostly work, perhaps this is a
situation where we should use Javascript. Stick to the existing HTML,
but post-process it to turn the line number into a CSS decoration ala

 http://en.support.wordpress.com/code/posting-source-code/


By the way, I mentioned if() last time around (not ifeq) on purpose:

ifeq(x, '', a, b) -> if(x, a, b)


[1] I personally use these anchor links at least once a day
[2] We have a known issue with the first tab being too small
-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list