changeset 4300:05d15c456fb2

hgweb: display named branches in gitweb-style summary page
author greg@maptuit.com
date Fri, 16 Mar 2007 17:55:42 -0400
parents 6b1e1b9da853
children f344440fdcb0
files mercurial/hgweb/hgweb_mod.py templates/gitweb/map templates/gitweb/summary.tmpl
diffstat 3 files changed, 28 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/hgweb_mod.py	Tue Mar 27 01:41:23 2007 -0300
+++ b/mercurial/hgweb/hgweb_mod.py	Fri Mar 16 17:55:42 2007 -0400
@@ -530,6 +530,23 @@
                              date=self.repo.changectx(n).date())
                 parity += 1
 
+
+        def branches(**map):
+            parity = 0
+
+            b = self.repo.branchtags()
+            l = [(-self.repo.changelog.rev(n), n, t) for t, n in b.items()]
+            l.sort()
+
+            for r,n,t in l:
+                ctx = self.repo.changectx(n)
+
+                yield {'parity': self.stripes(parity),
+                       'branch': t,
+                       'node': hex(n),
+                       'date': ctx.date()}
+                parity += 1
+
         def heads(**map):
             parity = 0
             count = 0
@@ -578,6 +595,7 @@
                         self.config("web", "author", "unknown")), # also
                  lastchange=cl.read(cl.tip())[2],
                  tags=tagentries,
+                 branches=branches,
                  heads=heads,
                  shortlog=changelist,
                  node=hex(cl.tip()),
--- a/templates/gitweb/map	Tue Mar 27 01:41:23 2007 -0300
+++ b/templates/gitweb/map	Fri Mar 16 17:55:42 2007 -0400
@@ -40,6 +40,7 @@
 tags = tags.tmpl
 tagentry = '<tr class="parity#parity#"><td class="age"><i>#date|age# ago</i></td><td><a class="list" href="{url}rev/{node|short}{sessionvars%urlparameter}"><b>#tag|escape#</b></a></td><td class="link"><a href="{url}rev/#node|short#{sessionvars%urlparameter}">changeset</a> | <a href="{url}log/#node|short#{sessionvars%urlparameter}">changelog</a> | <a href="{url}file/#node|short#{sessionvars%urlparameter}">manifest</a></td></tr>'
 headentry = '<tr class="parity{parity}"><td class="age"><i>{date|age} ago</i></td><td><a class="list" href="{url}rev/{node|short}{sessionvars%urlparameter}"><b>{node|short}</td><td>{branch|escape}</td><td class="link"><a href="{url}rev/{node|short}{sessionvars%urlparameter}">changeset</a> | <a href="{url}log/{node|short}{sessionvars%urlparameter}">changelog</a> | <a href="{url}file/{node|short}{sessionvars%urlparameter}">manifest</a></td></tr>'
+branchentry = '<tr class="parity{parity}"><td class="age"><i>{date|age} ago</i></td><td><a class="list" href="{url}rev/{node|short}{sessionvars%urlparameter}"><b>{node|short}</b></td><td>{branch|escape}</td><td class="link"><a href="{url}rev/{node|short}{sessionvars%urlparameter}">changeset</a> | <a href="{url}log/{node|short}{sessionvars%urlparameter}">changelog</a> | <a href="{url}file/{node|short}{sessionvars%urlparameter}">manifest</a></td></tr>'
 diffblock = '<pre>#lines#</pre>'
 changelogtag = '<tr><th class="tag">tag:</th><td class="tag">#tag|escape#</td></tr>'
 changesettag = '<tr><td>tag</td><td>#tag|escape#</td></tr>'
--- a/templates/gitweb/summary.tmpl	Tue Mar 27 01:41:23 2007 -0300
+++ b/templates/gitweb/summary.tmpl	Fri Mar 16 17:55:42 2007 -0400
@@ -36,8 +36,15 @@
 <tr class="light"><td colspan="3"><a class="list" href="{url}tags{sessionvars%urlparameter}">...</a></td></tr>
 </table>
 
-<div><a class="title"
-href="#">heads</a></div>
+<div><a class="title" href="#">branches</a></div>
+<table cellspacing="0">
+{branches%branchentry}
+<tr class="light">
+  <td colspan="3"><a class="list"  href="#">...</a></td>
+</tr>
+</table>
+
+<div><a class="title" href="#">heads</a></div>
 <table cellspacing="0">
 {heads%headentry}
 <tr class="light">