diff rust/hg-cpython/src/parsers.rs @ 46507:68a15b5a7e58

rust: Replace DirstatePackError with HgError Differential Revision: https://phab.mercurial-scm.org/D9893
author Simon Sapin <simon.sapin@octobus.net>
date Wed, 27 Jan 2021 13:41:28 +0100
parents 496537c9c1b4
children 776b97179c06
line wrap: on
line diff
--- a/rust/hg-cpython/src/parsers.rs	Wed Jan 27 13:19:49 2021 +0100
+++ b/rust/hg-cpython/src/parsers.rs	Wed Jan 27 13:41:28 2021 +0100
@@ -15,8 +15,7 @@
 };
 use hg::{
     pack_dirstate, parse_dirstate, utils::hg_path::HgPathBuf, DirstateEntry,
-    DirstatePackError, DirstateParents, DirstateParseError, FastHashMap,
-    PARENT_SIZE,
+    DirstateParents, DirstateParseError, FastHashMap, PARENT_SIZE,
 };
 use std::convert::TryInto;
 
@@ -128,18 +127,9 @@
             }
             Ok(PyBytes::new(py, &packed))
         }
-        Err(error) => Err(PyErr::new::<exc::ValueError, _>(
-            py,
-            match error {
-                DirstatePackError::CorruptedParent => {
-                    "expected a 20-byte hash".to_string()
-                }
-                DirstatePackError::CorruptedEntry(e) => e,
-                DirstatePackError::BadSize(expected, actual) => {
-                    format!("bad dirstate size: {} != {}", actual, expected)
-                }
-            },
-        )),
+        Err(error) => {
+            Err(PyErr::new::<exc::ValueError, _>(py, error.to_string()))
+        }
     }
 }