Show More
@@ -23,9 +23,10 b' use hg::{' | |||||
23 | }; |
|
23 | }; | |
24 | use libc::{c_char, c_int}; |
|
24 | use libc::{c_char, c_int}; | |
25 | #[cfg(feature = "python27")] |
|
25 | #[cfg(feature = "python27")] | |
26 | use python27_sys::PyCapsule_Import; |
|
26 | use python27_sys as python_sys; | |
27 | #[cfg(feature = "python3")] |
|
27 | #[cfg(feature = "python3")] | |
28 | use python3_sys::PyCapsule_Import; |
|
28 | use python3_sys as python_sys; | |
|
29 | use python_sys::PyCapsule_Import; | |||
29 | use std::convert::TryFrom; |
|
30 | use std::convert::TryFrom; | |
30 | use std::ffi::CStr; |
|
31 | use std::ffi::CStr; | |
31 | use std::mem::transmute; |
|
32 | use std::mem::transmute; | |
@@ -41,7 +42,7 b' type MakeDirstateTupleFn = unsafe extern' | |||||
41 | mode: c_int, |
|
42 | mode: c_int, | |
42 | size: c_int, |
|
43 | size: c_int, | |
43 | mtime: c_int, |
|
44 | mtime: c_int, | |
44 | ) -> PyObject; |
|
45 | ) -> *mut python_sys::PyObject; | |
45 |
|
46 | |||
46 | /// This is largely a copy/paste from cindex.rs, pending the merge of a |
|
47 | /// This is largely a copy/paste from cindex.rs, pending the merge of a | |
47 | /// `py_capsule_fn!` macro in the rust-cpython project: |
|
48 | /// `py_capsule_fn!` macro in the rust-cpython project: | |
@@ -76,10 +77,11 b' pub fn make_dirstate_tuple(' | |||||
76 | // just do a naive enum cast. |
|
77 | // just do a naive enum cast. | |
77 | let state_code: u8 = state.into(); |
|
78 | let state_code: u8 = state.into(); | |
78 |
|
79 | |||
79 | unsafe { |
|
80 | let maybe_obj = unsafe { | |
80 | let ptr = make(state_code as c_char, mode, size, mtime); |
|
81 | let ptr = make(state_code as c_char, mode, size, mtime); | |
81 | Ok(ptr) |
|
82 | PyObject::from_owned_ptr_opt(py, ptr) | |
82 | } |
|
83 | }; | |
|
84 | maybe_obj.ok_or_else(|| PyErr::fetch(py)) | |||
83 | } |
|
85 | } | |
84 |
|
86 | |||
85 | pub fn extract_dirstate(py: Python, dmap: &PyDict) -> Result<StateMap, PyErr> { |
|
87 | pub fn extract_dirstate(py: Python, dmap: &PyDict) -> Result<StateMap, PyErr> { |
General Comments 0
You need to be logged in to leave comments.
Login now