From patchwork Wed Apr 17 14:26:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1,of,1,V3] hgweb: code selection in file view without line numbers From: Alexander Plavin X-Patchwork-Id: 1385 Message-Id: <1933896b16c821ba1e54.1366208797@debian-alexander.dolgopa> To: mercurial-devel@selenic.com Date: Wed, 17 Apr 2013 18:26:37 +0400 # HG changeset patch # User Alexander Plavin # Date 1366205259 -14400 # Wed Apr 17 17:27:39 2013 +0400 # Node ID 1933896b16c821ba1e54e397f15e3f521aaf8909 # Parent 4d32c86be3fad13cbe42ce3f51b0fdacf295f30f hgweb: code selection in file view without line numbers Only single file views changed, and only default templates set ('paper') diff -r 4d32c86be3fa -r 1933896b16c8 mercurial/templates/paper/filerevision.tmpl --- a/mercurial/templates/paper/filerevision.tmpl Wed Apr 10 20:45:10 2013 +0400 +++ b/mercurial/templates/paper/filerevision.tmpl Wed Apr 17 17:27:39 2013 +0400 @@ -68,7 +68,8 @@
line source
-{text%fileline} +
{text%filelinenum}
+
{text%fileline}
diff -r 4d32c86be3fa -r 1933896b16c8 mercurial/templates/paper/map --- a/mercurial/templates/paper/map Wed Apr 10 20:45:10 2013 +0400 +++ b/mercurial/templates/paper/map Wed Apr 17 17:27:39 2013 +0400 @@ -72,7 +72,9 @@ filecomparison = filecomparison.tmpl filelog = filelog.tmpl fileline = ' -
{linenumber} {line|escape}
' + {line|escape|strip}' +filelinenum = ' + {linenumber} ' filelogentry = filelogentry.tmpl annotateline = ' diff -r 4d32c86be3fa -r 1933896b16c8 mercurial/templates/static/style-paper.css --- a/mercurial/templates/static/style-paper.css Wed Apr 10 20:45:10 2013 +0400 +++ b/mercurial/templates/static/style-paper.css Wed Apr 17 17:27:39 2013 +0400 @@ -198,7 +198,7 @@ .bigtable td.annotate { font-size: smaller; } .bigtable td.source { font-size: inherit; } -.source, .sourcefirst, .sourcelast { +.source, .sourcefirst, .sourcelast, .sourcenumbers { font-family: monospace; white-space: pre; padding: 1px 4px; @@ -206,7 +206,8 @@ } .sourcefirst { border-bottom: 1px solid #999; font-weight: bold; } .sourcelast { border-top: 1px solid #999; } -.source a { color: #999; font-size: smaller; font-family: monospace;} +.sourcenumbers { float: left; } +.sourcenumbers a { color: #999; font-size: smaller; font-family: monospace; } .bottomline { border-bottom: 1px solid #999; } .fileline { font-family: monospace; } diff -r 4d32c86be3fa -r 1933896b16c8 tests/test-hgweb-commands.t --- a/tests/test-hgweb-commands.t Wed Apr 10 20:45:10 2013 +0400 +++ b/tests/test-hgweb-commands.t Wed Apr 17 17:27:39 2013 +0400 @@ -668,9 +668,10 @@
line source
- -
1 foo -
+
+       1 
+
+  foo
diff -r 4d32c86be3fa -r 1933896b16c8 tests/test-highlight.t --- a/tests/test-highlight.t Wed Apr 10 20:45:10 2013 +0400 +++ b/tests/test-highlight.t Wed Apr 17 17:27:39 2013 +0400 @@ -137,39 +137,72 @@
line source
+
+       1 
+       2 
+       3 
+       4 
+       5 
+       6 
+       7 
+       8 
+       9 
+      10 
+      11 
+      12 
+      13 
+      14 
+      15 
+      16 
+      17 
+      18 
+      19 
+      20 
+      21 
+      22 
+      23 
+      24 
+      25 
+      26 
+      27 
+      28 
+      29 
+      30 
+      31 
+      32 
+
+  #!/usr/bin/env python
   
-  
1 #!/usr/bin/env python
- -
3 """Fun with generators. Corresponding Haskell implementation:
- -
5 primes = 2 : sieve [3, 5..]
-
6 where sieve (p:ns) = p : sieve [n | n <- ns, mod n p /= 0]
-
7 """
- -
9 from itertools import dropwhile, ifilter, islice, count, chain
- -
11 def primes():
-
12 """Generate all primes."""
-
13 def sieve(ns):
-
14 p = ns.next()
-
15 # It is important to yield *here* in order to stop the
-
16 # infinite recursion.
-
17 yield p
-
18 ns = ifilter(lambda n: n % p != 0, ns)
-
19 for n in sieve(ns):
-
20 yield n
- -
22 odds = ifilter(lambda i: i % 2 == 1, count())
-
23 return chain([2], sieve(dropwhile(lambda n: n < 3, odds)))
- -
25 if __name__ == "__main__":
-
26 import sys
-
27 try:
-
28 n = int(sys.argv[1])
-
29 except (ValueError, IndexError):
-
30 n = 10
-
31 p = primes()
-
32 print "The first %d primes: %s" % (n, list(islice(p, n)))
+ """Fun with generators. Corresponding Haskell implementation: + + primes = 2 : sieve [3, 5..] + where sieve (p:ns) = p : sieve [n | n <- ns, mod n p /= 0] + """ + + from itertools import dropwhile, ifilter, islice, count, chain + + def primes(): + """Generate all primes.""" + def sieve(ns): + p = ns.next() + # It is important to yield *here* in order to stop the + # infinite recursion. + yield p + ns = ifilter(lambda n: n % p != 0, ns) + for n in sieve(ns): + yield n + + odds = ifilter(lambda i: i % 2 == 1, count()) + return chain([2], sieve(dropwhile(lambda n: n < 3, odds))) + + if __name__ == "__main__": + import sys + try: + n = int(sys.argv[1]) + except (ValueError, IndexError): + n = 10 + p = primes() + print "The first %d primes: %s" % (n, list(islice(p, n)))
@@ -586,24 +619,27 @@ > > echo % hgweb filerevision, html > "$TESTDIR/get-with-headers.py" localhost:$HGPORT "file/tip/$2" \ - > | grep '
' + > | grep -A 1 '
'
   >     echo % errors encountered
   >     cat errors.log
   > }
   $ hgserveget euc-jp eucjp.txt
   % HGENCODING=euc-jp hg serve
   % hgweb filerevision, html
-  
1 \xb5\xfe
(esc) +
+  \xb5\xfe
(esc) % errors encountered $ hgserveget utf-8 eucjp.txt % HGENCODING=utf-8 hg serve % hgweb filerevision, html -
1 \xef\xbf\xbd\xef\xbf\xbd
(esc) +
+  \xef\xbf\xbd\xef\xbf\xbd
(esc) % errors encountered $ hgserveget us-ascii eucjp.txt % HGENCODING=us-ascii hg serve % hgweb filerevision, html -
1 ??
+
+  ??
% errors encountered $ cd ..