# HG changeset patch # User Florent Guillaume # Date 1205448335 -3600 # Node ID cf1fa60fdaf47f8c6d28f52bc9c332827b5c101d # Parent b4fca699c33de134a7d9fa766ed684cfd9c1a2cc hgweb_mod: add branch helper functions to use in templates diff -r b4fca699c33d -r cf1fa60fdaf4 mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py Thu Mar 13 19:53:02 2008 -0700 +++ b/mercurial/hgweb/hgweb_mod.py Thu Mar 13 23:45:35 2008 +0100 @@ -367,6 +367,20 @@ branches.append({"name": branch}) return branches + def nodeinbranch(self, ctx): + branches = [] + branch = ctx.branch() + if branch != 'default' and self.repo.branchtags().get(branch) != ctx.node(): + branches.append({"name": branch}) + return branches + + def nodebranchnodefault(self, ctx): + branches = [] + branch = ctx.branch() + if branch != 'default': + branches.append({"name": branch}) + return branches + def showtag(self, tmpl, t1, node=nullid, **args): for t in self.repo.nodetags(node): yield tmpl(t1, tag=t, **args) @@ -458,6 +472,7 @@ "rev": i, "node": hex(n), "tags": self.nodetagsdict(n), + "inbranch": self.nodeinbranch(ctx), "branches": self.nodebranchdict(ctx)}) if limit > 0: @@ -529,6 +544,7 @@ rev=ctx.rev(), node=hex(n), tags=self.nodetagsdict(n), + inbranch=self.nodeinbranch(ctx), branches=self.nodebranchdict(ctx)) if count >= self.maxchanges: @@ -572,6 +588,8 @@ files=files, archives=self.archivelist(hex(n)), tags=self.nodetagsdict(n), + branch=self.nodebranchnodefault(ctx), + inbranch=self.nodeinbranch(ctx), branches=self.nodebranchdict(ctx)) def filelog(self, tmpl, fctx): @@ -642,6 +660,7 @@ author=fctx.user(), date=fctx.date(), desc=fctx.description(), + branch=self.nodebranchnodefault(fctx), parent=self.siblings(fctx.parents()), child=self.siblings(fctx.children()), rename=self.renamelink(fl, n), @@ -689,6 +708,7 @@ date=fctx.date(), desc=fctx.description(), rename=self.renamelink(fl, n), + branch=self.nodebranchnodefault(fctx), parent=self.siblings(fctx.parents()), child=self.siblings(fctx.children()), permissions=fctx.manifest().flags(f)) @@ -757,6 +777,7 @@ dentries=dirlist, archives=self.archivelist(hex(node)), tags=self.nodetagsdict(node), + inbranch=self.nodeinbranch(ctx), branches=self.nodebranchdict(ctx)) def tags(self, tmpl): @@ -837,6 +858,7 @@ rev=i, node=hn, tags=self.nodetagsdict(n), + inbranch=self.nodeinbranch(ctx), branches=self.nodebranchdict(ctx))) yield l @@ -869,6 +891,7 @@ file=path, node=hex(n), rev=fctx.rev(), + branch=self.nodebranchnodefault(fctx), parent=self.siblings(parents), child=self.siblings(fctx.children()), diff=diff)