Mercurial > public > mercurial-scm > hg
diff rust/hg-cpython/src/cindex.rs @ 41054:ef54bd33b476
rust: core implementation for lazyancestors
Once exposed through appropriate bindings, this
should be able to replace ancestor.lazyancestors
entirely.
Differential Revision: https://phab.mercurial-scm.org/D5440
author | Georges Racinet <gracinet@anybox.fr> |
---|---|
date | Tue, 04 Dec 2018 11:05:06 +0100 |
parents | 4c25038c112c |
children | ab0d762d89ef |
line wrap: on
line diff
--- a/rust/hg-cpython/src/cindex.rs Thu Dec 06 20:01:21 2018 +0100 +++ b/rust/hg-cpython/src/cindex.rs Tue Dec 04 11:05:06 2018 +0100 @@ -15,7 +15,7 @@ extern crate python3_sys as python_sys; use self::python_sys::PyCapsule_Import; -use cpython::{PyErr, PyObject, PyResult, Python}; +use cpython::{PyClone, PyErr, PyObject, PyResult, Python}; use hg::{Graph, GraphError, Revision}; use libc::c_int; use std::ffi::CStr; @@ -59,7 +59,6 @@ /// the core API, that would be tied to `GILGuard` / `Python<'p>` /// in the case of the `cpython` crate bindings yet could leave room for other /// mechanisms in other contexts. - pub struct Index { index: PyObject, parents: IndexParentsFn, @@ -74,6 +73,16 @@ } } +impl Clone for Index { + fn clone(&self) -> Self { + let guard = Python::acquire_gil(); + Index { + index: self.index.clone_ref(guard.python()), + parents: self.parents.clone(), + } + } +} + impl Graph for Index { /// wrap a call to the C extern parents function fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError> {