diff mercurial/hgweb/webcommands.py @ 18403:bfaee31a83d2

hgweb: move revnavgen into an object For later compatibility with changelog filtering some part of the navigation generation logic will be altered. Those altered part will be different when in the changelog case and in the filelog case. Moving this into an object will allow to use inheritance to override just the part of the logic we need. The aimed logic are for example: - generation of revision 'hex' (different logic for changelog and filelog) - revlog emptyness test - fetching of the first revision of a revlog (may not be 0)
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Tue, 15 Jan 2013 21:17:18 +0100
parents bfba6d954108
children 1da84a6b136a
line wrap: on
line diff
--- a/mercurial/hgweb/webcommands.py	Wed Jan 16 12:51:24 2013 +0100
+++ b/mercurial/hgweb/webcommands.py	Tue Jan 15 21:17:18 2013 +0100
@@ -242,7 +242,7 @@
     pos = end - 1
     parity = paritygen(web.stripecount, offset=start - end)
 
-    changenav = webutil.revnavgen(pos, revcount, count, web.repo.changectx)
+    changenav = webutil.revnav().gen(pos, revcount, count, web.repo.changectx)
 
     return tmpl(shortlog and 'shortlog' or 'changelog', changenav=changenav,
                 node=ctx.hex(), rev=pos, changesets=count,
@@ -772,7 +772,7 @@
             yield e
 
     nodefunc = lambda x: fctx.filectx(fileid=x)
-    nav = webutil.revnavgen(end - 1, revcount, count, nodefunc)
+    nav = webutil.revnav().gen(end - 1, revcount, count, nodefunc)
     return tmpl("filelog", file=f, node=fctx.hex(), nav=nav,
                 entries=lambda **x: entries(latestonly=False, **x),
                 latestentry=lambda **x: entries(latestonly=True, **x),
@@ -851,7 +851,7 @@
 
     uprev = min(max(0, count - 1), rev + revcount)
     downrev = max(0, rev - revcount)
-    changenav = webutil.revnavgen(pos, revcount, count, web.repo.changectx)
+    changenav = webutil.revnav().gen(pos, revcount, count, web.repo.changectx)
 
     dag = graphmod.dagwalker(web.repo, range(start, end)[::-1])
     tree = list(graphmod.colored(dag, web.repo))