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