Show More
@@ -24,9 +24,8 b' use crate::{' | |||
|
24 | 24 | ref_sharing::PySharedState, |
|
25 | 25 | }; |
|
26 | 26 | use hg::{ |
|
27 | DirsIterable, DirsMultiset, DirstateEntry, | |
|
28 | DirstateMap as RustDirstateMap, DirstateParents, DirstateParseError, | |
|
29 | EntryState, | |
|
27 | DirsIterable, DirsMultiset, DirstateEntry, DirstateMap as RustDirstateMap, | |
|
28 | DirstateParents, DirstateParseError, EntryState, PARENT_SIZE, | |
|
30 | 29 | }; |
|
31 | 30 | |
|
32 | 31 | // TODO |
@@ -239,9 +238,8 b' py_class!(pub class DirstateMap |py| {' | |||
|
239 | 238 | } |
|
240 | 239 | |
|
241 | 240 | def setparents(&self, p1: PyObject, p2: PyObject) -> PyResult<PyObject> { |
|
242 | // TODO: don't panic; raise Python exception instead. | |
|
243 | let p1 = p1.extract::<PyBytes>(py)?.data(py).try_into().unwrap(); | |
|
244 | let p2 = p2.extract::<PyBytes>(py)?.data(py).try_into().unwrap(); | |
|
241 | let p1 = extract_node_id(py, &p1)?; | |
|
242 | let p2 = extract_node_id(py, &p2)?; | |
|
245 | 243 | |
|
246 | 244 | self.inner(py) |
|
247 | 245 | .borrow_mut() |
@@ -275,9 +273,8 b' py_class!(pub class DirstateMap |py| {' | |||
|
275 | 273 | ) -> PyResult<PyBytes> { |
|
276 | 274 | let now = Duration::new(now.extract(py)?, 0); |
|
277 | 275 | let parents = DirstateParents { |
|
278 | // TODO: don't panic; raise Python exception instead. | |
|
279 | p1: p1.extract::<PyBytes>(py)?.data(py).try_into().unwrap(), | |
|
280 | p2: p2.extract::<PyBytes>(py)?.data(py).try_into().unwrap(), | |
|
276 | p1: extract_node_id(py, &p1)?, | |
|
277 | p2: extract_node_id(py, &p2)?, | |
|
281 | 278 | }; |
|
282 | 279 | |
|
283 | 280 | match self.borrow_mut(py)?.pack(parents, now) { |
@@ -508,3 +505,11 b' py_shared_mapping_iterator!(' | |||
|
508 | 505 | DirstateMap::translate_key_value, |
|
509 | 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