Mercurial > hg
changeset 10246:b9d02695bde4
hgweb: add less/more links to shortlog/filelog nav
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Thu, 14 Jan 2010 16:28:21 +0100 |
parents | 207b94f6b65d |
children | e8c7410371e0 |
files | mercurial/hgweb/webcommands.py mercurial/templates/paper/filelog.tmpl mercurial/templates/paper/shortlog.tmpl tests/test-hgweb-commands.out tests/test-hgweb-empty.out tests/test-hgweb-filelog.out |
diffstat | 6 files changed, 126 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hgweb/webcommands.py Thu Jan 14 16:07:34 2010 +0100 +++ b/mercurial/hgweb/webcommands.py Thu Jan 14 16:28:21 2010 +0100 @@ -200,24 +200,32 @@ for e in l: yield e - maxchanges = shortlog and web.maxshortchanges or web.maxchanges + revcount = shortlog and web.maxshortchanges or web.maxchanges + if 'revcount' in req.form: + revcount = int(req.form.get('revcount', [revcount])[0]) + tmpl.defaults['sessionvars']['revcount'] = revcount + + lessvars = copy.copy(tmpl.defaults['sessionvars']) + lessvars['revcount'] = revcount / 2 + morevars = copy.copy(tmpl.defaults['sessionvars']) + morevars['revcount'] = revcount * 2 + cl = web.repo.changelog count = len(cl) pos = ctx.rev() - start = max(0, pos - maxchanges + 1) - end = min(count, start + maxchanges) + start = max(0, pos - revcount + 1) + end = min(count, start + revcount) pos = end - 1 parity = paritygen(web.stripecount, offset=start-end) - changenav = webutil.revnavgen(pos, maxchanges, count, web.repo.changectx) + changenav = webutil.revnavgen(pos, revcount, count, web.repo.changectx) - return tmpl(shortlog and 'shortlog' or 'changelog', - changenav=changenav, - node=hex(ctx.node()), - rev=pos, changesets=count, + return tmpl(shortlog and 'shortlog' or 'changelog', changenav=changenav, + node=hex(ctx.node()), rev=pos, changesets=count, entries=lambda **x: changelist(limit=0,**x), latestentry=lambda **x: changelist(limit=1,**x), - archives=web.archivelist("tip")) + archives=web.archivelist("tip"), revcount=revcount, + morevars=morevars, lessvars=lessvars) def shortlog(web, req, tmpl): return changelog(web, req, tmpl, shortlog = True) @@ -567,10 +575,19 @@ frev -= 1 fctx = web.repo.filectx(f, fl.linkrev(frev)) + revcount = web.maxshortchanges + if 'revcount' in req.form: + revcount = int(req.form.get('revcount', [revcount])[0]) + tmpl.defaults['sessionvars']['revcount'] = revcount + + lessvars = copy.copy(tmpl.defaults['sessionvars']) + lessvars['revcount'] = revcount / 2 + morevars = copy.copy(tmpl.defaults['sessionvars']) + morevars['revcount'] = revcount * 2 + count = fctx.filerev() + 1 - pagelen = web.maxshortchanges - start = max(0, fctx.filerev() - pagelen + 1) # first rev on this page - end = min(count, start + pagelen) # last rev on this page + start = max(0, fctx.filerev() - revcount + 1) # first rev on this page + end = min(count, start + revcount) # last rev on this page parity = paritygen(web.stripecount, offset=start-end) def entries(limit=0, **map): @@ -602,11 +619,11 @@ yield e nodefunc = lambda x: fctx.filectx(fileid=x) - nav = webutil.revnavgen(end - 1, pagelen, count, nodefunc) + nav = webutil.revnavgen(end - 1, revcount, count, nodefunc) return tmpl("filelog", file=f, node=hex(fctx.node()), nav=nav, entries=lambda **x: entries(limit=0, **x), - latestentry=lambda **x: entries(limit=1, **x)) - + latestentry=lambda **x: entries(limit=1, **x), + revcount=revcount, morevars=morevars, lessvars=lessvars) def archive(web, req, tmpl): type_ = req.form.get('type', [None])[0]
--- a/mercurial/templates/paper/filelog.tmpl Thu Jan 14 16:07:34 2010 +0100 +++ b/mercurial/templates/paper/filelog.tmpl Thu Jan 14 16:28:21 2010 +0100 @@ -43,7 +43,10 @@ files, or words in the commit message</div> </form> -<div class="navigate">{nav%filenaventry}</div> +<div class="navigate"> +<a href="{url}log/{node|short}/{file|urlescape}{lessvars%urlparameter}">less</a> +<a href="{url}log/{node|short}/{file|urlescape}{morevars%urlparameter}">more</a> +| {nav%filenaventry}</div> <table class="bigtable"> <tr> @@ -54,6 +57,12 @@ {entries%filelogentry} </table> +<div class="navigate"> +<a href="{url}log/{node|short}/{file|urlescape}{lessvars%urlparameter}">less</a> +<a href="{url}log/{node|short}/{file|urlescape}{morevars%urlparameter}">more</a> +| {nav%filenaventry} +</div> + </div> </div>
--- a/mercurial/templates/paper/shortlog.tmpl Thu Jan 14 16:07:34 2010 +0100 +++ b/mercurial/templates/paper/shortlog.tmpl Thu Jan 14 16:28:21 2010 +0100 @@ -39,7 +39,11 @@ files, or words in the commit message</div> </form> -<div class="navigate">rev {rev}: {changenav%navshortentry}</div> +<div class="navigate"> +<a href="{url}shortlog/{rev}{lessvars%urlparameter}">less</a> +<a href="{url}shortlog/{rev}{morevars%urlparameter}">more</a> +| rev {rev}: {changenav%navshortentry} +</div> <table class="bigtable"> <tr> @@ -50,7 +54,12 @@ {entries%shortlogentry} </table> -<div class="navigate">rev {rev}: {changenav%navshortentry}</div> +<div class="navigate"> +<a href="{url}shortlog/{rev}{lessvars%urlparameter}">less</a> +<a href="{url}shortlog/{rev}{morevars%urlparameter}">more</a> +| rev {rev}: {changenav%navshortentry} +</div> + </div> </div>
--- a/tests/test-hgweb-commands.out Thu Jan 14 16:07:34 2010 +0100 +++ b/tests/test-hgweb-commands.out Thu Jan 14 16:28:21 2010 +0100 @@ -201,7 +201,11 @@ files, or words in the commit message</div> </form> -<div class="navigate">rev 2: <a href="/shortlog/2ef0ac749a14">(0)</a> <a href="/shortlog/tip">tip</a> </div> +<div class="navigate"> +<a href="/shortlog/2?revcount=30">less</a> +<a href="/shortlog/2?revcount=120">more</a> +| rev 2: <a href="/shortlog/2ef0ac749a14">(0)</a> <a href="/shortlog/tip">tip</a> +</div> <table class="bigtable"> <tr> @@ -227,7 +231,12 @@ </table> -<div class="navigate">rev 2: <a href="/shortlog/2ef0ac749a14">(0)</a> <a href="/shortlog/tip">tip</a> </div> +<div class="navigate"> +<a href="/shortlog/2?revcount=30">less</a> +<a href="/shortlog/2?revcount=120">more</a> +| rev 2: <a href="/shortlog/2ef0ac749a14">(0)</a> <a href="/shortlog/tip">tip</a> +</div> + </div> </div>
--- a/tests/test-hgweb-empty.out Thu Jan 14 16:07:34 2010 +0100 +++ b/tests/test-hgweb-empty.out Thu Jan 14 16:28:21 2010 +0100 @@ -47,7 +47,11 @@ files, or words in the commit message</div> </form> -<div class="navigate">rev -1: <a href="/shortlog/000000000000">(0)</a> <a href="/shortlog/tip">tip</a> </div> +<div class="navigate"> +<a href="/shortlog/-1?revcount=30">less</a> +<a href="/shortlog/-1?revcount=120">more</a> +| rev -1: <a href="/shortlog/000000000000">(0)</a> <a href="/shortlog/tip">tip</a> +</div> <table class="bigtable"> <tr> @@ -58,7 +62,12 @@ </table> -<div class="navigate">rev -1: <a href="/shortlog/000000000000">(0)</a> <a href="/shortlog/tip">tip</a> </div> +<div class="navigate"> +<a href="/shortlog/-1?revcount=30">less</a> +<a href="/shortlog/-1?revcount=120">more</a> +| rev -1: <a href="/shortlog/000000000000">(0)</a> <a href="/shortlog/tip">tip</a> +</div> + </div> </div> @@ -116,7 +125,11 @@ files, or words in the commit message</div> </form> -<div class="navigate">rev -1: <a href="/shortlog/000000000000">(0)</a> <a href="/shortlog/tip">tip</a> </div> +<div class="navigate"> +<a href="/shortlog/-1?revcount=5">less</a> +<a href="/shortlog/-1?revcount=20">more</a> +| rev -1: <a href="/shortlog/000000000000">(0)</a> <a href="/shortlog/tip">tip</a> +</div> <table class="bigtable"> <tr> @@ -127,7 +140,12 @@ </table> -<div class="navigate">rev -1: <a href="/shortlog/000000000000">(0)</a> <a href="/shortlog/tip">tip</a> </div> +<div class="navigate"> +<a href="/shortlog/-1?revcount=5">less</a> +<a href="/shortlog/-1?revcount=20">more</a> +| rev -1: <a href="/shortlog/000000000000">(0)</a> <a href="/shortlog/tip">tip</a> +</div> + </div> </div>
--- a/tests/test-hgweb-filelog.out Thu Jan 14 16:07:34 2010 +0100 +++ b/tests/test-hgweb-filelog.out Thu Jan 14 16:28:21 2010 +0100 @@ -139,7 +139,10 @@ files, or words in the commit message</div> </form> -<div class="navigate"><a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a> </div> +<div class="navigate"> +<a href="/log/01de2d66a28d/a?revcount=30">less</a> +<a href="/log/01de2d66a28d/a?revcount=120">more</a> +| <a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a> </div> <table class="bigtable"> <tr> @@ -160,6 +163,12 @@ </table> +<div class="navigate"> +<a href="/log/01de2d66a28d/a?revcount=30">less</a> +<a href="/log/01de2d66a28d/a?revcount=120">more</a> +| <a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a> +</div> + </div> </div> @@ -222,7 +231,10 @@ files, or words in the commit message</div> </form> -<div class="navigate"><a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a> </div> +<div class="navigate"> +<a href="/log/01de2d66a28d/a?revcount=30">less</a> +<a href="/log/01de2d66a28d/a?revcount=120">more</a> +| <a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a> </div> <table class="bigtable"> <tr> @@ -243,6 +255,12 @@ </table> +<div class="navigate"> +<a href="/log/01de2d66a28d/a?revcount=30">less</a> +<a href="/log/01de2d66a28d/a?revcount=120">more</a> +| <a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a> +</div> + </div> </div> @@ -305,7 +323,10 @@ files, or words in the commit message</div> </form> -<div class="navigate"><a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a> </div> +<div class="navigate"> +<a href="/log/5ed941583260/a?revcount=30">less</a> +<a href="/log/5ed941583260/a?revcount=120">more</a> +| <a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a> </div> <table class="bigtable"> <tr> @@ -321,6 +342,12 @@ </table> +<div class="navigate"> +<a href="/log/5ed941583260/a?revcount=30">less</a> +<a href="/log/5ed941583260/a?revcount=120">more</a> +| <a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a> +</div> + </div> </div> @@ -383,7 +410,10 @@ files, or words in the commit message</div> </form> -<div class="navigate"><a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a> </div> +<div class="navigate"> +<a href="/log/5ed941583260/a?revcount=30">less</a> +<a href="/log/5ed941583260/a?revcount=120">more</a> +| <a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a> </div> <table class="bigtable"> <tr> @@ -399,6 +429,12 @@ </table> +<div class="navigate"> +<a href="/log/5ed941583260/a?revcount=30">less</a> +<a href="/log/5ed941583260/a?revcount=120">more</a> +| <a href="/log/5ed941583260/a">(0)</a> <a href="/log/tip/a">tip</a> +</div> + </div> </div>