hgweb: move hex creation into an object method
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Thu, 10 Jan 2013 18:54:50 +0100
changeset 18405 1eaf0d017b2c
parent 18404 1da84a6b136a
child 18406 20cf53932b6f
hgweb: move hex creation into an object method This is clearer and allow later overwrite.
mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py	Thu Jan 10 18:59:37 2013 +0100
+++ b/mercurial/hgweb/webutil.py	Thu Jan 10 18:54:50 2013 +0100
@@ -48,6 +48,9 @@
         """
         self.nodefunc = nodefunc
 
+    def hex(self, rev):
+        return self.nodefunc(rev).hex()
+
     def gen(self, pos, pagelen, limit):
         """computes label and revision id for navigation link
 
@@ -69,15 +72,13 @@
             if f > limit:
                 break
             if pos + f < limit:
-                navafter.append(("+%d" % f,
-                                 hex(self.nodefunc(pos + f).node())))
+                navafter.append(("+%d" % f, self.hex(pos + f)))
             if pos - f >= 0:
-                navbefore.insert(0, ("-%d" % f,
-                                     hex(self.nodefunc(pos - f).node())))
+                navbefore.insert(0, ("-%d" % f, self.hex(pos - f)))
 
         navafter.append(("tip", "tip"))
         try:
-            navbefore.insert(0, ("(0)", hex(self.nodefunc(0).node())))
+            navbefore.insert(0, ("(0)", self.hex(0)))
         except error.RepoError:
             pass