diff rust/hg-core/src/dirstate_tree/dispatch.rs @ 48047:9b2a51b2c36a

dirstate: Propagate dirstate-v2 parse errors from set_dirstate_item ? so that Python sees a proper ValueError instead of only `SystemError: Rust panic` Differential Revision: https://phab.mercurial-scm.org/D11489
author Simon Sapin <simon.sapin@octobus.net>
date Wed, 22 Sep 2021 18:56:58 +0200
parents 32ef647821b2
children 76f1c76186a1
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate_tree/dispatch.rs	Wed Sep 22 18:42:00 2021 +0200
+++ b/rust/hg-core/src/dirstate_tree/dispatch.rs	Wed Sep 22 18:56:58 2021 +0200
@@ -39,7 +39,11 @@
 
     /// Add the given filename to the map if it is not already there, and
     /// associate the given entry with it.
-    fn set_entry(&mut self, filename: &HgPath, entry: DirstateEntry);
+    fn set_entry(
+        &mut self,
+        filename: &HgPath,
+        entry: DirstateEntry,
+    ) -> Result<(), DirstateV2ParseError>;
 
     /// Add or change the information associated to a given file.
     ///
@@ -321,8 +325,13 @@
     ///
     /// XXX Is temporary during a refactor of V1 dirstate and will disappear
     /// shortly.
-    fn set_entry(&mut self, filename: &HgPath, entry: DirstateEntry) {
-        self.set_entry(&filename, entry)
+    fn set_entry(
+        &mut self,
+        filename: &HgPath,
+        entry: DirstateEntry,
+    ) -> Result<(), DirstateV2ParseError> {
+        self.set_entry(&filename, entry);
+        Ok(())
     }
 
     fn add_file(