Patchwork [11,of,12] hgweb: simplify branches with repo.branchmap().iterbranches()

login
register
mail settings
Submitter Brodie Rao
Date Nov. 16, 2013, 2:27 a.m.
Message ID <b1295f027f812d0a130e.1384568863@hit-nxdomain.opendns.com>
Download mbox | patch
Permalink /patch/2969/
State Superseded
Headers show

Comments

Brodie Rao - Nov. 16, 2013, 2:27 a.m.
# HG changeset patch
# User Brodie Rao <brodie@sf.io>
# Date 1379318909 25200
#      Mon Sep 16 01:08:29 2013 -0700
# Node ID b1295f027f812d0a130e86ced0273014a83ebde5
# Parent  0cc37ae6a1060456c0787d16ef2ee3fc9be5a90b
hgweb: simplify branches with repo.branchmap().iterbranches()

Patch

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -531,18 +531,18 @@  def branches(web, req, tmpl):
     tips = []
     heads = web.repo.heads()
     parity = paritygen(web.stripecount)
-    sortkey = lambda ctx: (not ctx.closesbranch(), ctx.rev())
+    sortkey = lambda item: (not item[1], item[0].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):
+            for tag, hs, tip, closed in web.repo.branchmap().iterbranches():
+                tips.append((web.repo[tip], closed))
+        for ctx, closed in sorted(tips, key=sortkey, reverse=True):
             if limit > 0 and count >= limit:
                 return
             count += 1
-            if not web.repo.branchheads(ctx.branch()):
+            if closed:
                 status = 'closed'
             elif ctx.node() not in heads:
                 status = 'inactive'