rust/hg-cpython/src/ancestors.rs
changeset 41185 5ac61ca58c3f
parent 41184 dcf818267bc1
child 41186 1b4b94bac8a0
equal deleted inserted replaced
41184:dcf818267bc1 41185:5ac61ca58c3f
    25 use cindex::Index;
    25 use cindex::Index;
    26 use cpython::{
    26 use cpython::{
    27     ObjectProtocol, PyClone, PyDict, PyModule, PyObject, PyResult, Python,
    27     ObjectProtocol, PyClone, PyDict, PyModule, PyObject, PyResult, Python,
    28 };
    28 };
    29 use exceptions::GraphError;
    29 use exceptions::GraphError;
    30 use hg;
       
    31 use hg::Revision;
    30 use hg::Revision;
    32 use hg::{AncestorsIterator as CoreIterator, LazyAncestors as CoreLazy};
    31 use hg::{AncestorsIterator as CoreIterator, LazyAncestors as CoreLazy};
    33 use std::cell::RefCell;
    32 use std::cell::RefCell;
    34 
    33 
    35 /// Utility function to convert a Python iterable into a Vec<Revision>
    34 /// Utility function to convert a Python iterable into a Vec<Revision>
    64     }
    63     }
    65 
    64 
    66     def __new__(_cls, index: PyObject, initrevs: PyObject, stoprev: Revision,
    65     def __new__(_cls, index: PyObject, initrevs: PyObject, stoprev: Revision,
    67                 inclusive: bool) -> PyResult<AncestorsIterator> {
    66                 inclusive: bool) -> PyResult<AncestorsIterator> {
    68         let initvec = reviter_to_revvec(py, initrevs)?;
    67         let initvec = reviter_to_revvec(py, initrevs)?;
    69         let ait = match hg::AncestorsIterator::new(Index::new(py, index)?,
    68         let ait = match CoreIterator::new(Index::new(py, index)?,
    70                                                    initvec, stoprev,
    69                                           initvec, stoprev,
    71                                                    inclusive) {
    70                                           inclusive) {
    72             Ok(ait) => ait,
    71             Ok(ait) => ait,
    73             Err(e) => {
    72             Err(e) => {
    74                 return Err(GraphError::pynew(py, e));
    73                 return Err(GraphError::pynew(py, e));
    75             }
    74             }
    76         };
    75         };