Mercurial > public > mercurial-scm > hg
view rust/hg-cpython/src/dirstate/non_normal_entries.rs @ 47279:40b51c28b242
dirstate-v2: Update the expected output of some tests for new requirement
Fix most test failures (except in test-narrow-debugrebuilddirstate.t and
test-upgrade-repo.t) caused by the new entry in config or in .hg/requires
when running `run-tests.py --extra-config-opt format.exp-dirstate-v2=1`
There is no CI?so far for this configuration.
Differential Revision: https://phab.mercurial-scm.org/D10718
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Wed, 19 May 2021 13:15:00 +0200 |
parents | cd8ca38fccff |
children | ed1583a845d2 |
line wrap: on
line source
// non_normal_other_parent_entries.rs // // Copyright 2020 Raphaël Gomès <rgomes@octobus.net> // // This software may be used and distributed according to the terms of the // GNU General Public License version 2 or any later version. use cpython::{ exc::NotImplementedError, CompareOp, ObjectProtocol, PyBytes, PyClone, PyErr, PyObject, PyResult, PyString, Python, PythonObject, ToPyObject, UnsafePyLeaked, }; use crate::dirstate::DirstateMap; use hg::utils::hg_path::HgPath; use std::cell::RefCell; py_class!(pub class NonNormalEntries |py| { data dmap: DirstateMap; def __contains__(&self, key: PyObject) -> PyResult<bool> { self.dmap(py).non_normal_entries_contains(py, key) } def remove(&self, key: PyObject) -> PyResult<PyObject> { self.dmap(py).non_normal_entries_remove(py, key) } def __richcmp__(&self, other: PyObject, op: CompareOp) -> PyResult<bool> { match op { CompareOp::Eq => self.is_equal_to(py, other), CompareOp::Ne => Ok(!self.is_equal_to(py, other)?), _ => Err(PyErr::new::<NotImplementedError, _>(py, "")) } } def __repr__(&self) -> PyResult<PyString> { self.dmap(py).non_normal_entries_display(py) } def __iter__(&self) -> PyResult<NonNormalEntriesIterator> { self.dmap(py).non_normal_entries_iter(py) } }); impl NonNormalEntries { pub fn from_inner(py: Python, dm: DirstateMap) -> PyResult<Self> { Self::create_instance(py, dm) } fn is_equal_to(&self, py: Python, other: PyObject) -> PyResult<bool> { for item in other.iter(py)? { if !self.dmap(py).non_normal_entries_contains(py, item?)? { return Ok(false); } } Ok(true) } fn translate_key(py: Python, key: &HgPath) -> PyResult<Option<PyBytes>> { Ok(Some(PyBytes::new(py, key.as_bytes()))) } } type NonNormalEntriesIter<'a> = Box<dyn Iterator<Item = &'a HgPath> + Send + 'a>; py_shared_iterator!( NonNormalEntriesIterator, UnsafePyLeaked<NonNormalEntriesIter<'static>>, NonNormalEntries::translate_key, Option<PyBytes> );