# HG changeset patch # User Dirkjan Ochtman # Date 2010-01-14 15:28:21 # Node ID b9d02695bde4665d3400148cebdb7ea081fdbe87 # Parent 207b94f6b65dc9913c5dc45ce758576a9f388dab hgweb: add less/more links to shortlog/filelog nav diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -200,24 +200,32 @@ def changelog(web, req, tmpl, shortlog = 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 @@ def filelog(web, req, tmpl): 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 @@ def filelog(web, req, tmpl): 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] diff --git a/mercurial/templates/paper/filelog.tmpl b/mercurial/templates/paper/filelog.tmpl --- a/mercurial/templates/paper/filelog.tmpl +++ b/mercurial/templates/paper/filelog.tmpl @@ -43,7 +43,10 @@ files, or words in the commit message - + @@ -54,6 +57,12 @@ files, or words in the commit message + + diff --git a/mercurial/templates/paper/shortlog.tmpl b/mercurial/templates/paper/shortlog.tmpl --- a/mercurial/templates/paper/shortlog.tmpl +++ b/mercurial/templates/paper/shortlog.tmpl @@ -39,7 +39,11 @@ files, or words in the commit message - +
@@ -50,7 +54,12 @@ files, or words in the commit message - + + diff --git a/tests/test-hgweb-commands.out b/tests/test-hgweb-commands.out --- a/tests/test-hgweb-commands.out +++ b/tests/test-hgweb-commands.out @@ -201,7 +201,11 @@ 200 Script output follows files, or words in the commit message - +
@@ -227,7 +231,12 @@ files, or words in the commit message - + + diff --git a/tests/test-hgweb-empty.out b/tests/test-hgweb-empty.out --- a/tests/test-hgweb-empty.out +++ b/tests/test-hgweb-empty.out @@ -47,7 +47,11 @@ 200 Script output follows files, or words in the commit message - +
@@ -58,7 +62,12 @@ files, or words in the commit message - + + @@ -116,7 +125,11 @@ 200 Script output follows files, or words in the commit message - +
@@ -127,7 +140,12 @@ files, or words in the commit message - + + diff --git a/tests/test-hgweb-filelog.out b/tests/test-hgweb-filelog.out --- a/tests/test-hgweb-filelog.out +++ b/tests/test-hgweb-filelog.out @@ -139,7 +139,10 @@ 200 Script output follows files, or words in the commit message - +
@@ -160,6 +163,12 @@ files, or words in the commit message + + @@ -222,7 +231,10 @@ 200 Script output follows files, or words in the commit message - +
@@ -243,6 +255,12 @@ files, or words in the commit message + + @@ -305,7 +323,10 @@ 200 Script output follows files, or words in the commit message - +
@@ -321,6 +342,12 @@ files, or words in the commit message + + @@ -383,7 +410,10 @@ 200 Script output follows files, or words in the commit message - +
@@ -399,6 +429,12 @@ files, or words in the commit message + +