comparison rust/hg-core/src/revlog/changelog.rs @ 51725:bbe59cc5d2e1

rust-changelog: accessing the index The `Index` object is currently the one providing all DAG related algorithms, starting with simple ancestors iteration up to more advanced ones (ranges, common ancestors…). From pure Rust code, there was no way to access the changelog index for a given `Repository`, probably because `rhg` does not use any such algorithm yet.
author Georges Racinet <georges.racinet@cloudcrane.io>
date Mon, 22 Jul 2024 18:20:29 +0200
parents ec7171748350
children 69b804c8e09e
comparison
equal deleted inserted replaced
51724:a3dc962cac62 51725:bbe59cc5d2e1
6 6
7 use chrono::{DateTime, FixedOffset, NaiveDateTime}; 7 use chrono::{DateTime, FixedOffset, NaiveDateTime};
8 use itertools::{Either, Itertools}; 8 use itertools::{Either, Itertools};
9 9
10 use crate::errors::HgError; 10 use crate::errors::HgError;
11 use crate::revlog::Index;
11 use crate::revlog::Revision; 12 use crate::revlog::Revision;
12 use crate::revlog::{Node, NodePrefix}; 13 use crate::revlog::{Node, NodePrefix};
13 use crate::revlog::{Revlog, RevlogEntry, RevlogError}; 14 use crate::revlog::{Revlog, RevlogEntry, RevlogError};
14 use crate::utils::hg_path::HgPath; 15 use crate::utils::hg_path::HgPath;
15 use crate::vfs::Vfs; 16 use crate::vfs::Vfs;
78 pub fn rev_from_node( 79 pub fn rev_from_node(
79 &self, 80 &self,
80 node: NodePrefix, 81 node: NodePrefix,
81 ) -> Result<Revision, RevlogError> { 82 ) -> Result<Revision, RevlogError> {
82 self.revlog.rev_from_node(node) 83 self.revlog.rev_from_node(node)
84 }
85
86 pub fn get_index(&self) -> &Index {
87 &self.revlog.index
83 } 88 }
84 } 89 }
85 90
86 impl Graph for Changelog { 91 impl Graph for Changelog {
87 fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError> { 92 fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError> {