hgweb: avoid generator exhaustion with branches stable
authorMatt Mackall <mpm@selenic.com>
Thu, 06 Dec 2012 13:21:27 -0600
branchstable
changeset 18030 ebc0fa067c07
parent 18029 109a6a9dcca8
child 18037 c8326ffdcb4f
child 18064 7e2b9f6a2cd0
hgweb: avoid generator exhaustion with branches
mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py	Wed Dec 05 15:38:18 2012 -0600
+++ b/mercurial/hgweb/webcommands.py	Thu Dec 06 13:21:27 2012 -0600
@@ -437,13 +437,16 @@
                 latestentry=lambda **x: entries(1, **x))
 
 def branches(web, req, tmpl):
-    tips = (web.repo[n] for t, n in web.repo.branchtags().iteritems())
+    tips = []
     heads = web.repo.heads()
     parity = paritygen(web.stripecount)
     sortkey = lambda ctx: (not ctx.closesbranch(), ctx.rev())
 
     def entries(limit, **map):
         count = 0
+        if not tips:
+            for t, n in web.repo.branchtags().iteritems():
+                tips.append(web.repo[n])
         for ctx in sorted(tips, key=sortkey, reverse=True):
             if limit > 0 and count >= limit:
                 return