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

Matt Mackall mpm at selenic.com
Wed Jun 11 23:39:58 CDT 2008


On Thu, 2008-06-12 at 03:28 +0200, Christian Ebert wrote:
> # HG changeset patch
> # User Christian Ebert <blacktrash at gmx.net>
> # Date 1212320112 -7200
> # Node ID a6c4ede8048dd4caa03f524e810fe28f21b4b679
> # Parent  bc553c6d1ef9b4360fe2fc6b65f50862e519d2fa
> keyword: use dirstate.parents to obtain current first parent
> 
> This should be quicker than changectx().node()
> 
> diff --git a/hgext/keyword.py b/hgext/keyword.py
> --- a/hgext/keyword.py
> +++ b/hgext/keyword.py
> @@ -509,7 +509,7 @@
>          comparing against working dir.'''
>          if node2 is not None:
>              kwt.matcher = util.never
> -        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, 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.

-- 
Mathematics is the supreme nostalgia of our time.



More information about the Mercurial-devel mailing list