comparison rust/hg-cpython/src/dirstate/dirstate_map.rs @ 47121:b6339a993b91

rust: Remove handling of `parents` in `DirstateMap` The Python wrapper class `dirstatemap` can take care of it. This removes the need to have both `_rustmap` and `_inner_rustmap`. Differential Revision: https://phab.mercurial-scm.org/D10555
author Simon Sapin <simon.sapin@octobus.net>
date Fri, 30 Apr 2021 15:40:11 +0200
parents d5956136d19d
children 9aba0cde0ed9
comparison
equal deleted inserted replaced
47120:7109a38830c9 47121:b6339a993b91
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, PyTuple, Python, PythonObject, 16 PyObject, PyResult, PySet, PyString, Python, PythonObject, ToPyObject,
17 ToPyObject, UnsafePyLeaked, 17 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::non_normal_entries::{ 22 dirstate::non_normal_entries::{
269 PyErr::new::<exc::ValueError, _>(py, e.to_string()) 269 PyErr::new::<exc::ValueError, _>(py, e.to_string())
270 })? 270 })?
271 .to_py_object(py)) 271 .to_py_object(py))
272 } 272 }
273 273
274 def parents(&self, st: PyObject) -> PyResult<PyTuple> {
275 self.inner(py).borrow_mut()
276 .parents(st.extract::<PyBytes>(py)?.data(py))
277 .map(|parents| dirstate_parents_to_pytuple(py, parents))
278 .or_else(|_| {
279 Err(PyErr::new::<exc::OSError, _>(
280 py,
281 "Dirstate error".to_string(),
282 ))
283 })
284 }
285
286 def setparents(&self, p1: PyObject, p2: PyObject) -> PyResult<PyObject> {
287 let p1 = extract_node_id(py, &p1)?;
288 let p2 = extract_node_id(py, &p2)?;
289
290 self.inner(py).borrow_mut()
291 .set_parents(&DirstateParents { p1, p2 });
292 Ok(py.None())
293 }
294
295 def read(&self, st: PyObject) -> PyResult<Option<PyObject>> { 274 def read(&self, st: PyObject) -> PyResult<Option<PyObject>> {
296 match self.inner(py).borrow_mut() 275 match self.inner(py).borrow_mut()
297 .read(st.extract::<PyBytes>(py)?.data(py)) 276 .read(st.extract::<PyBytes>(py)?.data(py))
298 { 277 {
299 Ok(Some(parents)) => Ok(Some( 278 Ok(Some(parents)) => Ok(Some(