Patchwork D12448: rust-dirstate: don't return a state for untracked entries

login
register
mail settings
Submitter phabricator
Date April 6, 2022, 2:10 p.m.
Message ID <differential-rev-PHID-DREV-vkr7vegtyhvfw6rldv54-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50793/
State New
Headers show

Comments

phabricator - April 6, 2022, 2:10 p.m.
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12448

AFFECTED FILES
  rust/hg-core/src/dirstate_tree/dirstate_map.rs

CHANGE DETAILS




To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/rust/hg-core/src/dirstate_tree/dirstate_map.rs b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
@@ -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(