Patchwork [08,of,22,V2-Series-D] hgweb: move hex creation into an object method

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 14, 2013, 8:35 p.m.
Message ID <0c0c858fb41574fb4c3c.1358195740@yamac.lan>
Download mbox | patch
Permalink /patch/604/
State Superseded
Commit 1eaf0d017b2cb9c9b09247ef3c4bb3af7938734f
Headers show

Comments

Pierre-Yves David - Jan. 14, 2013, 8:35 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1357840490 -3600
# Node ID 0c0c858fb41574fb4c3c34080d2719aa5023df4c
# Parent  92e5ff8ba661fb429b2eb324de249b51bc2fbed7
hgweb: move hex creation into an object method

This is clearer and allow later overwrite.

Patch

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 size 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):