rust-config: fix incorrect coercion of null values to false
authorRaphaël Gomès <rgomes@octobus.net>
Wed, 09 Aug 2023 15:46:35 +0200
changeset 50983 8343947af6a7
parent 50982 10e57e3f7276
child 50987 727428c7e1fc
rust-config: fix incorrect coercion of null values to false As explained in the previous changeset: Probably being too trigger happy about boolean values, I incorrectly set the transform for a `None` to a `Some(false)`. It would cause for example the `ui.formatted` value to be set to `Some(false)`, which turns off the colors among other things, when `None` would trigger the automatic behavior.
rust/hg-core/src/config/config_items.rs
rust/hg-core/src/config/mod.rs
--- a/rust/hg-core/src/config/config_items.rs	Wed Aug 09 15:44:56 2023 +0200
+++ b/rust/hg-core/src/config/config_items.rs	Wed Aug 09 15:46:35 2023 +0200
@@ -198,7 +198,7 @@
                     _ => Err(err),
                 }
             }
-            None => Ok(Some(false)),
+            None => Ok(None),
         }
     }
 }
--- a/rust/hg-core/src/config/mod.rs	Wed Aug 09 15:44:56 2023 +0200
+++ b/rust/hg-core/src/config/mod.rs	Wed Aug 09 15:46:35 2023 +0200
@@ -805,7 +805,6 @@
         assert!(ret.is_ok(), "{:?}", ret);
 
         let ret = config.get_byte_size(b"ui", b"formatted");
-        // FIXME should be `is_none()`
-        assert!(ret.unwrap().is_some());
+        assert!(ret.unwrap().is_none());
     }
 }