Mercurial > hg
comparison rust/hg-cpython/src/discovery.rs @ 43945:f98f0e3ddaa1
rust-index: add a function to convert PyObject index for hg-core
Function in hg-core need something implementing the `Graph` trait. Right now,
the `hg-cpython` entry points directly turn the PyObject passed as argument
into a `cindex::Index`. However, if we start having the option to use an Index
in Rust, we need to dispatch between the different possible PyObject we could
receive.
So move the "duplicate" call into a unified function. When time come. It will be
easy to update the logic of all interface when the time come.
Differential Revision: https://phab.mercurial-scm.org/D7653
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 13 Dec 2019 19:59:59 +0100 |
parents | 33fe96a5c522 |
children | 4c5f6e95df84 |
comparison
equal
deleted
inserted
replaced
43944:8a8305f557d0 | 43945:f98f0e3ddaa1 |
---|---|
23 use hg::Revision; | 23 use hg::Revision; |
24 use std::collections::HashSet; | 24 use std::collections::HashSet; |
25 | 25 |
26 use std::cell::RefCell; | 26 use std::cell::RefCell; |
27 | 27 |
28 use crate::revlog::pyindex_to_graph; | |
29 | |
28 py_class!(pub class PartialDiscovery |py| { | 30 py_class!(pub class PartialDiscovery |py| { |
29 data inner: RefCell<Box<CorePartialDiscovery<Index>>>; | 31 data inner: RefCell<Box<CorePartialDiscovery<Index>>>; |
30 | 32 |
31 // `_respectsize` is currently only here to replicate the Python API and | 33 // `_respectsize` is currently only here to replicate the Python API and |
32 // will be used in future patches inside methods that are yet to be | 34 // will be used in future patches inside methods that are yet to be |
40 ) -> PyResult<PartialDiscovery> { | 42 ) -> PyResult<PartialDiscovery> { |
41 let index = repo.getattr(py, "changelog")?.getattr(py, "index")?; | 43 let index = repo.getattr(py, "changelog")?.getattr(py, "index")?; |
42 Self::create_instance( | 44 Self::create_instance( |
43 py, | 45 py, |
44 RefCell::new(Box::new(CorePartialDiscovery::new( | 46 RefCell::new(Box::new(CorePartialDiscovery::new( |
45 Index::new(py, index)?, | 47 pyindex_to_graph(py, index)?, |
46 rev_pyiter_collect(py, &targetheads)?, | 48 rev_pyiter_collect(py, &targetheads)?, |
47 respectsize, | 49 respectsize, |
48 randomize, | 50 randomize, |
49 ))) | 51 ))) |
50 ) | 52 ) |