[PATCH] Yield files in ignored directories directly in statwalk()

Alexis S. L. Carvalho alexis at cecm.usp.br
Mon Sep 3 00:35:59 CDT 2007

Thus spake Emanuele Aina:
> Alexis S. L. Carvalho commentò:
> >> @@ -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.
> I see. Maybe I can use something similar to a trie to store the dirstate
> content so it becomes trivial to get the items in a directory.
> Any ideas that doesn't require introducing a new ad-hoc and complex data
> structure?

I think I'm leaning towards just changing purge to do something like
this before calling statwalk:

if name_mangling_fs():
    modified, added, removed, deleted = repo.status()[:4]
    if modified or added or removed or deleted:
	if not opts.get('force'):
            util.Abort('there are uncommitted changes and purge may '
                       'accidentally remove a tracked file. use --force to '
        # maybe a warning?

Where name_mangling_fs calls checkfolding and some function that tries
to detect the unicode mangling done by hfs+.

It will need an extra working dir walk in these filesystems, but should
be quite a bit simpler than other alternatives.

> > 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.
> My intent was moving those checks directly in statwalk() but maybe I've
> forgot something. I really need to look into adding tests to be run on
> case insensitive fs, maybe using hghave.
> > 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.
> I'd really like to gather all the walking logic in dirstate.statwalk()
> moving the additional dirstate.status() checks there, so it can be
> reused easily.

Yeah, I also want to move in that direction.


More information about the Mercurial-devel mailing list