Mercurial > hg
diff rust/hg-core/src/dirstate.rs @ 47106:52906934b775
dirstate-tree: Add has_dir and has_tracked_dir
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.
Differential Revision: https://phab.mercurial-scm.org/D10490
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Mon, 12 Apr 2021 19:46:24 +0200 |
parents | 787ff5d21bcd |
children | e3cebe96c0fc |
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate.rs Mon Apr 12 18:42:51 2021 +0200 +++ b/rust/hg-core/src/dirstate.rs Mon Apr 12 19:46:24 2021 +0200 @@ -66,6 +66,16 @@ Unknown, } +impl EntryState { + pub fn is_tracked(self) -> bool { + use EntryState::*; + match self { + Normal | Added | Merged => true, + Removed | Unknown => false, + } + } +} + impl TryFrom<u8> for EntryState { type Error = HgError;