[PATCH 1 of 2] hgweb_mod: add branch helper functions to use in templates

Florent Guillaume fg at nuxeo.com
Thu Mar 13 17:48:49 CDT 2008


# HG changeset patch
# User Florent Guillaume <fg at nuxeo.com>
# Date 1205448335 -3600
# Node ID 8cd62bcad647fa2a78e73669fd22556c2a0ff652
# Parent  b36774d0fce1f7d85a50f0618036f3fdda9ebde2
hgweb_mod: add branch helper functions to use in templates

diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py
+++ b/mercurial/hgweb/hgweb_mod.py
@@ -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)


More information about the Mercurial-devel mailing list