Show More
@@ -18,7 +18,7 b' use crate::{' | |||||
18 | exceptions::GraphError, |
|
18 | exceptions::GraphError, | |
19 | }; |
|
19 | }; | |
20 | use cpython::{ |
|
20 | use cpython::{ | |
21 | ObjectProtocol, PyDict, PyModule, PyObject, PyResult, Python, |
|
21 | ObjectProtocol, PyDict, PyModule, PyObject, PyResult, PyTuple, Python, | |
22 | PythonObject, ToPyObject, |
|
22 | PythonObject, ToPyObject, | |
23 | }; |
|
23 | }; | |
24 | use hg::discovery::PartialDiscovery as CorePartialDiscovery; |
|
24 | use hg::discovery::PartialDiscovery as CorePartialDiscovery; | |
@@ -111,6 +111,32 b' py_class!(pub class PartialDiscovery |py' | |||||
111 | .map_err(|e| GraphError::pynew(py, e))? |
|
111 | .map_err(|e| GraphError::pynew(py, e))? | |
112 | ) |
|
112 | ) | |
113 | } |
|
113 | } | |
|
114 | ||||
|
115 | def takefullsample(&self, _headrevs: PyObject, | |||
|
116 | size: usize) -> PyResult<PyObject> { | |||
|
117 | let mut inner = self.inner(py).borrow_mut(); | |||
|
118 | let sample = inner.take_full_sample(size) | |||
|
119 | .map_err(|e| GraphError::pynew(py, e))?; | |||
|
120 | let as_vec: Vec<PyObject> = sample | |||
|
121 | .iter() | |||
|
122 | .map(|rev| rev.to_py_object(py).into_object()) | |||
|
123 | .collect(); | |||
|
124 | Ok(PyTuple::new(py, as_vec.as_slice()).into_object()) | |||
|
125 | } | |||
|
126 | ||||
|
127 | def takequicksample(&self, headrevs: PyObject, | |||
|
128 | size: usize) -> PyResult<PyObject> { | |||
|
129 | let mut inner = self.inner(py).borrow_mut(); | |||
|
130 | let revsvec: Vec<Revision> = rev_pyiter_collect(py, &headrevs)?; | |||
|
131 | let sample = inner.take_quick_sample(revsvec, size) | |||
|
132 | .map_err(|e| GraphError::pynew(py, e))?; | |||
|
133 | let as_vec: Vec<PyObject> = sample | |||
|
134 | .iter() | |||
|
135 | .map(|rev| rev.to_py_object(py).into_object()) | |||
|
136 | .collect(); | |||
|
137 | Ok(PyTuple::new(py, as_vec.as_slice()).into_object()) | |||
|
138 | } | |||
|
139 | ||||
114 | }); |
|
140 | }); | |
115 |
|
141 | |||
116 | /// Create the module, with __package__ given from parent |
|
142 | /// Create the module, with __package__ given from parent |
General Comments 0
You need to be logged in to leave comments.
Login now