[PATCH 08 of 22 V2-Series-D] hgweb: move hex creation into an object method
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Mon Jan 14 20:35:40 UTC 2013
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at 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.
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):
More information about the Mercurial-devel
mailing list