Mercurial > hg
comparison mercurial/hgweb/webcommands.py @ 18319:e350ce798b63
hgweb: no do not use listinsert(0, ...)
This is not efficient. We now append element and either reverse the list or
iterate in reverse order.
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Wed, 19 Dec 2012 19:06:50 +0100 |
parents | c8326ffdcb4f |
children | 853221386f48 |
comparison
equal
deleted
inserted
replaced
18318:948f495fb230 | 18319:e350ce798b63 |
---|---|
200 ctx = web.repo[i] | 200 ctx = web.repo[i] |
201 n = ctx.node() | 201 n = ctx.node() |
202 showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n) | 202 showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n) |
203 files = webutil.listfilediffs(tmpl, ctx.files(), n, web.maxfiles) | 203 files = webutil.listfilediffs(tmpl, ctx.files(), n, web.maxfiles) |
204 | 204 |
205 l.insert(0, {"parity": parity.next(), | 205 l.append({"parity": parity.next(), |
206 "author": ctx.user(), | 206 "author": ctx.user(), |
207 "parent": webutil.parents(ctx, i - 1), | 207 "parent": webutil.parents(ctx, i - 1), |
208 "child": webutil.children(ctx, i + 1), | 208 "child": webutil.children(ctx, i + 1), |
209 "changelogtag": showtags, | 209 "changelogtag": showtags, |
210 "desc": ctx.description(), | 210 "desc": ctx.description(), |
211 "date": ctx.date(), | 211 "date": ctx.date(), |
212 "files": files, | 212 "files": files, |
213 "rev": i, | 213 "rev": i, |
214 "node": hex(n), | 214 "node": hex(n), |
215 "tags": webutil.nodetagsdict(web.repo, n), | 215 "tags": webutil.nodetagsdict(web.repo, n), |
216 "bookmarks": webutil.nodebookmarksdict(web.repo, n), | 216 "bookmarks": webutil.nodebookmarksdict(web.repo, n), |
217 "inbranch": webutil.nodeinbranch(web.repo, ctx), | 217 "inbranch": webutil.nodeinbranch(web.repo, ctx), |
218 "branches": webutil.nodebranchdict(web.repo, ctx) | 218 "branches": webutil.nodebranchdict(web.repo, ctx) |
219 }) | 219 }) |
220 | |
221 if limit > 0: | 220 if limit > 0: |
222 l = l[:limit] | 221 l = l[-limit:] |
223 | 222 |
224 for e in l: | 223 for e in reversed(l): |
225 yield e | 224 yield e |
226 | 225 |
227 revcount = shortlog and web.maxshortchanges or web.maxchanges | 226 revcount = shortlog and web.maxshortchanges or web.maxchanges |
228 if 'revcount' in req.form: | 227 if 'revcount' in req.form: |
229 revcount = int(req.form.get('revcount', [revcount])[0]) | 228 revcount = int(req.form.get('revcount', [revcount])[0]) |
518 for i in xrange(start, end): | 517 for i in xrange(start, end): |
519 ctx = web.repo[i] | 518 ctx = web.repo[i] |
520 n = ctx.node() | 519 n = ctx.node() |
521 hn = hex(n) | 520 hn = hex(n) |
522 | 521 |
523 l.insert(0, tmpl( | 522 l.append(tmpl( |
524 'shortlogentry', | 523 'shortlogentry', |
525 parity=parity.next(), | 524 parity=parity.next(), |
526 author=ctx.user(), | 525 author=ctx.user(), |
527 desc=ctx.description(), | 526 desc=ctx.description(), |
528 date=ctx.date(), | 527 date=ctx.date(), |
531 tags=webutil.nodetagsdict(web.repo, n), | 530 tags=webutil.nodetagsdict(web.repo, n), |
532 bookmarks=webutil.nodebookmarksdict(web.repo, n), | 531 bookmarks=webutil.nodebookmarksdict(web.repo, n), |
533 inbranch=webutil.nodeinbranch(web.repo, ctx), | 532 inbranch=webutil.nodeinbranch(web.repo, ctx), |
534 branches=webutil.nodebranchdict(web.repo, ctx))) | 533 branches=webutil.nodebranchdict(web.repo, ctx))) |
535 | 534 |
535 l.reverse() | |
536 yield l | 536 yield l |
537 | 537 |
538 tip = web.repo['tip'] | 538 tip = web.repo['tip'] |
539 count = len(web.repo) | 539 count = len(web.repo) |
540 start = max(0, count - web.maxchanges) | 540 start = max(0, count - web.maxchanges) |
746 | 746 |
747 repo = web.repo | 747 repo = web.repo |
748 for i in xrange(start, end): | 748 for i in xrange(start, end): |
749 iterfctx = fctx.filectx(i) | 749 iterfctx = fctx.filectx(i) |
750 | 750 |
751 l.insert(0, {"parity": parity.next(), | 751 l.append({"parity": parity.next(), |
752 "filerev": i, | 752 "filerev": i, |
753 "file": f, | 753 "file": f, |
754 "node": iterfctx.hex(), | 754 "node": iterfctx.hex(), |
755 "author": iterfctx.user(), | 755 "author": iterfctx.user(), |
756 "date": iterfctx.date(), | 756 "date": iterfctx.date(), |
757 "rename": webutil.renamelink(iterfctx), | 757 "rename": webutil.renamelink(iterfctx), |
758 "parent": webutil.parents(iterfctx), | 758 "parent": webutil.parents(iterfctx), |
759 "child": webutil.children(iterfctx), | 759 "child": webutil.children(iterfctx), |
760 "desc": iterfctx.description(), | 760 "desc": iterfctx.description(), |
761 "tags": webutil.nodetagsdict(repo, iterfctx.node()), | 761 "tags": webutil.nodetagsdict(repo, iterfctx.node()), |
762 "bookmarks": webutil.nodebookmarksdict( | 762 "bookmarks": webutil.nodebookmarksdict( |
763 repo, iterfctx.node()), | 763 repo, iterfctx.node()), |
764 "branch": webutil.nodebranchnodefault(iterfctx), | 764 "branch": webutil.nodebranchnodefault(iterfctx), |
765 "inbranch": webutil.nodeinbranch(repo, iterfctx), | 765 "inbranch": webutil.nodeinbranch(repo, iterfctx), |
766 "branches": webutil.nodebranchdict(repo, iterfctx)}) | 766 "branches": webutil.nodebranchdict(repo, iterfctx)}) |
767 | 767 |
768 if limit > 0: | 768 if limit > 0: |
769 l = l[:limit] | 769 l = l[-limit:] |
770 | 770 |
771 for e in l: | 771 for e in reversed(l): |
772 yield e | 772 yield e |
773 | 773 |
774 nodefunc = lambda x: fctx.filectx(fileid=x) | 774 nodefunc = lambda x: fctx.filectx(fileid=x) |
775 nav = webutil.revnavgen(end - 1, revcount, count, nodefunc) | 775 nav = webutil.revnavgen(end - 1, revcount, count, nodefunc) |
776 return tmpl("filelog", file=f, node=fctx.hex(), nav=nav, | 776 return tmpl("filelog", file=f, node=fctx.hex(), nav=nav, |