Mercurial > public > mercurial-scm > hg-stable
diff mercurial/hgweb/common.py @ 4462:12e4d9524951
hgweb: use generator to count parity of horizontal stripes for easier reading.
- use web.stripes in all places and consistently
- start with parity0 for lists generated in reverse (e.g. changelog)
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Tue, 29 May 2007 16:42:05 +0200 |
parents | 5ae460b1f6f0 |
children | 22713dce19f6 800e2756c9ab |
line wrap: on
line diff
--- a/mercurial/hgweb/common.py Tue May 29 07:00:36 2007 -0400 +++ b/mercurial/hgweb/common.py Tue May 29 16:42:05 2007 +0200 @@ -60,3 +60,19 @@ return mapfile raise RuntimeError("No hgweb templates found in %r" % templatepath) +def paritygen(stripecount, offset=0): + """count parity of horizontal stripes for easier reading""" + if stripecount and offset: + # account for offset, e.g. due to building the list in reverse + count = (stripecount + offset) % stripecount + parity = (stripecount + offset) / stripecount & 1 + else: + count = 0 + parity = 0 + while True: + yield parity + count += 1 + if stripecount and count >= stripecount: + parity = 1 - parity + count = 0 +