changeset 18030:ebc0fa067c07 stable

hgweb: avoid generator exhaustion with branches
author Matt Mackall <mpm@selenic.com>
date Thu, 06 Dec 2012 13:21:27 -0600
parents 109a6a9dcca8
children c8326ffdcb4f 7e2b9f6a2cd0
files mercurial/hgweb/webcommands.py
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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