Patchwork D9671: rust: fix file folding map

login
register
mail settings
Submitter phabricator
Date Dec. 30, 2020, 12:01 p.m.
Message ID <differential-rev-PHID-DREV-koq43k3f3bd372cu74qa-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47982/
State Superseded
Headers show

Comments

phabricator - Dec. 30, 2020, 12:01 p.m.
danchr created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

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

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate/dirstate_map.rs
  rust/hg-cpython/src/dirstate/dirstate_map.rs

CHANGE DETAILS




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

Patch

diff --git a/rust/hg-cpython/src/dirstate/dirstate_map.rs b/rust/hg-cpython/src/dirstate/dirstate_map.rs
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs
+++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs
@@ -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)
diff --git a/rust/hg-core/src/dirstate/dirstate_map.rs b/rust/hg-core/src/dirstate/dirstate_map.rs
--- a/rust/hg-core/src/dirstate/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate/dirstate_map.rs
@@ -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());
             }