[PATCH] Yield files in ignored directories directly in statwalk()
Alexis S. L. Carvalho
alexis at cecm.usp.br
Wed Jul 11 18:35:18 CDT 2007
Thus spake Emanuele Aina:
> Emanuele Aina suggerì:
>
> >dirstate.statwalk() returns tracked files in ignored directories as
> >missing and
> >dirstate.status() goes a great length to check if those are still there.
> >
> >What about if statwalk, when encountering an ignored directory, would scan
> >the
> >tracked files list yielding those under the ignored directory?
>
> This patch implements the approach described above.
>
> --
> Buongiorno.
> Complimenti per l'ottima scelta.
>
> # HG changeset patch
> # User Emanuele Aina <em at nerd.ocracy.org>
> # Date 1183928858 -7200
> # Node ID 0ebd22bf7db8ca90b2337a7ee82c04271d0145d5
> # Parent 80bb627ae7238ea14d19cf892575409f40bc3880
> Yield files in ignored directories directly in statwalk()
>
> diff -r 80bb627ae723 -r 0ebd22bf7db8 mercurial/dirstate.py
> --- a/mercurial/dirstate.py Mon Jul 02 23:30:35 2007 +0200
> +++ b/mercurial/dirstate.py Sun Jul 08 23:07:38 2007 +0200
> @@ -371,6 +371,18 @@ class dirstate(object):
> if hg < len(names) and names[hg] == '.hg':
> if os.path.isdir(os.path.join(top, '.hg')):
> continue
> + if ignore(nd):
> + for fn in dc:
I don't really like this - some projects have a lot of ignored
directories and iterating through dc every time we get to one of them
can add quite a bit of overhead.
> @@ -451,23 +462,11 @@ class dirstate(object):
> else:
> unknown.append(fn)
> continue
> - if src == 'm':
> - nonexistent = True
> - if not st:
> - try:
> - st = os.lstat(self.wjoin(fn))
> - except OSError, inst:
> - if inst.errno != errno.ENOENT:
> - raise
> - st = None
> - # We need to re-check that it is a valid file
> - if st and self._supported(fn, st):
> - nonexistent = False
> - # XXX: what to do with file no longer present in the fs
> - # who are not removed in the dirstate ?
> - if nonexistent and type_ in "nm":
> - deleted.append(fn)
> - continue
> + # XXX: what to do with file no longer present in the fs
> + # who are not removed in the dirstate ?
> + if src == 'm' and type_ in "nm":
> + deleted.append(fn)
> + continue
Removing the lstat above can break things in case-insensitive
filesystems (e.g. somebody does mv foo Foo in a non-ignored directory).
Moving it to the last loop in statwalk might make sense, but I don't
think that will help purge - it will probably even defeat purge's tests.
I'm not sure what's the best thing to do here. The easiest thing for
purge is probably to change _check_missing to forget about files in
found that are in some ignored directory.
Alexis
More information about the Mercurial-devel
mailing list