Mercurial > hg
changeset 18425:6da1e979340a
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.
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Thu, 10 Jan 2013 19:29:48 +0100 |
parents | 100fdc84670f |
children | 01638b51df44 |
files | mercurial/hgweb/webutil.py |
diffstat | 1 files changed, 13 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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"))