hgweb: move the `seq` function out of the revnavgen scope
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Tue, 15 Jan 2013 12:11:18 +0100
changeset 18389 82572533bc00
parent 18388 083daee1b749
child 18390 28fa9443f751
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.
mercurial/hgweb/webutil.py
--- 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: