comparison 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
comparison
equal deleted inserted replaced
43787:be8552f25cab 43788:1fe2e574616e
66 } 66 }
67 67
68 def addpath(&self, path: PyObject) -> PyResult<PyObject> { 68 def addpath(&self, path: PyObject) -> PyResult<PyObject> {
69 self.inner_shared(py).borrow_mut()?.add_path( 69 self.inner_shared(py).borrow_mut()?.add_path(
70 HgPath::new(path.extract::<PyBytes>(py)?.data(py)), 70 HgPath::new(path.extract::<PyBytes>(py)?.data(py)),
71 ); 71 ).and(Ok(py.None())).or_else(|e| {
72 Ok(py.None()) 72 match e {
73 DirstateMapError::EmptyPath => {
74 Ok(py.None())
75 },
76 e => {
77 Err(PyErr::new::<exc::ValueError, _>(
78 py,
79 e.to_string(),
80 ))
81 }
82 }
83 })
73 } 84 }
74 85
75 def delpath(&self, path: PyObject) -> PyResult<PyObject> { 86 def delpath(&self, path: PyObject) -> PyResult<PyObject> {
76 self.inner_shared(py).borrow_mut()?.delete_path( 87 self.inner_shared(py).borrow_mut()?.delete_path(
77 HgPath::new(path.extract::<PyBytes>(py)?.data(py)), 88 HgPath::new(path.extract::<PyBytes>(py)?.data(py)),
78 ) 89 )
79 .and(Ok(py.None())) 90 .and(Ok(py.None()))
80 .or_else(|e| { 91 .or_else(|e| {
81 match e { 92 match e {
82 DirstateMapError::PathNotFound(_p) => { 93 DirstateMapError::EmptyPath => {
94 Ok(py.None())
95 },
96 e => {
83 Err(PyErr::new::<exc::ValueError, _>( 97 Err(PyErr::new::<exc::ValueError, _>(
84 py, 98 py,
85 "expected a value, found none".to_string(), 99 e.to_string(),
86 )) 100 ))
87 }
88 DirstateMapError::EmptyPath => {
89 Ok(py.None())
90 } 101 }
91 } 102 }
92 }) 103 })
93 } 104 }
94 def __iter__(&self) -> PyResult<DirsMultisetKeysIterator> { 105 def __iter__(&self) -> PyResult<DirsMultisetKeysIterator> {