mercurial/hgweb/webutil.py
changeset 18409 e3f5cef11d6a
parent 18408 f332a64fef51
child 18425 6da1e979340a
--- a/mercurial/hgweb/webutil.py	Mon Jan 14 16:55:48 2013 +0100
+++ b/mercurial/hgweb/webutil.py	Wed Jan 16 13:18:22 2013 +0100
@@ -41,23 +41,24 @@
 
 class revnav(object):
 
-    def __init__(self, nodefunc):
+    def __init__(self, repo):
         """Navigation generation object
 
-        :nodefun: factory for a changectx from a revision
+        :repo: repo object we generate nav for
         """
-        self.nodefunc = nodefunc
+        # used for hex generation
+        self._revlog = repo.changelog
 
     def __nonzero__(self):
         """return True if any revision to navigate over"""
         try:
-            self.nodefunc(0)
+            self._revlog.node(0)
             return True
         except error.RepoError:
             return False
 
     def hex(self, rev):
-        return self.nodefunc(rev).hex()
+        return hex(self._revlog.node(rev))
 
     def gen(self, pos, pagelen, limit):
         """computes label and revision id for navigation link
@@ -94,7 +95,21 @@
                  'after':  lambda **map: (data(i) for i in navafter)},)
 
 class filerevnav(revnav):
-    pass
+
+    def __init__(self, repo, path):
+        """Navigation generation object
+
+        :repo: repo object we generate nav for
+        :path: path of the file we generate nav for
+        """
+        # used for iteration
+        self._changelog = repo.unfiltered().changelog
+        # used for hex generation
+        self._revlog = repo.file(path)
+
+    def hex(self, rev):
+        return hex(self._changelog.node(self._revlog.linkrev(rev)))
+
 
 def _siblings(siblings=[], hiderev=None):
     siblings = [s for s in siblings if s.node() != nullid]