On Wed, 17 Jan 2018 22:14:29 -0500, Jordi Gutiérrez Hermoso wrote: > # HG changeset patch > # User Jordi Gutiérrez Hermoso <jord...@octave.org> > # Date 1516242948 18000 > # Wed Jan 17 21:35:48 2018 -0500 > # Node ID 701f8a9defdc09bb63f2596e2fc426f2e78da313 > # Parent 0e369eca888fc80ee980fe8200c59dc7b0024dae > templatekw: add utility function numrevs > > len(repo) calls incur noticeable overhead if called for each revision > a template keyword is evaluated.
Do you have some number? It's just a proxy to revlog.__len__(), so I think it is super fast. > --- a/mercurial/templatekw.py > +++ b/mercurial/templatekw.py > @@ -852,6 +852,10 @@ def showrev(repo, ctx, templ, **args): > """Integer. The repository-local changeset revision number.""" > return scmutil.intrev(ctx) > > +@util.cachefunc > +def numrevs(repo): > + return len(repo) It leaks repo forever as the cache is keyed by arguments. args['cache'] can be used instead. _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel