mercurial/hgweb/common.py
changeset 4462 12e4d9524951
parent 4038 5ae460b1f6f0
child 5561 22713dce19f6
child 6122 800e2756c9ab
--- 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
+