11 use std::cell::{RefCell, RefMut}; |
11 use std::cell::{RefCell, RefMut}; |
12 use std::convert::TryInto; |
12 use std::convert::TryInto; |
13 |
13 |
14 use cpython::{ |
14 use cpython::{ |
15 exc, ObjectProtocol, PyBool, PyBytes, PyClone, PyDict, PyErr, PyList, |
15 exc, ObjectProtocol, PyBool, PyBytes, PyClone, PyDict, PyErr, PyList, |
16 PyObject, PyResult, PySet, PyString, Python, PythonObject, ToPyObject, |
16 PyNone, PyObject, PyResult, PySet, PyString, Python, PythonObject, |
17 UnsafePyLeaked, |
17 ToPyObject, UnsafePyLeaked, |
18 }; |
18 }; |
19 |
19 |
20 use crate::{ |
20 use crate::{ |
21 dirstate::copymap::{CopyMap, CopyMapItemsIterator, CopyMapKeysIterator}, |
21 dirstate::copymap::{CopyMap, CopyMapItemsIterator, CopyMapKeysIterator}, |
22 dirstate::item::DirstateItem, |
22 dirstate::item::DirstateItem, |
210 Ok(py.None()) |
210 Ok(py.None()) |
211 } |
211 } |
212 |
212 |
213 def dropfile( |
213 def dropfile( |
214 &self, |
214 &self, |
215 f: PyObject, |
215 f: PyBytes, |
216 ) -> PyResult<PyBool> { |
216 ) -> PyResult<PyNone> { |
217 self.inner(py).borrow_mut() |
217 self.inner(py) |
218 .drop_file( |
218 .borrow_mut() |
219 HgPath::new(f.extract::<PyBytes>(py)?.data(py)), |
219 .drop_file(HgPath::new(f.data(py))) |
220 ) |
220 .map_err(|e |dirstate_error(py, e))?; |
221 .and_then(|b| Ok(b.to_py_object(py))) |
221 Ok(PyNone) |
222 .or_else(|e| { |
|
223 Err(PyErr::new::<exc::OSError, _>( |
|
224 py, |
|
225 format!("Dirstate error: {}", e.to_string()), |
|
226 )) |
|
227 }) |
|
228 } |
222 } |
229 |
223 |
230 def clearambiguoustimes( |
224 def clearambiguoustimes( |
231 &self, |
225 &self, |
232 files: PyObject, |
226 files: PyObject, |