##// END OF EJS Templates
hgweb: pass repo object to revnav construction...
Pierre-Yves David -
r18409:e3f5cef1 default
parent child Browse files
Show More
@@ -242,7 +242,7 b' def changelog(web, req, tmpl, shortlog=F'
242 242 pos = end - 1
243 243 parity = paritygen(web.stripecount, offset=start - end)
244 244
245 changenav = webutil.revnav(web.repo.changectx).gen(pos, revcount, count)
245 changenav = webutil.revnav(web.repo).gen(pos, revcount, count)
246 246
247 247 return tmpl(shortlog and 'shortlog' or 'changelog', changenav=changenav,
248 248 node=ctx.hex(), rev=pos, changesets=count,
@@ -771,8 +771,8 b' def filelog(web, req, tmpl):'
771 771 for e in reversed(l):
772 772 yield e
773 773
774 nodefunc = lambda x: fctx.filectx(fileid=x)
775 nav = webutil.filerevnav(nodefunc).gen(end - 1, revcount, count)
774 revnav = webutil.filerevnav(web.repo, fctx.path())
775 nav = revnav.gen(end - 1, revcount, count)
776 776 return tmpl("filelog", file=f, node=fctx.hex(), nav=nav,
777 777 entries=lambda **x: entries(latestonly=False, **x),
778 778 latestentry=lambda **x: entries(latestonly=True, **x),
@@ -851,7 +851,7 b' def graph(web, req, tmpl):'
851 851
852 852 uprev = min(max(0, count - 1), rev + revcount)
853 853 downrev = max(0, rev - revcount)
854 changenav = webutil.revnav(web.repo.changectx).gen(pos, revcount, count)
854 changenav = webutil.revnav(web.repo).gen(pos, revcount, count)
855 855
856 856 dag = graphmod.dagwalker(web.repo, range(start, end)[::-1])
857 857 tree = list(graphmod.colored(dag, web.repo))
@@ -41,23 +41,24 b' def _navseq(step, firststep=None):'
41 41
42 42 class revnav(object):
43 43
44 def __init__(self, nodefunc):
44 def __init__(self, repo):
45 45 """Navigation generation object
46 46
47 :nodefun: factory for a changectx from a revision
47 :repo: repo object we generate nav for
48 48 """
49 self.nodefunc = nodefunc
49 # used for hex generation
50 self._revlog = repo.changelog
50 51
51 52 def __nonzero__(self):
52 53 """return True if any revision to navigate over"""
53 54 try:
54 self.nodefunc(0)
55 self._revlog.node(0)
55 56 return True
56 57 except error.RepoError:
57 58 return False
58 59
59 60 def hex(self, rev):
60 return self.nodefunc(rev).hex()
61 return hex(self._revlog.node(rev))
61 62
62 63 def gen(self, pos, pagelen, limit):
63 64 """computes label and revision id for navigation link
@@ -94,7 +95,21 b' class revnav(object):'
94 95 'after': lambda **map: (data(i) for i in navafter)},)
95 96
96 97 class filerevnav(revnav):
97 pass
98
99 def __init__(self, repo, path):
100 """Navigation generation object
101
102 :repo: repo object we generate nav for
103 :path: path of the file we generate nav for
104 """
105 # used for iteration
106 self._changelog = repo.unfiltered().changelog
107 # used for hex generation
108 self._revlog = repo.file(path)
109
110 def hex(self, rev):
111 return hex(self._changelog.node(self._revlog.linkrev(rev)))
112
98 113
99 114 def _siblings(siblings=[], hiderev=None):
100 115 siblings = [s for s in siblings if s.node() != nullid]
General Comments 0
You need to be logged in to leave comments. Login now