changeset 46227:5bae4bc9bd42

rust: fix file folding map The file folding map, frequently used on macOS, had two issues: * the means for converting it to Python didn't work * a minor typo when copying the python code, where `!=` became `==` With this, the rust code passes all tests on macOS. Test Plan: I'm currently doing a full test run on a case-insensitive file system. If it passes, perhaps we can change the platform check from an error to a warning? Differential Revision: https://phab.mercurial-scm.org/D9671
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Wed, 30 Dec 2020 00:14:28 +0100
parents 0826d684a1b5
children e73b40c790ec
files rust/hg-core/src/dirstate/dirstate_map.rs rust/hg-cpython/src/dirstate/dirstate_map.rs
diffstat 2 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate/dirstate_map.rs	Tue Jan 12 22:43:55 2021 +0100
+++ b/rust/hg-core/src/dirstate/dirstate_map.rs	Wed Dec 30 00:14:28 2020 +0100
@@ -431,7 +431,7 @@
         let mut new_file_fold_map = FileFoldMap::default();
 
         for (filename, DirstateEntry { state, .. }) in self.state_map.iter() {
-            if *state == EntryState::Removed {
+            if *state != EntryState::Removed {
                 new_file_fold_map
                     .insert(normalize_case(&filename), filename.to_owned());
             }
@@ -447,7 +447,7 @@
         let mut new_file_fold_map = FileFoldMap::default();
 
         for (filename, DirstateEntry { state, .. }) in self.state_map.iter() {
-            if state == EntryState::Removed {
+            if state != EntryState::Removed {
                 new_file_fold_map
                     .insert(normalize_case(&filename), filename.to_owned());
             }
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs	Tue Jan 12 22:43:55 2021 +0100
+++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs	Wed Dec 30 00:14:28 2020 +0100
@@ -350,8 +350,8 @@
         {
             dict.set_item(
                 py,
-                key.as_bytes().to_vec(),
-                value.as_bytes().to_vec(),
+                PyBytes::new(py, key.as_bytes()).into_object(),
+                PyBytes::new(py, value.as_bytes()).into_object(),
             )?;
         }
         Ok(dict)