Mercurial > hg
diff rust/hg-cpython/src/dirstate/dirstate_map.rs @ 49104:b5c2aca84618
rust-dirstatemap: add `set_clean` method
This is the new dirstate API that has already been moved to in Python.
Differential Revision: https://phab.mercurial-scm.org/D12502
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Mon, 28 Mar 2022 18:02:50 +0200 |
parents | dd0430434ce9 |
children | c1a3fdedc492 |
line wrap: on
line diff
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs Wed Mar 23 17:13:18 2022 +0100 +++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs Mon Mar 28 18:02:50 2022 +0200 @@ -142,6 +142,28 @@ Ok(was_tracked.to_py_object(py)) } + def set_clean( + &self, + f: PyObject, + mode: u32, + size: u32, + mtime: (i64, u32, bool) + ) -> PyResult<PyNone> { + let (mtime_s, mtime_ns, second_ambiguous) = mtime; + let timestamp = TruncatedTimestamp::new_truncate( + mtime_s, mtime_ns, second_ambiguous + ); + let bytes = f.extract::<PyBytes>(py)?; + let path = HgPath::new(bytes.data(py)); + let res = self.inner(py).borrow_mut().set_clean( + path, mode, size, timestamp, + ); + res.or_else(|_| { + Err(PyErr::new::<exc::OSError, _>(py, "Dirstate error".to_string())) + })?; + Ok(PyNone) + } + def reset_state( &self, f: PyObject,