changeset 18389:82572533bc00

hgweb: move the `seq` function out of the revnavgen scope There is not reason for it to be a in there. And this function could use a major reworks.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Tue, 15 Jan 2013 12:11:18 +0100
parents 083daee1b749
children 28fa9443f751
files mercurial/hgweb/webutil.py
diffstat 1 files changed, 12 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/webutil.py	Mon Jan 14 16:52:35 2013 +0100
+++ b/mercurial/hgweb/webutil.py	Tue Jan 15 12:11:18 2013 +0100
@@ -24,6 +24,17 @@
         return "/"
     return up + "/"
 
+def _navseq(factor, limit=None):
+    if limit:
+        yield limit
+        if limit >= 20 and limit <= 40:
+            yield 50
+    else:
+        yield 1 * factor
+        yield 3 * factor
+    for f in _navseq(factor * 10):
+        yield f
+
 def revnavgen(pos, pagelen, limit, nodefunc):
     """computes label and revision id for navigation link
 
@@ -38,22 +49,12 @@
         - values are generator functions taking an arbitrary number of kwargs
         - yield items are dictionaries with `label` and `node` keys
     """
-    def seq(factor, limit=None):
-        if limit:
-            yield limit
-            if limit >= 20 and limit <= 40:
-                yield 50
-        else:
-            yield 1 * factor
-            yield 3 * factor
-        for f in seq(factor * 10):
-            yield f
 
     navbefore = []
     navafter = []
 
     last = 0
-    for f in seq(1, pagelen):
+    for f in _navseq(1, pagelen):
         if f < pagelen or f <= last:
             continue
         if f > limit: