[PATCH 1 of 2 V2] changectx: increase perf of walk function
sid0 at fb.com
Tue Jan 14 19:35:43 CST 2014
On 01/14/2014 01:52 PM, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham at fb.com>
> # Date 1389736159 28800
> # Tue Jan 14 13:49:19 2014 -0800
> # Node ID 9c531e73a03eb7ddd809da0778d98612ae41134e
> # Parent 47d0843647d1e32f6af4482867327cec5db11a1f
> changectx: increase perf of walk function
> When running 'hg cat -r . <file>' it was doing an expensive ctx.walk(m) which
> applied the regex to every file in the manifest.
> This changes changectx.walk to iterate over just the files in the regex, if no
> other patterns are specified. This cuts hg cat time by 50% in our repo and
> probably benefits a few other commands as well.
> diff --git a/mercurial/context.py b/mercurial/context.py
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -410,6 +410,15 @@
> # for dirstate.walk, files=['.'] means "walk the whole tree".
> # follow that here, too
> + # avoid the entire walk if we're only looking for specific files
> + if fset and not match.anypats():
> + if util.all([fn in self for fn in fset]):
> + for fn in sorted(fset):
> + if match(fn):
> + yield fn
I think you don't need 'if match(fn)': since fset is derived from
match.files(), you should just be able to yield fn.
More information about the Mercurial-devel