Patchwork [12,of,23,Series-D] hgweb: ensure _navseq yield strictly increasing numbers

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 11, 2013, 12:23 a.m.
Message ID <ff270287514b7197574f.1357863837@yamac.lan>
Download mbox | patch
Permalink /patch/537/
State Superseded
Headers show

Comments

Pierre-Yves David - Jan. 11, 2013, 12:23 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1357840337 -3600
# Node ID ff270287514b7197574f73c0dbcc8959e2119cf2
# Parent  a9fcb87655e2784adc045e781c0efa785f185e34
hgweb: ensure _navseq yield strictly increasing numbers

This is not hard and allows to drop hack in the customer code.

Patch

diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -26,12 +26,16 @@  def up(p):
 
 def _navseq(step, firststep=None):
     if firststep:
         yield firststep
         if firststep >= 20 and firststep <= 40:
-            yield 50
-        step *= 10
+            firststep = 50
+            yield firststep
+        assert step > 0
+        assert firststep > 0
+        while step <= firststep:
+            step *= 10
     while True:
         yield 1 * step
         yield 3 * step
         step *= 10
 
@@ -59,17 +63,13 @@  class revnav(object):
         """
 
         navbefore = []
         navafter = []
 
-        last = 0
         for f in _navseq(1, pagelen):
-            if f < pagelen or f <= last:
-                continue
             if f > limit:
                 break
-            last = f
             if pos + f < limit:
                 navafter.append(("+%d" % f,
                                  hex(self.nodefunc(pos + f).node())))
             if pos - f >= 0:
                 navbefore.insert(0, ("-%d" % f,