Mercurial > hg
comparison mercurial/hgweb/hgweb_mod.py @ 6249:cf1fa60fdaf4
hgweb_mod: add branch helper functions to use in templates
author | Florent Guillaume <fg@nuxeo.com> |
---|---|
date | Thu, 13 Mar 2008 23:45:35 +0100 |
parents | fe8dbbe9520d |
children | 2c370f08c486 |
comparison
equal
deleted
inserted
replaced
6248:b4fca699c33d | 6249:cf1fa60fdaf4 |
---|---|
362 branch = ctx.branch() | 362 branch = ctx.branch() |
363 # If this is an empty repo, ctx.node() == nullid, | 363 # If this is an empty repo, ctx.node() == nullid, |
364 # ctx.branch() == 'default', but branchtags() is | 364 # ctx.branch() == 'default', but branchtags() is |
365 # an empty dict. Using dict.get avoids a traceback. | 365 # an empty dict. Using dict.get avoids a traceback. |
366 if self.repo.branchtags().get(branch) == ctx.node(): | 366 if self.repo.branchtags().get(branch) == ctx.node(): |
367 branches.append({"name": branch}) | |
368 return branches | |
369 | |
370 def nodeinbranch(self, ctx): | |
371 branches = [] | |
372 branch = ctx.branch() | |
373 if branch != 'default' and self.repo.branchtags().get(branch) != ctx.node(): | |
374 branches.append({"name": branch}) | |
375 return branches | |
376 | |
377 def nodebranchnodefault(self, ctx): | |
378 branches = [] | |
379 branch = ctx.branch() | |
380 if branch != 'default': | |
367 branches.append({"name": branch}) | 381 branches.append({"name": branch}) |
368 return branches | 382 return branches |
369 | 383 |
370 def showtag(self, tmpl, t1, node=nullid, **args): | 384 def showtag(self, tmpl, t1, node=nullid, **args): |
371 for t in self.repo.nodetags(node): | 385 for t in self.repo.nodetags(node): |
456 "date": ctx.date(), | 470 "date": ctx.date(), |
457 "files": self.listfilediffs(tmpl, ctx.files(), n), | 471 "files": self.listfilediffs(tmpl, ctx.files(), n), |
458 "rev": i, | 472 "rev": i, |
459 "node": hex(n), | 473 "node": hex(n), |
460 "tags": self.nodetagsdict(n), | 474 "tags": self.nodetagsdict(n), |
475 "inbranch": self.nodeinbranch(ctx), | |
461 "branches": self.nodebranchdict(ctx)}) | 476 "branches": self.nodebranchdict(ctx)}) |
462 | 477 |
463 if limit > 0: | 478 if limit > 0: |
464 l = l[:limit] | 479 l = l[:limit] |
465 | 480 |
527 date=ctx.date(), | 542 date=ctx.date(), |
528 files=self.listfilediffs(tmpl, ctx.files(), n), | 543 files=self.listfilediffs(tmpl, ctx.files(), n), |
529 rev=ctx.rev(), | 544 rev=ctx.rev(), |
530 node=hex(n), | 545 node=hex(n), |
531 tags=self.nodetagsdict(n), | 546 tags=self.nodetagsdict(n), |
547 inbranch=self.nodeinbranch(ctx), | |
532 branches=self.nodebranchdict(ctx)) | 548 branches=self.nodebranchdict(ctx)) |
533 | 549 |
534 if count >= self.maxchanges: | 550 if count >= self.maxchanges: |
535 break | 551 break |
536 | 552 |
570 desc=ctx.description(), | 586 desc=ctx.description(), |
571 date=ctx.date(), | 587 date=ctx.date(), |
572 files=files, | 588 files=files, |
573 archives=self.archivelist(hex(n)), | 589 archives=self.archivelist(hex(n)), |
574 tags=self.nodetagsdict(n), | 590 tags=self.nodetagsdict(n), |
591 branch=self.nodebranchnodefault(ctx), | |
592 inbranch=self.nodeinbranch(ctx), | |
575 branches=self.nodebranchdict(ctx)) | 593 branches=self.nodebranchdict(ctx)) |
576 | 594 |
577 def filelog(self, tmpl, fctx): | 595 def filelog(self, tmpl, fctx): |
578 f = fctx.path() | 596 f = fctx.path() |
579 fl = fctx.filelog() | 597 fl = fctx.filelog() |
640 rev=fctx.rev(), | 658 rev=fctx.rev(), |
641 node=hex(fctx.node()), | 659 node=hex(fctx.node()), |
642 author=fctx.user(), | 660 author=fctx.user(), |
643 date=fctx.date(), | 661 date=fctx.date(), |
644 desc=fctx.description(), | 662 desc=fctx.description(), |
663 branch=self.nodebranchnodefault(fctx), | |
645 parent=self.siblings(fctx.parents()), | 664 parent=self.siblings(fctx.parents()), |
646 child=self.siblings(fctx.children()), | 665 child=self.siblings(fctx.children()), |
647 rename=self.renamelink(fl, n), | 666 rename=self.renamelink(fl, n), |
648 permissions=fctx.manifest().flags(f)) | 667 permissions=fctx.manifest().flags(f)) |
649 | 668 |
687 node=hex(fctx.node()), | 706 node=hex(fctx.node()), |
688 author=fctx.user(), | 707 author=fctx.user(), |
689 date=fctx.date(), | 708 date=fctx.date(), |
690 desc=fctx.description(), | 709 desc=fctx.description(), |
691 rename=self.renamelink(fl, n), | 710 rename=self.renamelink(fl, n), |
711 branch=self.nodebranchnodefault(fctx), | |
692 parent=self.siblings(fctx.parents()), | 712 parent=self.siblings(fctx.parents()), |
693 child=self.siblings(fctx.children()), | 713 child=self.siblings(fctx.children()), |
694 permissions=fctx.manifest().flags(f)) | 714 permissions=fctx.manifest().flags(f)) |
695 | 715 |
696 def manifest(self, tmpl, ctx, path): | 716 def manifest(self, tmpl, ctx, path): |
755 upparity=parity.next(), | 775 upparity=parity.next(), |
756 fentries=filelist, | 776 fentries=filelist, |
757 dentries=dirlist, | 777 dentries=dirlist, |
758 archives=self.archivelist(hex(node)), | 778 archives=self.archivelist(hex(node)), |
759 tags=self.nodetagsdict(node), | 779 tags=self.nodetagsdict(node), |
780 inbranch=self.nodeinbranch(ctx), | |
760 branches=self.nodebranchdict(ctx)) | 781 branches=self.nodebranchdict(ctx)) |
761 | 782 |
762 def tags(self, tmpl): | 783 def tags(self, tmpl): |
763 i = self.repo.tagslist() | 784 i = self.repo.tagslist() |
764 i.reverse() | 785 i.reverse() |
835 desc=ctx.description(), | 856 desc=ctx.description(), |
836 date=ctx.date(), | 857 date=ctx.date(), |
837 rev=i, | 858 rev=i, |
838 node=hn, | 859 node=hn, |
839 tags=self.nodetagsdict(n), | 860 tags=self.nodetagsdict(n), |
861 inbranch=self.nodeinbranch(ctx), | |
840 branches=self.nodebranchdict(ctx))) | 862 branches=self.nodebranchdict(ctx))) |
841 | 863 |
842 yield l | 864 yield l |
843 | 865 |
844 cl = self.repo.changelog | 866 cl = self.repo.changelog |
867 | 889 |
868 return tmpl("filediff", | 890 return tmpl("filediff", |
869 file=path, | 891 file=path, |
870 node=hex(n), | 892 node=hex(n), |
871 rev=fctx.rev(), | 893 rev=fctx.rev(), |
894 branch=self.nodebranchnodefault(fctx), | |
872 parent=self.siblings(parents), | 895 parent=self.siblings(parents), |
873 child=self.siblings(fctx.children()), | 896 child=self.siblings(fctx.children()), |
874 diff=diff) | 897 diff=diff) |
875 | 898 |
876 archive_specs = { | 899 archive_specs = { |