hgweb: fix empty navigation detection stable
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Tue, 30 Apr 2013 15:11:12 +0200
branchstable
changeset 19093 6f27efc7db23
parent 19092 8c560ad1cdc4
child 19094 fc1b77db123f
hgweb: fix empty navigation detection For some obscure reason, changelog.node(0) returns nullid if changelog is empty. this break empty navigation detection. We fix this code by using the length of the changelog. Using the length have some issue with revision filtering but this is a small step in the right direction. Proper fix comes in later changeset.
mercurial/hgweb/webutil.py
tests/test-hgweb-empty.t
--- a/mercurial/hgweb/webutil.py	Tue Apr 30 14:56:33 2013 +0100
+++ b/mercurial/hgweb/webutil.py	Tue Apr 30 15:11:12 2013 +0200
@@ -51,11 +51,7 @@
 
     def __nonzero__(self):
         """return True if any revision to navigate over"""
-        try:
-            self._revlog.node(0)
-            return True
-        except error.RepoError:
-            return False
+        return bool(len(self._revlog))
 
     def hex(self, rev):
         return hex(self._revlog.node(rev))
--- a/tests/test-hgweb-empty.t	Tue Apr 30 14:56:33 2013 +0100
+++ b/tests/test-hgweb-empty.t	Tue Apr 30 15:11:12 2013 +0200
@@ -70,7 +70,7 @@
   <div class="navigate">
   <a href="/shortlog/-1?revcount=30">less</a>
   <a href="/shortlog/-1?revcount=120">more</a>
-  | rev -1: <a href="/shortlog/000000000000">(0)</a> <a href="/shortlog/tip">tip</a> 
+  | rev -1: 
   </div>
   
   <table class="bigtable">
@@ -85,7 +85,7 @@
   <div class="navigate">
   <a href="/shortlog/-1?revcount=30">less</a>
   <a href="/shortlog/-1?revcount=120">more</a>
-  | rev -1: <a href="/shortlog/000000000000">(0)</a> <a href="/shortlog/tip">tip</a> 
+  | rev -1: 
   </div>
   
   </div>
@@ -97,6 +97,8 @@
   </body>
   </html>
   
+  $ echo babar
+  babar
   $ ("$TESTDIR/get-with-headers.py" localhost:$HGPORT 'log')
   200 Script output follows
   
@@ -161,7 +163,7 @@
   <div class="navigate">
   <a href="/shortlog/-1?revcount=5">less</a>
   <a href="/shortlog/-1?revcount=20">more</a>
-  | rev -1: <a href="/shortlog/000000000000">(0)</a> <a href="/shortlog/tip">tip</a> 
+  | rev -1: 
   </div>
   
   <table class="bigtable">
@@ -176,7 +178,7 @@
   <div class="navigate">
   <a href="/shortlog/-1?revcount=5">less</a>
   <a href="/shortlog/-1?revcount=20">more</a>
-  | rev -1: <a href="/shortlog/000000000000">(0)</a> <a href="/shortlog/tip">tip</a> 
+  | rev -1: 
   </div>
   
   </div>
@@ -250,7 +252,7 @@
   <div class="navigate">
   <a href="/graph/-1?revcount=30">less</a>
   <a href="/graph/-1?revcount=120">more</a>
-  | rev -1: <a href="/graph/000000000000">(0)</a> <a href="/graph/tip">tip</a> 
+  | rev -1: 
   </div>
   
   <noscript><p>The revision graph only works with JavaScript-enabled browsers.</p></noscript>
@@ -320,7 +322,7 @@
   <div class="navigate">
   <a href="/graph/-1?revcount=30">less</a>
   <a href="/graph/-1?revcount=120">more</a>
-  | rev -1: <a href="/graph/000000000000">(0)</a> <a href="/graph/tip">tip</a> 
+  | rev -1: 
   </div>
   
   </div>