Mercurial > hg
diff rust/hg-cpython/src/dirstate/dirs_multiset.rs @ 43788:1fe2e574616e
rust-dirs: address failing tests for `dirs` impl with a temporary fix
https://phab.mercurial-scm.org/D7252 (5d40317d42b7083b49467502549e25f144888cb3)
introduced a regression in Rust tests.
This is a temporary fix that replicates the behavior of the C and Python impl,
pending the resolution of the discussion (in the phabricator link) about how
we actually want to solve this problem.
Differential Revision: https://phab.mercurial-scm.org/D7503
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Fri, 22 Nov 2019 10:39:05 +0100 |
parents | 8418b77132c1 |
children | bc7d8f45c3b6 |
line wrap: on
line diff
--- a/rust/hg-cpython/src/dirstate/dirs_multiset.rs Sun Dec 01 18:46:10 2019 -0500 +++ b/rust/hg-cpython/src/dirstate/dirs_multiset.rs Fri Nov 22 10:39:05 2019 +0100 @@ -68,8 +68,19 @@ def addpath(&self, path: PyObject) -> PyResult<PyObject> { self.inner_shared(py).borrow_mut()?.add_path( HgPath::new(path.extract::<PyBytes>(py)?.data(py)), - ); - Ok(py.None()) + ).and(Ok(py.None())).or_else(|e| { + match e { + DirstateMapError::EmptyPath => { + Ok(py.None()) + }, + e => { + Err(PyErr::new::<exc::ValueError, _>( + py, + e.to_string(), + )) + } + } + }) } def delpath(&self, path: PyObject) -> PyResult<PyObject> { @@ -79,15 +90,15 @@ .and(Ok(py.None())) .or_else(|e| { match e { - DirstateMapError::PathNotFound(_p) => { + DirstateMapError::EmptyPath => { + Ok(py.None()) + }, + e => { Err(PyErr::new::<exc::ValueError, _>( py, - "expected a value, found none".to_string(), + e.to_string(), )) } - DirstateMapError::EmptyPath => { - Ok(py.None()) - } } }) }