fix changenav for maxchanges != 10
authorJohannes Stezenbach <js@linuxtv.org>
Mon, 06 Feb 2006 17:34:53 -0600
changeset 1703 41d884f741ca
parent 1702 e291d9a30bef
child 1704 c2755eba8631
fix changenav for maxchanges != 10 for maxchanges = 25 the changelog navigation had a minimum stepsize of 30; try to calculate more useful navigation steps
mercurial/hgweb.py
--- a/mercurial/hgweb.py	Mon Feb 06 17:34:39 2006 -0600
+++ b/mercurial/hgweb.py	Mon Feb 06 17:34:53 2006 -0600
@@ -298,19 +298,25 @@
 
     def changelog(self, pos):
         def changenav(**map):
-            def seq(factor=1):
-                yield 1 * factor
-                yield 3 * factor
-                #yield 5 * factor
+            def seq(factor, maxchanges=None):
+                if maxchanges:
+                    yield maxchanges
+                    if maxchanges >= 20 and maxchanges <= 40:
+                        yield 50
+                else:
+                    yield 1 * factor
+                    yield 3 * factor
                 for f in seq(factor * 10):
                     yield f
 
             l = []
-            for f in seq():
-                if f < self.maxchanges / 2:
+            last = 0
+            for f in seq(1, self.maxchanges):
+                if f < self.maxchanges or f <= last:
                     continue
                 if f > count:
                     break
+                last = f
                 r = "%d" % f
                 if pos + f < count:
                     l.append(("+" + r, pos + f))