[PATCH 6 of 6] revset: fix a crash with 'roots(wdir())'

Yuya Nishihara yuya at tcha.org
Thu Jul 2 10:02:38 CDT 2015


On Wed, 01 Jul 2015 21:28:47 -0400, Matt Harbison wrote:
> On Wed, 01 Jul 2015 09:01:17 -0400, Yuya Nishihara <yuya at tcha.org> wrote:
> > 3) can we have a function that is as fast as cl.parentrevs(r) and can  
> > process
> >    wdir() ?
> 
> Something like this in revset.py?  It looks like an optimization to not go  
> through context.
> 
> def _parentrevs(repo, cl, r):
>      if r is not None:
>          return cl.parentrevs(r)
>      else:
>          return [p.rev() for p in repo[r].parents()]

I don't have a good idea, but something like 'repo.parentrevs()'. I know we
shouldn't add new function to localrepo, but it will have to access both
changelog and dirstate to process the wdir revision seamlessly.

> The only reason I didn't do it was because with the local changelog  
> caching optimization, I assumed calling a function over and over would be  
> unacceptable overhead.

Probably yes. revset functions avoid extra name lookup and function calls in
heavy loop.


More information about the Mercurial-devel mailing list