Mercurial > hg
diff rust/hg-cpython/src/dirstate/dirstate_map.rs @ 49108:119c7e2b4248
rust-dirstatemap: add `set_untracked` method
This is the new API that Python has already migrated to
Differential Revision: https://phab.mercurial-scm.org/D12506
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Mon, 28 Mar 2022 18:13:58 +0200 |
parents | c1a3fdedc492 |
children | 8a17fc501eda |
line wrap: on
line diff
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs Mon Mar 28 18:10:19 2022 +0200 +++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs Mon Mar 28 18:13:58 2022 +0200 @@ -142,6 +142,16 @@ Ok(was_tracked.to_py_object(py)) } + def set_untracked(&self, f: PyObject) -> PyResult<PyBool> { + let bytes = f.extract::<PyBytes>(py)?; + let path = HgPath::new(bytes.data(py)); + let res = self.inner(py).borrow_mut().set_untracked(path); + let was_tracked = res.or_else(|_| { + Err(PyErr::new::<exc::OSError, _>(py, "Dirstate error".to_string())) + })?; + Ok(was_tracked.to_py_object(py)) + } + def set_clean( &self, f: PyObject,