Mercurial > public > mercurial-scm > hg-stable
comparison 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 |
comparison
equal
deleted
inserted
replaced
18402:bfba6d954108 | 18403:bfaee31a83d2 |
---|---|
240 start = max(0, pos - revcount + 1) | 240 start = max(0, pos - revcount + 1) |
241 end = min(count, start + revcount) | 241 end = min(count, start + revcount) |
242 pos = end - 1 | 242 pos = end - 1 |
243 parity = paritygen(web.stripecount, offset=start - end) | 243 parity = paritygen(web.stripecount, offset=start - end) |
244 | 244 |
245 changenav = webutil.revnavgen(pos, revcount, count, web.repo.changectx) | 245 changenav = webutil.revnav().gen(pos, revcount, count, web.repo.changectx) |
246 | 246 |
247 return tmpl(shortlog and 'shortlog' or 'changelog', changenav=changenav, | 247 return tmpl(shortlog and 'shortlog' or 'changelog', changenav=changenav, |
248 node=ctx.hex(), rev=pos, changesets=count, | 248 node=ctx.hex(), rev=pos, changesets=count, |
249 entries=lambda **x: changelist(latestonly=False, **x), | 249 entries=lambda **x: changelist(latestonly=False, **x), |
250 latestentry=lambda **x: changelist(latestonly=True, **x), | 250 latestentry=lambda **x: changelist(latestonly=True, **x), |
770 "branches": webutil.nodebranchdict(repo, iterfctx)}) | 770 "branches": webutil.nodebranchdict(repo, iterfctx)}) |
771 for e in reversed(l): | 771 for e in reversed(l): |
772 yield e | 772 yield e |
773 | 773 |
774 nodefunc = lambda x: fctx.filectx(fileid=x) | 774 nodefunc = lambda x: fctx.filectx(fileid=x) |
775 nav = webutil.revnavgen(end - 1, revcount, count, nodefunc) | 775 nav = webutil.revnav().gen(end - 1, revcount, count, nodefunc) |
776 return tmpl("filelog", file=f, node=fctx.hex(), nav=nav, | 776 return tmpl("filelog", file=f, node=fctx.hex(), nav=nav, |
777 entries=lambda **x: entries(latestonly=False, **x), | 777 entries=lambda **x: entries(latestonly=False, **x), |
778 latestentry=lambda **x: entries(latestonly=True, **x), | 778 latestentry=lambda **x: entries(latestonly=True, **x), |
779 revcount=revcount, morevars=morevars, lessvars=lessvars) | 779 revcount=revcount, morevars=morevars, lessvars=lessvars) |
780 | 780 |
849 end = min(count, start + revcount) | 849 end = min(count, start + revcount) |
850 pos = end - 1 | 850 pos = end - 1 |
851 | 851 |
852 uprev = min(max(0, count - 1), rev + revcount) | 852 uprev = min(max(0, count - 1), rev + revcount) |
853 downrev = max(0, rev - revcount) | 853 downrev = max(0, rev - revcount) |
854 changenav = webutil.revnavgen(pos, revcount, count, web.repo.changectx) | 854 changenav = webutil.revnav().gen(pos, revcount, count, web.repo.changectx) |
855 | 855 |
856 dag = graphmod.dagwalker(web.repo, range(start, end)[::-1]) | 856 dag = graphmod.dagwalker(web.repo, range(start, end)[::-1]) |
857 tree = list(graphmod.colored(dag, web.repo)) | 857 tree = list(graphmod.colored(dag, web.repo)) |
858 | 858 |
859 def getcolumns(tree): | 859 def getcolumns(tree): |