This is an archive of the discontinued Mercurial Phabricator instance.

dirstate-v2: Drop cached read_dir results after .hgignore changes
ClosedPublic

Authored by SimonSapin on Jun 24 2021, 4:52 PM.

Details

Summary

Soon we’ll want the status algorithm to be able to skip std::fs::read_dir in
more cases, notabling when listing unknown files but not ignored files.

When ignore patterns change (which we detect by their hash, added to the
dirstate-v2 format in a previous changeset), a formerly-ignored file could
become unknown without changing its parent directory’s modification time.
Therefore we remove any directory mtime from the dirstate, effictively
invalidating the existing caches.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

SimonSapin created this revision.Jun 24 2021, 4:52 PM

Won't this potentially miss some directories if we're in a partial match for example?

Good question. At the moment the matcher is only consulted for files and symlinks. Later if we add an optimization to skip "full" subtree traversal of unmatched directories, we’ll likely need to have a simpler traversal that only checks for outdated cache.

Alphare accepted this revision.Jul 2 2021, 11:59 AM
This revision is now accepted and ready to land.Jul 2 2021, 11:59 AM