comparison mercurial/hgweb/webcommands.py @ 13597:38c9837b1f75 stable

hgweb: add separate page with bookmarks listing
author Alexander Solovyov <alexander@solovyov.net>
date Sat, 12 Mar 2011 11:20:03 +0100
parents 270f57d35525
children 5c18a0bca26f
comparison
equal deleted inserted replaced
13596:270f57d35525 13597:38c9837b1f75
19 # __all__ is populated with the allowed commands. Be sure to add to it if 19 # __all__ is populated with the allowed commands. Be sure to add to it if
20 # you're adding a new command, or the new command won't work. 20 # you're adding a new command, or the new command won't work.
21 21
22 __all__ = [ 22 __all__ = [
23 'log', 'rawfile', 'file', 'changelog', 'shortlog', 'changeset', 'rev', 23 'log', 'rawfile', 'file', 'changelog', 'shortlog', 'changeset', 'rev',
24 'manifest', 'tags', 'branches', 'summary', 'filediff', 'diff', 'annotate', 24 'manifest', 'tags', 'bookmarks', 'branches', 'summary', 'filediff', 'diff',
25 'filelog', 'archive', 'static', 'graph', 'help', 25 'annotate', 'filelog', 'archive', 'static', 'graph', 'help',
26 ] 26 ]
27 27
28 def log(web, req, tmpl): 28 def log(web, req, tmpl):
29 if 'file' in req.form and req.form['file'][0]: 29 if 'file' in req.form and req.form['file'][0]:
30 return filelog(web, req, tmpl) 30 return filelog(web, req, tmpl)
387 node=hex(web.repo.changelog.tip()), 387 node=hex(web.repo.changelog.tip()),
388 entries=lambda **x: entries(False, 0, **x), 388 entries=lambda **x: entries(False, 0, **x),
389 entriesnotip=lambda **x: entries(True, 0, **x), 389 entriesnotip=lambda **x: entries(True, 0, **x),
390 latestentry=lambda **x: entries(True, 1, **x)) 390 latestentry=lambda **x: entries(True, 1, **x))
391 391
392 def bookmarks(web, req, tmpl):
393 i = web.repo._bookmarks.items()
394 i.reverse()
395 parity = paritygen(web.stripecount)
396
397 def entries(notip=False, limit=0, **map):
398 count = 0
399 for k, n in i:
400 if notip and k == "tip":
401 continue
402 if limit > 0 and count >= limit:
403 continue
404 count = count + 1
405 yield {"parity": parity.next(),
406 "bookmark": k,
407 "date": web.repo[n].date(),
408 "node": hex(n)}
409
410 return tmpl("bookmarks",
411 node=hex(web.repo.changelog.tip()),
412 entries=lambda **x: entries(False, 0, **x),
413 entriesnotip=lambda **x: entries(True, 0, **x),
414 latestentry=lambda **x: entries(True, 1, **x))
415
392 def branches(web, req, tmpl): 416 def branches(web, req, tmpl):
393 tips = (web.repo[n] for t, n in web.repo.branchtags().iteritems()) 417 tips = (web.repo[n] for t, n in web.repo.branchtags().iteritems())
394 heads = web.repo.heads() 418 heads = web.repo.heads()
395 parity = paritygen(web.stripecount) 419 parity = paritygen(web.stripecount)
396 sortkey = lambda ctx: ('close' not in ctx.extra(), ctx.rev()) 420 sortkey = lambda ctx: ('close' not in ctx.extra(), ctx.rev())
724 desc = templatefilters.firstline(ctx.description()) 748 desc = templatefilters.firstline(ctx.description())
725 desc = cgi.escape(templatefilters.nonempty(desc)) 749 desc = cgi.escape(templatefilters.nonempty(desc))
726 user = cgi.escape(templatefilters.person(ctx.user())) 750 user = cgi.escape(templatefilters.person(ctx.user()))
727 branch = ctx.branch() 751 branch = ctx.branch()
728 branch = branch, web.repo.branchtags().get(branch) == ctx.node() 752 branch = branch, web.repo.branchtags().get(branch) == ctx.node()
729 data.append((node, vtx, edges, desc, user, age, branch, ctx.tags(), ctx.bookmarks())) 753 data.append((node, vtx, edges, desc, user, age, branch, ctx.tags(),
754 ctx.bookmarks()))
730 755
731 return tmpl('graph', rev=rev, revcount=revcount, uprev=uprev, 756 return tmpl('graph', rev=rev, revcount=revcount, uprev=uprev,
732 lessvars=lessvars, morevars=morevars, downrev=downrev, 757 lessvars=lessvars, morevars=morevars, downrev=downrev,
733 canvasheight=canvasheight, jsdata=data, bg_height=bg_height, 758 canvasheight=canvasheight, jsdata=data, bg_height=bg_height,
734 node=revnode_hex, changenav=changenav) 759 node=revnode_hex, changenav=changenav)