comparison mercurial/hgweb/webcommands.py @ 8354:418ea63f00fb

hgweb: use context api in branches webcommand
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Tue, 12 May 2009 10:23:45 +0200
parents eefcb59d44d6
children beae42f3d93b
comparison
equal deleted inserted replaced
8353:6058d291abdf 8354:418ea63f00fb
358 entriesnotip=lambda **x: entries(True,0, **x), 358 entriesnotip=lambda **x: entries(True,0, **x),
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 l = [(-web.repo.changelog.rev(n), n, t) for t, n in b.iteritems()] 363 tips = (web.repo[n] for t, n in web.repo.branchtags().iteritems())
364 parity = paritygen(web.stripecount) 364 parity = paritygen(web.stripecount)
365 365
366 def entries(limit, **map): 366 def entries(limit, **map):
367 count = 0 367 count = 0
368 for r, n, t in sorted(l): 368 for ctx in sorted(tips, key=lambda x: x.rev(), reverse=True):
369 if limit > 0 and count >= limit: 369 if limit > 0 and count >= limit:
370 return 370 return
371 count += 1 371 count += 1
372 yield {'parity': parity.next(), 372 yield {'parity': parity.next(),
373 'branch': t, 373 'branch': ctx.branch(),
374 'node': hex(n), 374 'node': ctx.hex(),
375 'date': web.repo[n].date()} 375 'date': ctx.date()}
376 376
377 return tmpl('branches', node=hex(web.repo.changelog.tip()), 377 return tmpl('branches', node=hex(web.repo.changelog.tip()),
378 entries=lambda **x: entries(0, **x), 378 entries=lambda **x: entries(0, **x),
379 latestentry=lambda **x: entries(1, **x)) 379 latestentry=lambda **x: entries(1, **x))
380 380