Patchwork [07,of,22,V2-Series-D] hgweb: ensure _navseq yield strictly increasing numbers

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 14, 2013, 8:35 p.m.
Message ID <92e5ff8ba661fb429b2e.1358195739@yamac.lan>
Download mbox | patch
Permalink /patch/603/
State Accepted
Commit 88a37b19dc0e482b7d6aec386c593a6fae370b96
Headers show

Comments

Pierre-Yves David - Jan. 14, 2013, 8:35 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1357840337 -3600
# Node ID 92e5ff8ba661fb429b2eb324de249b51bc2fbed7
# Parent  705e6db663644c4193c58fe495539bf53a0794ee
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,