--- a/mercurial/hgweb/webutil.py Thu Jan 10 18:54:50 2013 +0100
+++ b/mercurial/hgweb/webutil.py Mon Jan 14 16:30:06 2013 +0100
@@ -48,6 +48,14 @@
"""
self.nodefunc = nodefunc
+ def __nonzero__(self):
+ """return True if any revision to navigate over"""
+ try:
+ self.nodefunc(0)
+ return True
+ except error.RepoError:
+ return False
+
def hex(self, rev):
return self.nodefunc(rev).hex()
@@ -64,6 +72,9 @@
- values are generator functions taking arbitrary number of kwargs
- yield items are dictionaries with `label` and `node` keys
"""
+ if not self:
+ # empty repo
+ return ({'before': (), 'after': ()},)
navbefore = []
navafter = []
@@ -77,10 +88,7 @@
navbefore.insert(0, ("-%d" % f, self.hex(pos - f)))
navafter.append(("tip", "tip"))
- try:
- navbefore.insert(0, ("(0)", self.hex(0)))
- except error.RepoError:
- pass
+ navbefore.insert(0, ("(0)", self.hex(0)))
data = lambda i: {"label": i[0], "node": i[1]}
return ({'before': lambda **map: (data(i) for i in navbefore),