mercurial/hgweb/webcommands.py
changeset 8713 de6bb29e208a
parent 8390 beae42f3d93b
child 8796 2bcef677a6c3
equal deleted inserted replaced
8712:dd3ebf81af43 8713:de6bb29e208a
   359                 latestentry=lambda **x: entries(True,1, **x))
   359                 latestentry=lambda **x: entries(True,1, **x))
   360 
   360 
   361 def branches(web, req, tmpl):
   361 def branches(web, req, tmpl):
   362     b = web.repo.branchtags()
   362     b = web.repo.branchtags()
   363     tips = (web.repo[n] for t, n in web.repo.branchtags().iteritems())
   363     tips = (web.repo[n] for t, n in web.repo.branchtags().iteritems())
   364     parity = paritygen(web.stripecount)
   364     open = set(web.repo[n].branch() for n in web.repo.heads(closed=False))
       
   365     parity = paritygen(web.stripecount)
       
   366     sortkey = lambda ctx: ('close' not in ctx.extra(), ctx.rev())
   365 
   367 
   366     def entries(limit, **map):
   368     def entries(limit, **map):
   367         count = 0
   369         count = 0
   368         for ctx in sorted(tips, key=lambda x: x.rev(), reverse=True):
   370         for ctx in sorted(tips, key=sortkey, reverse=True):
   369             if limit > 0 and count >= limit:
   371             if limit > 0 and count >= limit:
   370                 return
   372                 return
   371             count += 1
   373             count += 1
       
   374             status = ctx.branch() in open and 'open' or 'closed'
   372             yield {'parity': parity.next(),
   375             yield {'parity': parity.next(),
   373                    'branch': ctx.branch(),
   376                    'branch': ctx.branch(),
       
   377                    'status': status,
   374                    'node': ctx.hex(),
   378                    'node': ctx.hex(),
   375                    'date': ctx.date()}
   379                    'date': ctx.date()}
   376 
   380 
   377     return tmpl('branches', node=hex(web.repo.changelog.tip()),
   381     return tmpl('branches', node=hex(web.repo.changelog.tip()),
   378                 entries=lambda **x: entries(0, **x),
   382                 entries=lambda **x: entries(0, **x),