##// END OF EJS Templates
dirstate-item: also build DistateItem in dirstate.directories()...
marmoute -
r48367:7a15dea6 default
parent child Browse files
Show More
@@ -73,6 +73,19 b' pub fn make_dirstate_item('
73 maybe_obj.ok_or_else(|| PyErr::fetch(py))
73 maybe_obj.ok_or_else(|| PyErr::fetch(py))
74 }
74 }
75
75
76 // XXX a bit strange to have a dedicated function, but directory are not
77 // treated as dirstate node by hg-core for now so…
78 pub fn make_directory_item(py: Python, mtime: i32) -> PyResult<PyObject> {
79 // might be silly to retrieve capsule function in hot loop
80 let make = make_dirstate_item_capi::retrieve(py)?;
81
82 let maybe_obj = unsafe {
83 let ptr = make(b'd' as c_char, 0 as i32, 0 as i32, mtime);
84 PyObject::from_owned_ptr_opt(py, ptr)
85 };
86 maybe_obj.ok_or_else(|| PyErr::fetch(py))
87 }
88
76 pub fn extract_dirstate(py: Python, dmap: &PyDict) -> Result<StateMap, PyErr> {
89 pub fn extract_dirstate(py: Python, dmap: &PyDict) -> Result<StateMap, PyErr> {
77 dmap.items(py)
90 dmap.items(py)
78 .iter()
91 .iter()
@@ -19,6 +19,7 b' use cpython::{'
19
19
20 use crate::{
20 use crate::{
21 dirstate::copymap::{CopyMap, CopyMapItemsIterator, CopyMapKeysIterator},
21 dirstate::copymap::{CopyMap, CopyMapItemsIterator, CopyMapKeysIterator},
22 dirstate::make_directory_item,
22 dirstate::make_dirstate_item,
23 dirstate::make_dirstate_item,
23 dirstate::non_normal_entries::{
24 dirstate::non_normal_entries::{
24 NonNormalEntries, NonNormalEntriesIterator,
25 NonNormalEntries, NonNormalEntriesIterator,
@@ -519,7 +520,8 b' py_class!(pub class DirstateMap |py| {'
519 let (path, mtime) = item.map_err(|e| v2_error(py, e))?;
520 let (path, mtime) = item.map_err(|e| v2_error(py, e))?;
520 let path = PyBytes::new(py, path.as_bytes());
521 let path = PyBytes::new(py, path.as_bytes());
521 let mtime = mtime.map(|t| t.0).unwrap_or(-1);
522 let mtime = mtime.map(|t| t.0).unwrap_or(-1);
522 let tuple = (path, (b'd', 0, 0, mtime));
523 let item = make_directory_item(py, mtime as i32)?;
524 let tuple = (path, item);
523 dirs.append(py, tuple.to_py_object(py).into_object())
525 dirs.append(py, tuple.to_py_object(py).into_object())
524 }
526 }
525 Ok(dirs)
527 Ok(dirs)
General Comments 0
You need to be logged in to leave comments. Login now