Mercurial > public > mercurial-scm > hg
diff 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 |
line wrap: on
line diff
--- a/mercurial/hgweb/webcommands.py Sat Mar 12 11:19:44 2011 +0100 +++ b/mercurial/hgweb/webcommands.py Sat Mar 12 11:20:03 2011 +0100 @@ -21,8 +21,8 @@ __all__ = [ 'log', 'rawfile', 'file', 'changelog', 'shortlog', 'changeset', 'rev', - 'manifest', 'tags', 'branches', 'summary', 'filediff', 'diff', 'annotate', - 'filelog', 'archive', 'static', 'graph', 'help', + 'manifest', 'tags', 'bookmarks', 'branches', 'summary', 'filediff', 'diff', + 'annotate', 'filelog', 'archive', 'static', 'graph', 'help', ] def log(web, req, tmpl): @@ -389,6 +389,30 @@ entriesnotip=lambda **x: entries(True, 0, **x), latestentry=lambda **x: entries(True, 1, **x)) +def bookmarks(web, req, tmpl): + i = web.repo._bookmarks.items() + i.reverse() + parity = paritygen(web.stripecount) + + def entries(notip=False, limit=0, **map): + count = 0 + for k, n in i: + if notip and k == "tip": + continue + if limit > 0 and count >= limit: + continue + count = count + 1 + yield {"parity": parity.next(), + "bookmark": k, + "date": web.repo[n].date(), + "node": hex(n)} + + return tmpl("bookmarks", + node=hex(web.repo.changelog.tip()), + entries=lambda **x: entries(False, 0, **x), + entriesnotip=lambda **x: entries(True, 0, **x), + latestentry=lambda **x: entries(True, 1, **x)) + def branches(web, req, tmpl): tips = (web.repo[n] for t, n in web.repo.branchtags().iteritems()) heads = web.repo.heads() @@ -726,7 +750,8 @@ user = cgi.escape(templatefilters.person(ctx.user())) branch = ctx.branch() branch = branch, web.repo.branchtags().get(branch) == ctx.node() - data.append((node, vtx, edges, desc, user, age, branch, ctx.tags(), ctx.bookmarks())) + data.append((node, vtx, edges, desc, user, age, branch, ctx.tags(), + ctx.bookmarks())) return tmpl('graph', rev=rev, revcount=revcount, uprev=uprev, lessvars=lessvars, morevars=morevars, downrev=downrev,