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

Emanuele Aina faina.mail at tiscali.it
Tue Aug 28 14:23:05 UTC 2007


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?

>> @@ -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.

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.

-- 
Buongiorno.
Complimenti per l'ottima scelta.





More information about the Mercurial-devel mailing list