Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/webcommands.py @ 30816:96f811bceb85
hgweb: build the "entries" list directly in filelog command
There's no apparent reason to have this "entries" generator function that
builds a list and then yields its elements in reverse order and which is only
called to build the "entries" list. So just build the list directly, in
reverse order.
Adjust "parity" generator's offset to keep rendering the same.
author | Denis Laxalde <denis.laxalde@logilab.fr> |
---|---|
date | Fri, 13 Jan 2017 10:22:25 +0100 |
parents | b9e49f7b0220 |
children | 4deb7c1a07ab |
comparison
equal
deleted
inserted
replaced
30815:c5bf2e8ec18c | 30816:96f811bceb85 |
---|---|
972 morevars['revcount'] = revcount * 2 | 972 morevars['revcount'] = revcount * 2 |
973 | 973 |
974 count = fctx.filerev() + 1 | 974 count = fctx.filerev() + 1 |
975 start = max(0, fctx.filerev() - revcount + 1) # first rev on this page | 975 start = max(0, fctx.filerev() - revcount + 1) # first rev on this page |
976 end = min(count, start + revcount) # last rev on this page | 976 end = min(count, start + revcount) # last rev on this page |
977 parity = paritygen(web.stripecount, offset=start - end) | 977 parity = paritygen(web.stripecount, offset=start - end + 1) |
978 | 978 |
979 def entries(): | 979 repo = web.repo |
980 l = [] | 980 revs = fctx.filelog().revs(start, end - 1) |
981 | 981 entries = [] |
982 repo = web.repo | 982 for i in reversed(revs): |
983 revs = fctx.filelog().revs(start, end - 1) | 983 iterfctx = fctx.filectx(i) |
984 for i in revs: | 984 entries.append(dict( |
985 iterfctx = fctx.filectx(i) | 985 parity=next(parity), |
986 | 986 filerev=i, |
987 l.append(dict( | 987 file=f, |
988 parity=next(parity), | 988 rename=webutil.renamelink(iterfctx), |
989 filerev=i, | 989 **webutil.commonentry(repo, iterfctx))) |
990 file=f, | 990 |
991 rename=webutil.renamelink(iterfctx), | |
992 **webutil.commonentry(repo, iterfctx))) | |
993 for e in reversed(l): | |
994 yield e | |
995 | |
996 entries = list(entries()) | |
997 latestentry = entries[:1] | 991 latestentry = entries[:1] |
998 | 992 |
999 revnav = webutil.filerevnav(web.repo, fctx.path()) | 993 revnav = webutil.filerevnav(web.repo, fctx.path()) |
1000 nav = revnav.gen(end - 1, revcount, count) | 994 nav = revnav.gen(end - 1, revcount, count) |
1001 return tmpl("filelog", | 995 return tmpl("filelog", |