[PATCH 1 of 3] keyword: use dirstate.parents to obtain current first parent

Matt Mackall mpm at selenic.com
Thu Jun 12 02:41:50 CDT 2008


On Thu, 2008-06-12 at 08:39 +0200, Christian Ebert wrote:
> * Matt Mackall on Wednesday, June 11, 2008 at 23:39:58 -0500
> > On Thu, 2008-06-12 at 03:28 +0200, Christian Ebert wrote:
> >> This should be quicker than changectx().node()
> 
> [...]
> 
> >> -        elif node1 is not None and node1 != repo.changectx().node():
> >> +        elif node1 is not None and node1 != repo.dirstate.parents()[0]:
> > 
> > Really? You're right,
> 
> phew
> 
> > it is about 5 times faster. But it's a difference between 2us
> > and 10us here. Unless this is in a loop, it's never going to
> > show up in a profile.
> 
> Sure. Just trying to make the extension's footprint as small as possible.

Unfortunately, I think this is a step in the wrong direction. But only a
minor one. This operation is very common and I'd like to see this
operation get simpler, not more complicated. It should go from:

repo.dirstate.parents()[0] 

to perhaps something like:

repo.parent1()  # maybe this takes an optional node arg

Or maybe we add a [] method to repo to get a context, so this becomes:

repo["."].node()

We should move away from people having to know about dirstates, and just
work with contexts.

-- 
Mathematics is the supreme nostalgia of our time.



More information about the Mercurial-devel mailing list