Mercurial > hg
comparison rust/hg-cpython/src/revlog.rs @ 44012:443dc1655923
rust-index: expose a method to retrieve the C index
The code for `shortesthexnodeidprefix` need to access the actual C index. For
now we grant its wish and expose a method to do so. Once we have the nodemap in
Rust, we will be able to implement the same feature from rust and we will be
able to drop this method.
Differential Revision: https://phab.mercurial-scm.org/D7658
author | Georges Racinet <georges.racinet@octobus.net> |
---|---|
date | Thu, 12 Dec 2019 03:39:14 +0100 |
parents | c627f1b2f3c3 |
children | 451d22174b5f |
comparison
equal
deleted
inserted
replaced
44011:c627f1b2f3c3 | 44012:443dc1655923 |
---|---|
25 data cindex: RefCell<cindex::Index>; | 25 data cindex: RefCell<cindex::Index>; |
26 | 26 |
27 def __new__(_cls, cindex: PyObject) -> PyResult<MixedIndex> { | 27 def __new__(_cls, cindex: PyObject) -> PyResult<MixedIndex> { |
28 Self::create_instance(py, RefCell::new( | 28 Self::create_instance(py, RefCell::new( |
29 cindex::Index::new(py, cindex)?)) | 29 cindex::Index::new(py, cindex)?)) |
30 } | |
31 | |
32 /// Compatibility layer used for Python consumers needing access to the C index | |
33 /// | |
34 /// Only use case so far is `scmutil.shortesthexnodeidprefix`, | |
35 /// that may need to build a custom `nodetree`, based on a specified revset. | |
36 /// With a Rust implementation of the nodemap, we will be able to get rid of | |
37 /// this, by exposing our own standalone nodemap class, | |
38 /// ready to accept `MixedIndex`. | |
39 def get_cindex(&self) -> PyResult<PyObject> { | |
40 Ok(self.cindex(py).borrow().inner().clone_ref(py)) | |
30 } | 41 } |
31 | 42 |
32 | 43 |
33 // Reforwarded C index API | 44 // Reforwarded C index API |
34 | 45 |