Mercurial > hg
comparison mercurial/hgweb/webcommands.py @ 7300:591767e6ea7a
hgweb: conditionally show file logs for deleted files
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Sat, 01 Nov 2008 13:07:24 +0100 |
parents | 9c399c53469d |
children | c21d236ca897 |
comparison
equal
deleted
inserted
replaced
7299:288dda59233c | 7300:591767e6ea7a |
---|---|
498 parent=webutil.siblings(fctx.parents()), | 498 parent=webutil.siblings(fctx.parents()), |
499 child=webutil.siblings(fctx.children()), | 499 child=webutil.siblings(fctx.children()), |
500 permissions=fctx.manifest().flags(f)) | 500 permissions=fctx.manifest().flags(f)) |
501 | 501 |
502 def filelog(web, req, tmpl): | 502 def filelog(web, req, tmpl): |
503 fctx = webutil.filectx(web.repo, req) | 503 |
504 f = fctx.path() | 504 try: |
505 fl = fctx.filelog() | 505 fctx = webutil.filectx(web.repo, req) |
506 count = len(fl) | 506 f = fctx.path() |
507 fl = fctx.filelog() | |
508 except revlog.LookupError: | |
509 f = webutil.cleanpath(web.repo, req.form['file'][0]) | |
510 fl = web.repo.file(f) | |
511 numrevs = len(fl) | |
512 if not numrevs: # file doesn't exist at all | |
513 raise | |
514 rev = webutil.changectx(web.repo, req).rev() | |
515 first = fl.linkrev(fl.node(0)) | |
516 if rev < first: # current rev is from before file existed | |
517 raise | |
518 frev = numrevs - 1 | |
519 while fl.linkrev(fl.node(frev)) > rev: | |
520 frev -= 1 | |
521 fctx = web.repo.filectx(f, fl.linkrev(fl.node(frev))) | |
522 | |
523 count = fctx.filerev() + 1 | |
507 pagelen = web.maxshortchanges | 524 pagelen = web.maxshortchanges |
508 pos = fctx.filerev() | 525 start = max(0, fctx.filerev() - pagelen + 1) # first rev on this page |
509 start = max(0, pos - pagelen + 1) | 526 end = min(count, start + pagelen) # last rev on this page |
510 end = min(count, start + pagelen) | |
511 pos = end - 1 | |
512 parity = paritygen(web.stripecount, offset=start-end) | 527 parity = paritygen(web.stripecount, offset=start-end) |
513 | 528 |
514 def entries(limit=0, **map): | 529 def entries(limit=0, **map): |
515 l = [] | 530 l = [] |
516 | 531 |
533 | 548 |
534 for e in l: | 549 for e in l: |
535 yield e | 550 yield e |
536 | 551 |
537 nodefunc = lambda x: fctx.filectx(fileid=x) | 552 nodefunc = lambda x: fctx.filectx(fileid=x) |
538 nav = webutil.revnavgen(pos, pagelen, count, nodefunc) | 553 nav = webutil.revnavgen(end - 1, pagelen, count, nodefunc) |
539 return tmpl("filelog", file=f, node=hex(fctx.node()), nav=nav, | 554 return tmpl("filelog", file=f, node=hex(fctx.node()), nav=nav, |
540 entries=lambda **x: entries(limit=0, **x), | 555 entries=lambda **x: entries(limit=0, **x), |
541 latestentry=lambda **x: entries(limit=1, **x)) | 556 latestentry=lambda **x: entries(limit=1, **x)) |
542 | 557 |
543 | 558 |