hgweb: generate revnav in two phase
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Thu, 10 Jan 2013 19:29:48 +0100
changeset 18425 6da1e979340a
parent 18424 100fdc84670f
child 18426 01638b51df44
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.
mercurial/hgweb/webutil.py
--- 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"))