[PATCH 13 of 23 Series-D] hgweb: move hex creation into an object method

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Jan 10 18:23:58 CST 2013


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1357840490 -3600
# Node ID ca473790efc20d18f38146f2a27d2730e5f4ed7a
# Parent  ff270287514b7197574f73c0dbcc8959e2119cf2
hgweb: move hex creation into an object method

This is clearer and allow later overwrite.

diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -46,10 +46,13 @@ class revnav(object):
 
         :nodefun: factory for a changectx from a revision
         """
         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
 
         :pos: is the revision relative to which we generate navigation.
         :pagelen: the since of each navigation pages
@@ -67,19 +70,17 @@ class revnav(object):
 
         for f in _navseq(1, pagelen):
             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
 
         def gen(l):
             def f(**map):


More information about the Mercurial-devel mailing list