Show More
@@ -24,9 +24,8 b' use crate::{' | |||||
24 | ref_sharing::PySharedState, |
|
24 | ref_sharing::PySharedState, | |
25 | }; |
|
25 | }; | |
26 | use hg::{ |
|
26 | use hg::{ | |
27 | DirsIterable, DirsMultiset, DirstateEntry, |
|
27 | DirsIterable, DirsMultiset, DirstateEntry, DirstateMap as RustDirstateMap, | |
28 | DirstateMap as RustDirstateMap, DirstateParents, DirstateParseError, |
|
28 | DirstateParents, DirstateParseError, EntryState, PARENT_SIZE, | |
29 | EntryState, |
|
|||
30 | }; |
|
29 | }; | |
31 |
|
30 | |||
32 | // TODO |
|
31 | // TODO | |
@@ -239,9 +238,8 b' py_class!(pub class DirstateMap |py| {' | |||||
239 | } |
|
238 | } | |
240 |
|
239 | |||
241 | def setparents(&self, p1: PyObject, p2: PyObject) -> PyResult<PyObject> { |
|
240 | def setparents(&self, p1: PyObject, p2: PyObject) -> PyResult<PyObject> { | |
242 | // TODO: don't panic; raise Python exception instead. |
|
241 | let p1 = extract_node_id(py, &p1)?; | |
243 | let p1 = p1.extract::<PyBytes>(py)?.data(py).try_into().unwrap(); |
|
242 | let p2 = extract_node_id(py, &p2)?; | |
244 | let p2 = p2.extract::<PyBytes>(py)?.data(py).try_into().unwrap(); |
|
|||
245 |
|
243 | |||
246 | self.inner(py) |
|
244 | self.inner(py) | |
247 | .borrow_mut() |
|
245 | .borrow_mut() | |
@@ -275,9 +273,8 b' py_class!(pub class DirstateMap |py| {' | |||||
275 | ) -> PyResult<PyBytes> { |
|
273 | ) -> PyResult<PyBytes> { | |
276 | let now = Duration::new(now.extract(py)?, 0); |
|
274 | let now = Duration::new(now.extract(py)?, 0); | |
277 | let parents = DirstateParents { |
|
275 | let parents = DirstateParents { | |
278 | // TODO: don't panic; raise Python exception instead. |
|
276 | p1: extract_node_id(py, &p1)?, | |
279 | p1: p1.extract::<PyBytes>(py)?.data(py).try_into().unwrap(), |
|
277 | p2: extract_node_id(py, &p2)?, | |
280 | p2: p2.extract::<PyBytes>(py)?.data(py).try_into().unwrap(), |
|
|||
281 | }; |
|
278 | }; | |
282 |
|
279 | |||
283 | match self.borrow_mut(py)?.pack(parents, now) { |
|
280 | match self.borrow_mut(py)?.pack(parents, now) { | |
@@ -508,3 +505,11 b' py_shared_mapping_iterator!(' | |||||
508 | DirstateMap::translate_key_value, |
|
505 | DirstateMap::translate_key_value, | |
509 | Option<(PyBytes, PyObject)> |
|
506 | Option<(PyBytes, PyObject)> | |
510 | ); |
|
507 | ); | |
|
508 | ||||
|
509 | fn extract_node_id(py: Python, obj: &PyObject) -> PyResult<[u8; PARENT_SIZE]> { | |||
|
510 | let bytes = obj.extract::<PyBytes>(py)?; | |||
|
511 | match bytes.data(py).try_into() { | |||
|
512 | Ok(s) => Ok(s), | |||
|
513 | Err(e) => Err(PyErr::new::<exc::ValueError, _>(py, e.to_string())), | |||
|
514 | } | |||
|
515 | } |
General Comments 0
You need to be logged in to leave comments.
Login now