[PATCH] keyword: avoid repeated context retrieval on commit

Matt Mackall mpm at selenic.com
Fri Nov 14 13:33:41 CST 2008


On Fri, 2008-11-14 at 17:53 +0100, Christian Ebert wrote:
> # HG changeset patch
> # User Christian Ebert <blacktrash at gmx.net>
> # Date 1226681182 -3600
> # Node ID 65472844ddce26a78046e5cdee3580a1334fc91e
> # Parent  d9e9dd2b00fbaf9469d847948232f50b70423511
> keyword: avoid repeated context retrieval on commit
> 
> diff --git a/hgext/keyword.py b/hgext/keyword.py
> --- a/hgext/keyword.py
> +++ b/hgext/keyword.py
> @@ -139,19 +139,19 @@
>          self.ct = cmdutil.changeset_templater(self.ui, self.repo,
>                                                False, '', False)
>  
> -    def getnode(self, path, fnode):
> +    def getkctx(self, path, fnode):
>          '''Derives changenode from file path and filenode.'''
>          # used by kwfilelog.read and kwexpand
>          c = self.repo.filectx(path, fileid=fnode)
> -        return c.node()
> +        return self.repo[c.node()]

return self.repo.filectx(path, fileid=fnode).changectx()

But it would be more efficient to pass in a linkrev here and go directly
to return self.repo[linkrev].

-- 
Mathematics is the supreme nostalgia of our time.



More information about the Mercurial-devel mailing list