Mercurial > hg-stable
changeset 44514:cefd130c98be
rust-index: add `append` method to cindex/Index
This will be used by `MixedIndex` in a later patch.
Differential Revision: https://phab.mercurial-scm.org/D8154
author | Georges Racinet <georges.racinet@octobus.net> |
---|---|
date | Tue, 11 Feb 2020 16:23:06 +0100 |
parents | 887d0f921b34 |
children | d738b7a18438 |
files | rust/hg-cpython/src/cindex.rs |
diffstat | 1 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/rust/hg-cpython/src/cindex.rs Mon Jan 13 19:56:16 2020 +0100 +++ b/rust/hg-cpython/src/cindex.rs Tue Feb 11 16:23:06 2020 +0100 @@ -10,7 +10,10 @@ //! Ideally, we should use an Index entirely implemented in Rust, //! but this will take some time to get there. -use cpython::{exc::ImportError, PyClone, PyErr, PyObject, PyResult, Python}; +use cpython::{ + exc::ImportError, ObjectProtocol, PyClone, PyErr, PyObject, PyResult, + PyTuple, Python, PythonObject, +}; use hg::revlog::{Node, RevlogIndex}; use hg::{Graph, GraphError, Revision, WORKING_DIRECTORY_REVISION}; use libc::c_int; @@ -97,6 +100,15 @@ pub fn inner(&self) -> &PyObject { &self.index } + + pub fn append(&mut self, py: Python, tup: PyTuple) -> PyResult<PyObject> { + self.index.call_method( + py, + "append", + PyTuple::new(py, &[tup.into_object()]), + None, + ) + } } impl Clone for Index {