Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/hgweb_mod.py @ 5889:209577095f20
hgweb: just return iterables instead of yielding them
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Fri, 18 Jan 2008 19:53:38 +0100 |
parents | dd1998dd6f3b |
children | a0e20a5eba3c |
comparison
equal
deleted
inserted
replaced
5888:956afc025c0f | 5889:209577095f20 |
---|---|
444 pos = end - 1 | 444 pos = end - 1 |
445 parity = paritygen(self.stripecount, offset=start-end) | 445 parity = paritygen(self.stripecount, offset=start-end) |
446 | 446 |
447 changenav = revnavgen(pos, maxchanges, count, self.repo.changectx) | 447 changenav = revnavgen(pos, maxchanges, count, self.repo.changectx) |
448 | 448 |
449 yield tmpl(shortlog and 'shortlog' or 'changelog', | 449 return tmpl(shortlog and 'shortlog' or 'changelog', |
450 changenav=changenav, | 450 changenav=changenav, |
451 node=hex(cl.tip()), | 451 node=hex(cl.tip()), |
452 rev=pos, changesets=count, | 452 rev=pos, changesets=count, |
453 entries=lambda **x: changelist(limit=0,**x), | 453 entries=lambda **x: changelist(limit=0,**x), |
454 latestentry=lambda **x: changelist(limit=1,**x), | 454 latestentry=lambda **x: changelist(limit=1,**x), |
455 archives=self.archivelist("tip")) | 455 archives=self.archivelist("tip")) |
456 | 456 |
457 def search(self, tmpl, query): | 457 def search(self, tmpl, query): |
458 | 458 |
459 def changelist(**map): | 459 def changelist(**map): |
460 cl = self.repo.changelog | 460 cl = self.repo.changelog |
503 break | 503 break |
504 | 504 |
505 cl = self.repo.changelog | 505 cl = self.repo.changelog |
506 parity = paritygen(self.stripecount) | 506 parity = paritygen(self.stripecount) |
507 | 507 |
508 yield tmpl('search', | 508 return tmpl('search', |
509 query=query, | 509 query=query, |
510 node=hex(cl.tip()), | 510 node=hex(cl.tip()), |
511 entries=changelist, | 511 entries=changelist, |
512 archives=self.archivelist("tip")) | 512 archives=self.archivelist("tip")) |
513 | 513 |
514 def changeset(self, tmpl, ctx): | 514 def changeset(self, tmpl, ctx): |
515 n = ctx.node() | 515 n = ctx.node() |
516 parents = ctx.parents() | 516 parents = ctx.parents() |
517 p1 = parents[0].node() | 517 p1 = parents[0].node() |
524 parity=parity.next())) | 524 parity=parity.next())) |
525 | 525 |
526 def diff(**map): | 526 def diff(**map): |
527 yield self.diff(tmpl, p1, n, None) | 527 yield self.diff(tmpl, p1, n, None) |
528 | 528 |
529 yield tmpl('changeset', | 529 return tmpl('changeset', |
530 diff=diff, | 530 diff=diff, |
531 rev=ctx.rev(), | 531 rev=ctx.rev(), |
532 node=hex(n), | 532 node=hex(n), |
533 parent=self.siblings(parents), | 533 parent=self.siblings(parents), |
534 child=self.siblings(ctx.children()), | 534 child=self.siblings(ctx.children()), |
535 changesettag=self.showtag("changesettag",n), | 535 changesettag=self.showtag("changesettag",n), |
536 author=ctx.user(), | 536 author=ctx.user(), |
537 desc=ctx.description(), | 537 desc=ctx.description(), |
538 date=ctx.date(), | 538 date=ctx.date(), |
539 files=files, | 539 files=files, |
540 archives=self.archivelist(hex(n)), | 540 archives=self.archivelist(hex(n)), |
541 tags=self.nodetagsdict(n), | 541 tags=self.nodetagsdict(n), |
542 branches=self.nodebranchdict(ctx)) | 542 branches=self.nodebranchdict(ctx)) |
543 | 543 |
544 def filelog(self, tmpl, fctx): | 544 def filelog(self, tmpl, fctx): |
545 f = fctx.path() | 545 f = fctx.path() |
546 fl = fctx.filelog() | 546 fl = fctx.filelog() |
547 count = fl.count() | 547 count = fl.count() |
576 for e in l: | 576 for e in l: |
577 yield e | 577 yield e |
578 | 578 |
579 nodefunc = lambda x: fctx.filectx(fileid=x) | 579 nodefunc = lambda x: fctx.filectx(fileid=x) |
580 nav = revnavgen(pos, pagelen, count, nodefunc) | 580 nav = revnavgen(pos, pagelen, count, nodefunc) |
581 yield tmpl("filelog", file=f, node=hex(fctx.node()), nav=nav, | 581 return tmpl("filelog", file=f, node=hex(fctx.node()), nav=nav, |
582 entries=lambda **x: entries(limit=0, **x), | 582 entries=lambda **x: entries(limit=0, **x), |
583 latestentry=lambda **x: entries(limit=1, **x)) | 583 latestentry=lambda **x: entries(limit=1, **x)) |
584 | 584 |
585 def filerevision(self, tmpl, fctx): | 585 def filerevision(self, tmpl, fctx): |
586 f = fctx.path() | 586 f = fctx.path() |
587 text = fctx.data() | 587 text = fctx.data() |
588 fl = fctx.filelog() | 588 fl = fctx.filelog() |
600 for l, t in enumerate(text.splitlines(1)): | 600 for l, t in enumerate(text.splitlines(1)): |
601 yield {"line": t, | 601 yield {"line": t, |
602 "linenumber": "% 6d" % (l + 1), | 602 "linenumber": "% 6d" % (l + 1), |
603 "parity": parity.next()} | 603 "parity": parity.next()} |
604 | 604 |
605 yield tmpl("filerevision", | 605 return tmpl("filerevision", |
606 file=f, | 606 file=f, |
607 path=_up(f), | 607 path=_up(f), |
608 text=lines(), | 608 text=lines(), |
609 raw=rawtext, | 609 raw=rawtext, |
610 mimetype=mt, | 610 mimetype=mt, |
611 rev=fctx.rev(), | 611 rev=fctx.rev(), |
612 node=hex(fctx.node()), | 612 node=hex(fctx.node()), |
613 author=fctx.user(), | 613 author=fctx.user(), |
614 date=fctx.date(), | 614 date=fctx.date(), |
615 desc=fctx.description(), | 615 desc=fctx.description(), |
616 parent=self.siblings(fctx.parents()), | 616 parent=self.siblings(fctx.parents()), |
617 child=self.siblings(fctx.children()), | 617 child=self.siblings(fctx.children()), |
618 rename=self.renamelink(fl, n), | 618 rename=self.renamelink(fl, n), |
619 permissions=fctx.manifest().flags(f)) | 619 permissions=fctx.manifest().flags(f)) |
620 | 620 |
621 def fileannotate(self, tmpl, fctx): | 621 def fileannotate(self, tmpl, fctx): |
622 f = fctx.path() | 622 f = fctx.path() |
623 n = fctx.filenode() | 623 n = fctx.filenode() |
624 fl = fctx.filelog() | 624 fl = fctx.filelog() |
638 "rev": f.rev(), | 638 "rev": f.rev(), |
639 "author": name, | 639 "author": name, |
640 "file": f.path(), | 640 "file": f.path(), |
641 "line": l} | 641 "line": l} |
642 | 642 |
643 yield tmpl("fileannotate", | 643 return tmpl("fileannotate", |
644 file=f, | 644 file=f, |
645 annotate=annotate, | 645 annotate=annotate, |
646 path=_up(f), | 646 path=_up(f), |
647 rev=fctx.rev(), | 647 rev=fctx.rev(), |
648 node=hex(fctx.node()), | 648 node=hex(fctx.node()), |
649 author=fctx.user(), | 649 author=fctx.user(), |
650 date=fctx.date(), | 650 date=fctx.date(), |
651 desc=fctx.description(), | 651 desc=fctx.description(), |
652 rename=self.renamelink(fl, n), | 652 rename=self.renamelink(fl, n), |
653 parent=self.siblings(fctx.parents()), | 653 parent=self.siblings(fctx.parents()), |
654 child=self.siblings(fctx.children()), | 654 child=self.siblings(fctx.children()), |
655 permissions=fctx.manifest().flags(f)) | 655 permissions=fctx.manifest().flags(f)) |
656 | 656 |
657 def manifest(self, tmpl, ctx, path): | 657 def manifest(self, tmpl, ctx, path): |
658 mf = ctx.manifest() | 658 mf = ctx.manifest() |
659 node = ctx.node() | 659 node = ctx.node() |
660 | 660 |
706 | 706 |
707 yield {"parity": parity.next(), | 707 yield {"parity": parity.next(), |
708 "path": "%s%s" % (abspath, f), | 708 "path": "%s%s" % (abspath, f), |
709 "basename": f[:-1]} | 709 "basename": f[:-1]} |
710 | 710 |
711 yield tmpl("manifest", | 711 return tmpl("manifest", |
712 rev=ctx.rev(), | 712 rev=ctx.rev(), |
713 node=hex(node), | 713 node=hex(node), |
714 path=abspath, | 714 path=abspath, |
715 up=_up(abspath), | 715 up=_up(abspath), |
716 upparity=parity.next(), | 716 upparity=parity.next(), |
717 fentries=filelist, | 717 fentries=filelist, |
718 dentries=dirlist, | 718 dentries=dirlist, |
719 archives=self.archivelist(hex(node)), | 719 archives=self.archivelist(hex(node)), |
720 tags=self.nodetagsdict(node), | 720 tags=self.nodetagsdict(node), |
721 branches=self.nodebranchdict(ctx)) | 721 branches=self.nodebranchdict(ctx)) |
722 | 722 |
723 def tags(self, tmpl): | 723 def tags(self, tmpl): |
724 i = self.repo.tagslist() | 724 i = self.repo.tagslist() |
725 i.reverse() | 725 i.reverse() |
726 parity = paritygen(self.stripecount) | 726 parity = paritygen(self.stripecount) |
736 yield {"parity": parity.next(), | 736 yield {"parity": parity.next(), |
737 "tag": k, | 737 "tag": k, |
738 "date": self.repo.changectx(n).date(), | 738 "date": self.repo.changectx(n).date(), |
739 "node": hex(n)} | 739 "node": hex(n)} |
740 | 740 |
741 yield tmpl("tags", | 741 return tmpl("tags", |
742 node=hex(self.repo.changelog.tip()), | 742 node=hex(self.repo.changelog.tip()), |
743 entries=lambda **x: entries(False,0, **x), | 743 entries=lambda **x: entries(False,0, **x), |
744 entriesnotip=lambda **x: entries(True,0, **x), | 744 entriesnotip=lambda **x: entries(True,0, **x), |
745 latestentry=lambda **x: entries(True,1, **x)) | 745 latestentry=lambda **x: entries(True,1, **x)) |
746 | 746 |
747 def summary(self, tmpl): | 747 def summary(self, tmpl): |
748 i = self.repo.tagslist() | 748 i = self.repo.tagslist() |
749 i.reverse() | 749 i.reverse() |
750 | 750 |
805 cl = self.repo.changelog | 805 cl = self.repo.changelog |
806 count = cl.count() | 806 count = cl.count() |
807 start = max(0, count - self.maxchanges) | 807 start = max(0, count - self.maxchanges) |
808 end = min(count, start + self.maxchanges) | 808 end = min(count, start + self.maxchanges) |
809 | 809 |
810 yield tmpl("summary", | 810 return tmpl("summary", |
811 desc=self.config("web", "description", "unknown"), | 811 desc=self.config("web", "description", "unknown"), |
812 owner=get_contact(self.config) or "unknown", | 812 owner=get_contact(self.config) or "unknown", |
813 lastchange=cl.read(cl.tip())[2], | 813 lastchange=cl.read(cl.tip())[2], |
814 tags=tagentries, | 814 tags=tagentries, |
815 branches=branches, | 815 branches=branches, |
816 shortlog=changelist, | 816 shortlog=changelist, |
817 node=hex(cl.tip()), | 817 node=hex(cl.tip()), |
818 archives=self.archivelist("tip")) | 818 archives=self.archivelist("tip")) |
819 | 819 |
820 def filediff(self, tmpl, fctx): | 820 def filediff(self, tmpl, fctx): |
821 n = fctx.node() | 821 n = fctx.node() |
822 path = fctx.path() | 822 path = fctx.path() |
823 parents = fctx.parents() | 823 parents = fctx.parents() |
824 p1 = parents and parents[0].node() or nullid | 824 p1 = parents and parents[0].node() or nullid |
825 | 825 |
826 def diff(**map): | 826 def diff(**map): |
827 yield self.diff(tmpl, p1, n, [path]) | 827 yield self.diff(tmpl, p1, n, [path]) |
828 | 828 |
829 yield tmpl("filediff", | 829 return tmpl("filediff", |
830 file=path, | 830 file=path, |
831 node=hex(n), | 831 node=hex(n), |
832 rev=fctx.rev(), | 832 rev=fctx.rev(), |
833 parent=self.siblings(parents), | 833 parent=self.siblings(parents), |
834 child=self.siblings(fctx.children()), | 834 child=self.siblings(fctx.children()), |
835 diff=diff) | 835 diff=diff) |
836 | 836 |
837 archive_specs = { | 837 archive_specs = { |
838 'bz2': ('application/x-tar', 'tbz2', '.tar.bz2', None), | 838 'bz2': ('application/x-tar', 'tbz2', '.tar.bz2', None), |
839 'gz': ('application/x-tar', 'tgz', '.tar.gz', None), | 839 'gz': ('application/x-tar', 'tgz', '.tar.gz', None), |
840 'zip': ('application/zip', 'zip', '.zip', None), | 840 'zip': ('application/zip', 'zip', '.zip', None), |