This is an archive of the discontinued Mercurial Phabricator instance.

dirstate-tree: Add has_dir and has_tracked_dir
ClosedPublic

Authored by SimonSapin on Apr 20 2021, 10:17 AM.

Details

Summary

A node without a DirstateMap entry represents a directory.

Only some values of EntryState represent tracked files.
A directory is considered "tracked" if it contains any descendant file that
is tracked. To avoid a sub-tree traversal in has_tracked_dir we add a
counter for this. A boolean flag would become insufficent when we implement
remove_file and drop_file.

add_file_node is more general than needed here, in anticipation of adding
the add_file and remove_file methods.

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.Apr 20 2021, 10:17 AM
baymax updated this revision to Diff 27140.Apr 20 2021, 1:03 PM

✅ refresh by Heptapod after a successful CI run (🐙 💚)

Alphare added inline comments.
rust/hg-core/src/dirstate_tree/dirstate_map.rs
57

Not always true: a file that used to be a directory with one or more children that have all been marked as removed will have children.

SimonSapin added inline comments.May 3 2021, 6:02 AM
rust/hg-core/src/dirstate_tree/dirstate_map.rs
57

Indeed. I’ll remove this comment.

SimonSapin updated this revision to Diff 27316.May 3 2021, 6:24 AM
Alphare accepted this revision.May 3 2021, 9:01 AM
This revision is now accepted and ready to land.May 3 2021, 9:01 AM
This revision was automatically updated to reflect the committed changes.