rust-dirstate: don't return a state for untracked entries
authorRaphaël Gomès <rgomes@octobus.net>
Mon, 28 Mar 2022 18:53:55 +0200
changeset 49045 a85c123c625a
parent 49044 be9bf75a837c
child 49051 1d6c6ad645e1
rust-dirstate: don't return a state for untracked entries This `state` API is a remnant of the former API and is slated for removal at some point. Any caller of this function will expect an entry that is tracked in the larger sense. Differential Revision: https://phab.mercurial-scm.org/D12448
rust/hg-core/src/dirstate_tree/dirstate_map.rs
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs	Tue Mar 22 16:33:18 2022 +0100
+++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs	Mon Mar 28 18:53:55 2022 +0200
@@ -343,7 +343,13 @@
     pub(super) fn state(
         &self,
     ) -> Result<Option<EntryState>, DirstateV2ParseError> {
-        Ok(self.entry()?.map(|e| e.state()))
+        Ok(self.entry()?.and_then(|e| {
+            if e.any_tracked() {
+                Some(e.state())
+            } else {
+                None
+            }
+        }))
     }
 
     pub(super) fn cached_directory_mtime(