Mercurial > public > mercurial-scm > hg-stable
diff mercurial/hgweb/webutil.py @ 18404:1da84a6b136a
hgweb: pass nodefunc to the revnav object
The issue between hgweb and filtering lay in this function. Moving it into the
object itself helps to abstract the erroneous bit.
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Thu, 10 Jan 2013 18:59:37 +0100 |
parents | bfaee31a83d2 |
children | 1eaf0d017b2c |
line wrap: on
line diff
--- a/mercurial/hgweb/webutil.py Tue Jan 15 21:17:18 2013 +0100 +++ b/mercurial/hgweb/webutil.py Thu Jan 10 18:59:37 2013 +0100 @@ -41,13 +41,19 @@ class revnav(object): - def gen(self, pos, pagelen, limit, nodefunc): + def __init__(self, nodefunc): + """Navigation generation object + + :nodefun: factory for a changectx from a revision + """ + self.nodefunc = nodefunc + + def gen(self, pos, pagelen, limit): """computes label and revision id for navigation link :pos: is the revision relative to which we generate navigation. :pagelen: the size of each navigation page :limit: how far shall we link - :nodefun: factory for a changectx from a revision The return is: - a single element tuple @@ -63,13 +69,15 @@ if f > limit: break if pos + f < limit: - navafter.append(("+%d" % f, hex(nodefunc(pos + f).node()))) + navafter.append(("+%d" % f, + hex(self.nodefunc(pos + f).node()))) if pos - f >= 0: - navbefore.insert(0, ("-%d" % f, hex(nodefunc(pos - f).node()))) + navbefore.insert(0, ("-%d" % f, + hex(self.nodefunc(pos - f).node()))) navafter.append(("tip", "tip")) try: - navbefore.insert(0, ("(0)", hex(nodefunc(0).node()))) + navbefore.insert(0, ("(0)", hex(self.nodefunc(0).node()))) except error.RepoError: pass