equal
deleted
inserted
replaced
12 //! - [`PartialDiscover`] is the Rust implementation of |
12 //! - [`PartialDiscover`] is the Rust implementation of |
13 //! `mercurial.setdiscovery.partialdiscovery`. |
13 //! `mercurial.setdiscovery.partialdiscovery`. |
14 |
14 |
15 use crate::conversion::{py_set, rev_pyiter_collect}; |
15 use crate::conversion::{py_set, rev_pyiter_collect}; |
16 use cindex::Index; |
16 use cindex::Index; |
17 use cpython::{ObjectProtocol, PyDict, PyModule, PyObject, PyResult, Python}; |
17 use cpython::{ |
|
18 ObjectProtocol, PyDict, PyModule, PyObject, PyResult, Python, ToPyObject, |
|
19 }; |
18 use exceptions::GraphError; |
20 use exceptions::GraphError; |
19 use hg::discovery::PartialDiscovery as CorePartialDiscovery; |
21 use hg::discovery::PartialDiscovery as CorePartialDiscovery; |
20 use hg::Revision; |
22 use hg::Revision; |
21 |
23 |
22 use std::cell::RefCell; |
24 use std::cell::RefCell; |
81 |
83 |
82 def iscomplete(&self) -> PyResult<bool> { |
84 def iscomplete(&self) -> PyResult<bool> { |
83 Ok(self.inner(py).borrow().is_complete()) |
85 Ok(self.inner(py).borrow().is_complete()) |
84 } |
86 } |
85 |
87 |
|
88 def stats(&self) -> PyResult<PyDict> { |
|
89 let stats = self.inner(py).borrow().stats(); |
|
90 let as_dict: PyDict = PyDict::new(py); |
|
91 as_dict.set_item(py, "undecided", |
|
92 stats.undecided.map(|l| l.to_py_object(py)) |
|
93 .unwrap_or_else(|| py.None()))?; |
|
94 Ok(as_dict) |
|
95 } |
|
96 |
86 def commonheads(&self) -> PyResult<PyObject> { |
97 def commonheads(&self) -> PyResult<PyObject> { |
87 py_set( |
98 py_set( |
88 py, |
99 py, |
89 &self.inner(py).borrow().common_heads() |
100 &self.inner(py).borrow().common_heads() |
90 .map_err(|e| GraphError::pynew(py, e))? |
101 .map_err(|e| GraphError::pynew(py, e))? |