[PATCH] hgweb: add heads to gitweb summary
Brendan Cully
brendan at kublai.com
Mon Oct 23 18:35:02 UTC 2006
On Friday, 13 October 2006 at 11:05, Thomas Arendsen Hein wrote:
> * Brendan Cully <brendan at kublai.com> [20061013 00:39]:
> > + def heads(**map):
> > + parity = 0
> > + count = 0
> > +
> > + branches = self.repo.branchlookup(self.repo.heads())
> > + revs = dict.fromkeys([cl.rev(n) for n in branches]).keys()
>
> I'm not sure if using the known-to-be-replaced branch code here is
> good, so showing the hash might be a better option for now.
>
> Additionally we can get around the problem with conflicting command
> names with cmd=heads vs. http://hg.kublai.com/mercurial/crew/heads
> easily now: If the NWI heads command is mapped to cmd=somethingelse,
> then we can show a separate page here.
>
> But having it on the summary page is useful anyway.
Here's an updated version that uses the new branchtags code (showing
the short hash if there's no tag for a head).
-------------- next part --------------
# HG changeset patch
# User Brendan Cully <brendan at kublai.com>
# Date 1161628292 25200
# Node ID 5590dbf961707f9f315c9acfb74da84ebeec4187
# Parent c3345b0f2fcdb3bb8cf3a6bf572159ec7e190a90
hgweb: add heads to gitweb summary
diff -r c3345b0f2fcd -r 5590dbf96170 mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py Mon Oct 23 14:56:51 2006 +0200
+++ b/mercurial/hgweb/hgweb_mod.py Mon Oct 23 11:31:32 2006 -0700
@@ -527,6 +527,29 @@ class hgweb(object):
date = t)
parity += 1
+ def heads(**map):
+ parity = 0
+ count = 0
+
+ branches = {}
+ for label, node in self.repo.branchtags().iteritems():
+ branches[node] = label
+ revs = [cl.rev(n) for n in self.repo.heads()]
+ revs.sort(lambda x, y: -cmp(x,y))
+ for node in [cl.node(n) for n in revs]:
+ count += 1
+ if count > 10:
+ break;
+
+ c = cl.read(node)
+
+ yield self.t('tagentry',
+ parity = self.stripes(parity),
+ tag = branches.get(node, short(node)),
+ node = hex(node),
+ date = c[2])
+ parity += 1
+
def changelist(**map):
parity = 0
cl = self.repo.changelog
@@ -560,6 +583,7 @@ class hgweb(object):
self.repo.ui.config("web", "author", "unknown")), # also
lastchange = cl.read(cl.tip())[2],
tags = tagentries,
+ heads = heads,
shortlog = changelist,
node = hex(cl.tip()),
archives=self.archivelist("tip"))
diff -r c3345b0f2fcd -r 5590dbf96170 templates/gitweb/summary.tmpl
--- a/templates/gitweb/summary.tmpl Mon Oct 23 14:56:51 2006 +0200
+++ b/templates/gitweb/summary.tmpl Mon Oct 23 11:31:32 2006 -0700
@@ -36,4 +36,12 @@ summary |
<tr class="light"><td colspan="3"><a class="list" href="{url}tags{sessionvars%urlparameter}">...</a></td></tr>
</table>
+<div><a class="title"
+href="{url}tags{sessionvars%urlparameter}">heads</a></div>
+<table cellspacing="0">
+{heads}
+<tr class="light">
+ <td colspan="3"><a class="list" href="{url}tags{sessionvars%urlparameter}">...</a></td>
+</tr>
+</table>
#footer#
More information about the Mercurial-devel
mailing list