diff rust/hg-cpython/src/dirstate.rs @ 47567:7a15dea6d303

dirstate-item: also build DistateItem in dirstate.directories() The rust code was building tuple. Differential Revision: https://phab.mercurial-scm.org/D10983
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 05 Jul 2021 10:32:49 +0200
parents 84391ddf4c78
children 284a20269a97
line wrap: on
line diff
--- a/rust/hg-cpython/src/dirstate.rs	Thu Jul 08 17:09:57 2021 -0400
+++ b/rust/hg-cpython/src/dirstate.rs	Mon Jul 05 10:32:49 2021 +0200
@@ -73,6 +73,19 @@
     maybe_obj.ok_or_else(|| PyErr::fetch(py))
 }
 
+// XXX a bit strange to have a dedicated function, but directory are not
+// treated as dirstate node by hg-core for now so…
+pub fn make_directory_item(py: Python, mtime: i32) -> PyResult<PyObject> {
+    // might be silly to retrieve capsule function in hot loop
+    let make = make_dirstate_item_capi::retrieve(py)?;
+
+    let maybe_obj = unsafe {
+        let ptr = make(b'd' as c_char, 0 as i32, 0 as i32, mtime);
+        PyObject::from_owned_ptr_opt(py, ptr)
+    };
+    maybe_obj.ok_or_else(|| PyErr::fetch(py))
+}
+
 pub fn extract_dirstate(py: Python, dmap: &PyDict) -> Result<StateMap, PyErr> {
     dmap.items(py)
         .iter()