hgweb: generate revnav in two phase
We first generate revision to link. Then we dispatch them in before, after list.
This will help filtering of unknown revision.
--- a/mercurial/hgweb/webutil.py Thu Jan 17 00:35:01 2013 +0100
+++ b/mercurial/hgweb/webutil.py Thu Jan 10 19:29:48 2013 +0100
@@ -77,16 +77,22 @@
# empty repo
return ({'before': (), 'after': ()},)
- navbefore = [("(0)", self.hex(0))]
- navafter = []
-
+ targets = []
for f in _navseq(1, pagelen):
if f > limit:
break
- if pos + f < limit:
- navafter.append(("+%d" % f, self.hex(pos + f)))
- if pos - f >= 0:
- navbefore.insert(0, ("-%d" % f, self.hex(pos - f)))
+ targets.append(pos + f)
+ targets.append(pos - f)
+ targets.sort()
+
+ navbefore = [("(0)", self.hex(0))]
+ navafter = []
+ for rev in targets:
+ if pos < rev < limit:
+ navafter.append(("+%d" % f, self.hex(rev)))
+ if 0 < rev < pos:
+ navbefore.append(("-%d" % f, self.hex(rev)))
+
navafter.append(("tip", "tip"))