[PATCH] hgweb: add heads to gitweb summary

Matt Mackall mpm at selenic.com
Mon Oct 23 19:50:20 UTC 2006


On Mon, Oct 23, 2006 at 11:35:02AM -0700, Brendan Cully wrote:
> 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).

> # 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

Eep, no! Loading the branch tags can be expensive and should only be
done as a last resort. Especially with hgweb, which may not be able to
write out the branch cache. 

Instead, read the branch labels directly out of the changeset using
changectx.branch().

Also, be careful not to confuse branches and heads, they're slightly
different concepts.

-- 
Mathematics is the supreme nostalgia of our time.



More information about the Mercurial-devel mailing list