[PATCH] Allow C&P from file revision in hgweb without also copying line numbers
Jordi Gutiérrez Hermoso
jordigh at octave.org
Tue Oct 11 12:37:08 CDT 2011
2011/10/11 Matt Mackall <mpm at selenic.com>:
> On Tue, 2011-10-11 at 11:15 -0500, Jordi Gutiérrez Hermoso wrote:
>> It's useful from the web interface to be able to highlight code in
>> order to copy and paste it elsewhere. Unfortunately with the
>> current web interface, this has the annoying result of also
>> including the line numbers, so the pasted code will have them too
>> and requires further surgery to work.
>> This patch puts the line numbers for file revisions in a separate
>> <td> inside a table, and the actual code in another <td>, so there
>> are only two <td>s in the table. This is also done by passing the
>> line numbers to the template in a separate generator object than
>> the actual line contents themselves.
> What browsers did you test this against?
Firefox and Chrome. Slightly old versions of both (debian stable).
> I'm surprised this doesn't have any CSS hacks to deal with the
> smaller font size used for line numbers.
The font sizes don't matter. What matter is the size of the lines so
they align properly. I did have to manually set the line height for
the spartan style.
> Will this break old custom templates?
Yes. Is this undesirable? I'll put back the stuff that I removed to
make it backwards compatible, but then it's slightly inefficient to
compute the same thing twice.
> If you can get this to work for annotate, you'll be a hero: the
> large tables that annotate throws coupled with a bug in Firefox's
> incremental table rendering cause it to degrade to O(n^2)
> performance on large files.
Huh. I don't understand why annotate is creating large tables at all.
I can easily see how to kill that with a similar method. Why is
annotate using tables but filerev isn't?
>> diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
>> --- a/mercurial/hgweb/webcommands.py
>> +++ b/mercurial/hgweb/webcommands.py
>> @@ -67,22 +67,30 @@
>> f = fctx.path()
>> text = fctx.data()
>> parity = paritygen(web.stripecount)
>> + parity_nums = paritygen(web.stripecount)
> To quote ContributingChanges on the wiki:
> <!> If you send a patch with an underscore in a variable name, we'll
> know you haven't read this page!
Sorry. I did it read it and somehow got the opposite meaning out of
it. I'll rename those variables.
>> + def linenums():
>> + for lineno in range(0, len(all_lines)):
> This should be xrange(len(lines))
Fixed. New patch now follows.
- Jordi G. H.
More information about the Mercurial-devel