##// END OF EJS Templates
hgweb: `limit` argument is actually `latestonly` renames and enforce...
Pierre-Yves David -
r18402:bfba6d95 default
parent child Browse files
Show More
@@ -194,9 +194,13 b' def changelog(web, req, tmpl, shortlog=F'
194 except error.RepoError:
194 except error.RepoError:
195 return _search(web, req, tmpl) # XXX redirect to 404 page?
195 return _search(web, req, tmpl) # XXX redirect to 404 page?
196
196
197 def changelist(limit=0, **map):
197 def changelist(latestonly, **map):
198 l = [] # build a list in forward order for efficiency
198 l = [] # build a list in forward order for efficiency
199 for i in xrange(start, end):
199 if latestonly:
200 revs = (end - 1,)
201 else:
202 revs = xrange(start, end)
203 for i in revs:
200 ctx = web.repo[i]
204 ctx = web.repo[i]
201 n = ctx.node()
205 n = ctx.node()
202 showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n)
206 showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n)
@@ -217,9 +221,6 b' def changelog(web, req, tmpl, shortlog=F'
217 "inbranch": webutil.nodeinbranch(web.repo, ctx),
221 "inbranch": webutil.nodeinbranch(web.repo, ctx),
218 "branches": webutil.nodebranchdict(web.repo, ctx)
222 "branches": webutil.nodebranchdict(web.repo, ctx)
219 })
223 })
220 if limit > 0:
221 l = l[-limit:]
222
223 for e in reversed(l):
224 for e in reversed(l):
224 yield e
225 yield e
225
226
@@ -245,8 +246,8 b' def changelog(web, req, tmpl, shortlog=F'
245
246
246 return tmpl(shortlog and 'shortlog' or 'changelog', changenav=changenav,
247 return tmpl(shortlog and 'shortlog' or 'changelog', changenav=changenav,
247 node=ctx.hex(), rev=pos, changesets=count,
248 node=ctx.hex(), rev=pos, changesets=count,
248 entries=lambda **x: changelist(limit=0,**x),
249 entries=lambda **x: changelist(latestonly=False, **x),
249 latestentry=lambda **x: changelist(limit=1,**x),
250 latestentry=lambda **x: changelist(latestonly=True, **x),
250 archives=web.archivelist("tip"), revcount=revcount,
251 archives=web.archivelist("tip"), revcount=revcount,
251 morevars=morevars, lessvars=lessvars)
252 morevars=morevars, lessvars=lessvars)
252
253
@@ -401,14 +402,13 b' def tags(web, req, tmpl):'
401 i = list(reversed(web.repo.tagslist()))
402 i = list(reversed(web.repo.tagslist()))
402 parity = paritygen(web.stripecount)
403 parity = paritygen(web.stripecount)
403
404
404 def entries(notip=False, limit=0, **map):
405 def entries(notip, latestonly, **map):
405 count = 0
406 t = i
406 for k, n in i:
407 if notip:
407 if notip and k == "tip":
408 t = [(k, n) for k, n in i if k != "tip"]
408 continue
409 if latestonly:
409 if limit > 0 and count >= limit:
410 t = t[:1]
410 continue
411 for k, n in t:
411 count = count + 1
412 yield {"parity": parity.next(),
412 yield {"parity": parity.next(),
413 "tag": k,
413 "tag": k,
414 "date": web.repo[n].date(),
414 "date": web.repo[n].date(),
@@ -416,20 +416,20 b' def tags(web, req, tmpl):'
416
416
417 return tmpl("tags",
417 return tmpl("tags",
418 node=hex(web.repo.changelog.tip()),
418 node=hex(web.repo.changelog.tip()),
419 entries=lambda **x: entries(False, 0, **x),
419 entries=lambda **x: entries(False, False, **x),
420 entriesnotip=lambda **x: entries(True, 0, **x),
420 entriesnotip=lambda **x: entries(True, False, **x),
421 latestentry=lambda **x: entries(True, 1, **x))
421 latestentry=lambda **x: entries(True, True, **x))
422
422
423 def bookmarks(web, req, tmpl):
423 def bookmarks(web, req, tmpl):
424 i = web.repo._bookmarks.items()
424 i = web.repo._bookmarks.items()
425 parity = paritygen(web.stripecount)
425 parity = paritygen(web.stripecount)
426
426
427 def entries(limit=0, **map):
427 def entries(latestonly, **map):
428 count = 0
428 if latestonly:
429 for k, n in sorted(i):
429 t = [min(i)]
430 if limit > 0 and count >= limit:
430 else:
431 continue
431 t = sorted(i)
432 count = count + 1
432 for k, n in t:
433 yield {"parity": parity.next(),
433 yield {"parity": parity.next(),
434 "bookmark": k,
434 "bookmark": k,
435 "date": web.repo[n].date(),
435 "date": web.repo[n].date(),
@@ -437,8 +437,8 b' def bookmarks(web, req, tmpl):'
437
437
438 return tmpl("bookmarks",
438 return tmpl("bookmarks",
439 node=hex(web.repo.changelog.tip()),
439 node=hex(web.repo.changelog.tip()),
440 entries=lambda **x: entries(0, **x),
440 entries=lambda **x: entries(latestonly=False, **x),
441 latestentry=lambda **x: entries(1, **x))
441 latestentry=lambda **x: entries(latestonly=True, **x))
442
442
443 def branches(web, req, tmpl):
443 def branches(web, req, tmpl):
444 tips = []
444 tips = []
@@ -741,11 +741,15 b' def filelog(web, req, tmpl):'
741 end = min(count, start + revcount) # last rev on this page
741 end = min(count, start + revcount) # last rev on this page
742 parity = paritygen(web.stripecount, offset=start - end)
742 parity = paritygen(web.stripecount, offset=start - end)
743
743
744 def entries(limit=0, **map):
744 def entries(latestonly, **map):
745 l = []
745 l = []
746
746
747 repo = web.repo
747 repo = web.repo
748 for i in xrange(start, end):
748 if latestonly:
749 revs = (end - 1,)
750 else:
751 revs = xrange(start, end)
752 for i in revs:
749 iterfctx = fctx.filectx(i)
753 iterfctx = fctx.filectx(i)
750
754
751 l.append({"parity": parity.next(),
755 l.append({"parity": parity.next(),
@@ -764,18 +768,14 b' def filelog(web, req, tmpl):'
764 "branch": webutil.nodebranchnodefault(iterfctx),
768 "branch": webutil.nodebranchnodefault(iterfctx),
765 "inbranch": webutil.nodeinbranch(repo, iterfctx),
769 "inbranch": webutil.nodeinbranch(repo, iterfctx),
766 "branches": webutil.nodebranchdict(repo, iterfctx)})
770 "branches": webutil.nodebranchdict(repo, iterfctx)})
767
768 if limit > 0:
769 l = l[-limit:]
770
771 for e in reversed(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,
777 entries=lambda **x: entries(limit=0, **x),
777 entries=lambda **x: entries(latestonly=False, **x),
778 latestentry=lambda **x: entries(limit=1, **x),
778 latestentry=lambda **x: entries(latestonly=True, **x),
779 revcount=revcount, morevars=morevars, lessvars=lessvars)
779 revcount=revcount, morevars=morevars, lessvars=lessvars)
780
780
781 def archive(web, req, tmpl):
781 def archive(web, req, tmpl):
General Comments 0
You need to be logged in to leave comments. Login now