[PATCH 3 of 3] use per-directory clustered stat calls even in cases where known tree is walked
Benoit Boissinot
bboissin at gmail.com
Tue Sep 30 17:56:08 CDT 2008
On Tue, Sep 30, 2008 at 11:32 PM, Petr Kodl <petrkodl at gmail.com> wrote:
> # HG changeset patch
> # User Petr Kodl <petrkodl at gmail.com>
> # Date 1222809788 14400
> # Node ID 88d9e471e94e2914234f49c0d4e0cc49795aabe1
> # Parent 89c54a451554b0f9475fe08acbf167dbd065212d
> use per-directory clustered stat calls even in cases where known tree is walked
>
>
> diff -r 89c54a451554 -r 88d9e471e94e mercurial/dirstate.py
> --- a/mercurial/dirstate.py Tue Sep 30 17:23:08 2008 -0400
> +++ b/mercurial/dirstate.py Tue Sep 30 17:23:08 2008 -0400
> @@ -507,6 +507,15 @@
> if (nf in dmap or not ignore(nf)) and matchfn(nf):
> results[nf] = None
>
> + # if stat on whole directory is fast compared to stat on files
> + # avoid per-file lstat call in favor of per-directory call
> + # proceed normally if specific files are listed
> + recursive = 1
> + if util.fastdirstat() and not len(match.files()) and not len(work):
> + work.append('.')
> + work.extend(self._dirs.keys())
> + recursive = 0
> +
I'm not sure but I think it would be cleaner not to do this
and to do the clustering in step3.
using a fonction util.statfiles() that would yield (nf, stat or None
if not found)
then step 3 would look like:
for nf, st in util.statfiles(visit):
if st is not None:
kind = getkind(st.st_mode)
if ...:
st = None
results[nf] = st
(it could be a one-liner with dict.update() + some lambda, but since
we can't use
generators I don't think it's worth it :)
Then util.statfiles could cluster by directories on win32
(or just sort the files and lstat on unix).
Would it work ?
regards,
Benoit
More information about the Mercurial-devel
mailing list