Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/webcommands.py @ 20194:9985e188d940
hgweb: simplify branches with repo.branchmap().iterbranches()
author | Brodie Rao <brodie@sf.io> |
---|---|
date | Mon, 16 Sep 2013 01:08:29 -0700 |
parents | 7d40e706412c |
children | a6cf48b2880d |
comparison
equal
deleted
inserted
replaced
20193:7d40e706412c | 20194:9985e188d940 |
---|---|
535 | 535 |
536 def branches(web, req, tmpl): | 536 def branches(web, req, tmpl): |
537 tips = [] | 537 tips = [] |
538 heads = web.repo.heads() | 538 heads = web.repo.heads() |
539 parity = paritygen(web.stripecount) | 539 parity = paritygen(web.stripecount) |
540 sortkey = lambda ctx: (not ctx.closesbranch(), ctx.rev()) | 540 sortkey = lambda item: (not item[1], item[0].rev()) |
541 | 541 |
542 def entries(limit, **map): | 542 def entries(limit, **map): |
543 count = 0 | 543 count = 0 |
544 if not tips: | 544 if not tips: |
545 for t, n in web.repo.branchtags().iteritems(): | 545 for tag, hs, tip, closed in web.repo.branchmap().iterbranches(): |
546 tips.append(web.repo[n]) | 546 tips.append((web.repo[tip], closed)) |
547 for ctx in sorted(tips, key=sortkey, reverse=True): | 547 for ctx, closed in sorted(tips, key=sortkey, reverse=True): |
548 if limit > 0 and count >= limit: | 548 if limit > 0 and count >= limit: |
549 return | 549 return |
550 count += 1 | 550 count += 1 |
551 if not web.repo.branchheads(ctx.branch()): | 551 if closed: |
552 status = 'closed' | 552 status = 'closed' |
553 elif ctx.node() not in heads: | 553 elif ctx.node() not in heads: |
554 status = 'inactive' | 554 status = 'inactive' |
555 else: | 555 else: |
556 status = 'open' | 556 status = 'open' |