Mercurial > hg
changeset 48853:4346be456875
rust: implement vcsgraph::RankedGraph for Index
Differential Revision: https://phab.mercurial-scm.org/D12210
author | pacien <pacien.trangirard@pacien.net> |
---|---|
date | Mon, 21 Feb 2022 18:06:02 +0100 |
parents | e633e660158f |
children | 8b8054b8e5a7 |
files | rust/hg-cpython/src/cindex.rs |
diffstat | 1 files changed, 14 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/rust/hg-cpython/src/cindex.rs Mon Feb 21 18:05:54 2022 +0100 +++ b/rust/hg-cpython/src/cindex.rs Mon Feb 21 18:06:02 2022 +0100 @@ -177,6 +177,20 @@ } } +impl vcsgraph::graph::RankedGraph for Index { + fn rank( + &self, + rev: Revision, + ) -> Result<vcsgraph::graph::Rank, vcsgraph::graph::GraphReadError> { + match unsafe { + (self.capi.fast_rank)(self.index.as_ptr(), rev as ssize_t) + } { + -1 => Err(vcsgraph::graph::GraphReadError::InconsistentGraphData), + rank => Ok(rank as usize), + } + } +} + impl RevlogIndex for Index { /// Note C return type is Py_ssize_t (hence signed), but we shall /// force it to unsigned, because it's a length