[PATCH 04 of 22 V2-Series-D] hgweb: move the `seq` closure into a dedicated function
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Mon Jan 14 14:35:36 CST 2013
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1357839775 -3600
# Node ID d37dda282ef4a22805c8c2e22bb7e5be5cfabbda
# Parent 5b869199ef7c34866bce802b43d1764b02e505ab
hgweb: move the `seq` closure into a dedicated function
There is not reason for it to be a closure. And this function could use a major
reworks.
diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -22,10 +22,21 @@ def up(p):
up = os.path.dirname(p)
if up == "/":
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
+
class revnav(object):
def __init__(self, nodefunc):
"""Navigation generation object
@@ -44,26 +55,16 @@ class revnav(object):
- a single element tuple
- containing a dictionary with a `before` and `after` key
- values are generator function taking arbitrary number of kwargs
- yield items are dictionnary with `label` and `node` key
"""
- 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:
break
last = f
More information about the Mercurial-devel
mailing list