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