# HG changeset patch # User Anton Shestakov # Date 1468651747 -28800 # Node ID d86b54d9bb0cb406040ecba1ae68946ea71eca2a # Parent d1a7d9c279bb27c8c275bf3a7d3e893d2f50d1f3 paper: make different blocks of annotated lines have different colors diff -r d1a7d9c279bb -r d86b54d9bb0c mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py Fri May 20 09:47:35 2016 +0900 +++ b/mercurial/hgweb/webcommands.py Sat Jul 16 14:49:07 2016 +0800 @@ -880,9 +880,14 @@ lines = fctx.annotate(follow=True, linenumber=True, diffopts=diffopts) previousrev = None + blockparitygen = paritygen(1) for lineno, ((f, targetline), l) in enumerate(lines): rev = f.rev() - blockhead = rev != previousrev or None + if rev != previousrev: + blockhead = True + blockparity = next(blockparitygen) + else: + blockhead = None previousrev = rev yield {"parity": next(parity), "node": f.hex(), @@ -893,6 +898,7 @@ "extra": f.extra(), "file": f.path(), "blockhead": blockhead, + "blockparity": blockparity, "targetline": targetline, "line": l, "lineno": lineno + 1, diff -r d1a7d9c279bb -r d86b54d9bb0c mercurial/templates/paper/map --- a/mercurial/templates/paper/map Fri May 20 09:47:35 2016 +0900 +++ b/mercurial/templates/paper/map Sat Jul 16 14:49:07 2016 +0800 @@ -77,7 +77,7 @@ annotateline = ' - + {if(blockhead, ' {rev} diff -r d1a7d9c279bb -r d86b54d9bb0c tests/test-highlight.t --- a/tests/test-highlight.t Fri May 20 09:47:35 2016 +0900 +++ b/tests/test-highlight.t Sat Jul 16 14:49:07 2016 +0800 @@ -289,7 +289,7 @@ - + 0 @@ -308,7 +308,7 @@ 1 #!/usr/bin/env python - +
@@ -325,7 +325,7 @@ 2 - +
@@ -342,7 +342,7 @@ 3 """Fun with generators. Corresponding Haskell implementation: - +
@@ -359,7 +359,7 @@ 4 - +
@@ -376,7 +376,7 @@ 5 primes = 2 : sieve [3, 5..] - +
@@ -393,7 +393,7 @@ 6 where sieve (p:ns) = p : sieve [n | n <- ns, mod n p /= 0] - +
@@ -410,7 +410,7 @@ 7 """ - +
@@ -427,7 +427,7 @@ 8 - +
@@ -444,7 +444,7 @@ 9 from itertools import dropwhile, ifilter, islice, count, chain - +
@@ -461,7 +461,7 @@ 10 - +
@@ -478,7 +478,7 @@ 11 def primes(): - +
@@ -495,7 +495,7 @@ 12 """Generate all primes.""" - +
@@ -512,7 +512,7 @@ 13 def sieve(ns): - +
@@ -529,7 +529,7 @@ 14 p = ns.next() - +
@@ -546,7 +546,7 @@ 15 # It is important to yield *here* in order to stop the - +
@@ -563,7 +563,7 @@ 16 # infinite recursion. - +
@@ -580,7 +580,7 @@ 17 yield p - +
@@ -597,7 +597,7 @@ 18 ns = ifilter(lambda n: n % p != 0, ns) - +
@@ -614,7 +614,7 @@ 19 for n in sieve(ns): - +
@@ -631,7 +631,7 @@ 20 yield n - +
@@ -648,7 +648,7 @@ 21 - +
@@ -665,7 +665,7 @@ 22 odds = ifilter(lambda i: i % 2 == 1, count()) - +
@@ -682,7 +682,7 @@ 23 return chain([2], sieve(dropwhile(lambda n: n < 3, odds))) - +
@@ -699,7 +699,7 @@ 24 - +
@@ -716,7 +716,7 @@ 25 if __name__ == "__main__": - +
@@ -733,7 +733,7 @@ 26 import sys - +
@@ -750,7 +750,7 @@ 27 try: - +
@@ -767,7 +767,7 @@ 28 n = int(sys.argv[1]) - +
@@ -784,7 +784,7 @@ 29 except (ValueError, IndexError): - +
@@ -801,7 +801,7 @@ 30 n = 10 - +
@@ -818,7 +818,7 @@ 31 p = primes() - +
@@ -835,7 +835,7 @@ 32 print "The first %d primes: %s" % (n, list(islice(p, n))) - +