comparison mercurial/hgweb/webcommands.py @ 17318:7ac5800dbc8f stable

hgweb: fix graph view paging - Fix off-by-one error on displayed entries count in normal mode - Fix incorrect paging when the top revision was lower than revcount - Fix revcount not overriding web.maxshortchanges everywhere
author Patrick Mezard <patrick@mezard.eu>
date Sun, 29 Jul 2012 23:16:20 +0200
parents 06217d3cf8d9
children 7124f984dc8d
comparison
equal deleted inserted replaced
17317:0b8272274b56 17318:7ac5800dbc8f
815 static = [os.path.join(p, 'static') for p in tp] 815 static = [os.path.join(p, 'static') for p in tp]
816 return [staticfile(static, fname, req)] 816 return [staticfile(static, fname, req)]
817 817
818 def graph(web, req, tmpl): 818 def graph(web, req, tmpl):
819 819
820 rev = webutil.changectx(web.repo, req).rev() 820 ctx = webutil.changectx(web.repo, req)
821 rev = ctx.rev()
822
821 bg_height = 39 823 bg_height = 39
822 revcount = web.maxshortchanges 824 revcount = web.maxshortchanges
823 if 'revcount' in req.form: 825 if 'revcount' in req.form:
824 revcount = int(req.form.get('revcount', [revcount])[0]) 826 revcount = int(req.form.get('revcount', [revcount])[0])
825 revcount = max(revcount, 1) 827 revcount = max(revcount, 1)
828 lessvars = copy.copy(tmpl.defaults['sessionvars']) 830 lessvars = copy.copy(tmpl.defaults['sessionvars'])
829 lessvars['revcount'] = max(revcount / 2, 1) 831 lessvars['revcount'] = max(revcount / 2, 1)
830 morevars = copy.copy(tmpl.defaults['sessionvars']) 832 morevars = copy.copy(tmpl.defaults['sessionvars'])
831 morevars['revcount'] = revcount * 2 833 morevars['revcount'] = revcount * 2
832 834
833 max_rev = len(web.repo) - 1 835 count = len(web.repo)
834 revcount = min(max_rev, revcount) 836 pos = rev
835 revnode = web.repo.changelog.node(rev) 837 start = max(0, pos - revcount + 1)
836 revnode_hex = hex(revnode) 838 end = min(count, start + revcount)
837 uprev = min(max_rev, rev + revcount) 839 pos = end - 1
840
841 uprev = min(max(0, count - 1), rev + revcount)
838 downrev = max(0, rev - revcount) 842 downrev = max(0, rev - revcount)
839 count = len(web.repo) 843 changenav = webutil.revnavgen(pos, revcount, count, web.repo.changectx)
840 changenav = webutil.revnavgen(rev, revcount, count, web.repo.changectx) 844
841 startrev = rev 845 dag = graphmod.dagwalker(web.repo, range(start, end)[::-1])
842 # if starting revision is less than 60 set it to uprev
843 if rev < web.maxshortchanges:
844 startrev = uprev
845
846 dag = graphmod.dagwalker(web.repo, range(startrev, downrev - 1, -1))
847 tree = list(graphmod.colored(dag, web.repo)) 846 tree = list(graphmod.colored(dag, web.repo))
848 847
849 def getcolumns(tree): 848 def getcolumns(tree):
850 cols = 0 849 cols = 0
851 for (id, type, ctx, vtx, edges) in tree: 850 for (id, type, ctx, vtx, edges) in tree:
913 canvaswidth=(cols + 1) * bg_height, 912 canvaswidth=(cols + 1) * bg_height,
914 truecanvasheight=rows * bg_height, 913 truecanvasheight=rows * bg_height,
915 canvasheight=canvasheight, bg_height=bg_height, 914 canvasheight=canvasheight, bg_height=bg_height,
916 jsdata=lambda **x: graphdata(True, **x), 915 jsdata=lambda **x: graphdata(True, **x),
917 nodes=lambda **x: graphdata(False, **x), 916 nodes=lambda **x: graphdata(False, **x),
918 node=revnode_hex, changenav=changenav) 917 node=ctx.hex(), changenav=changenav)
919 918
920 def _getdoc(e): 919 def _getdoc(e):
921 doc = e[0].__doc__ 920 doc = e[0].__doc__
922 if doc: 921 if doc:
923 doc = _(doc).split('\n')[0] 922 doc = _(doc).split('\n')[0]