diff rust/hg-core/src/revlog/changelog.rs @ 50978:27e773aa607d

rust: implement the `Graph` trait for all revlogs This is trivial and makes all the algorithms relying on the trait usable for more use cases.
author Raphaël Gomès <rgomes@octobus.net>
date Thu, 10 Aug 2023 11:01:07 +0200
parents 1928b770e3e7
children 13f58ce70299 d626e5e7bbbe
line wrap: on
line diff
--- a/rust/hg-core/src/revlog/changelog.rs	Thu Aug 10 11:00:34 2023 +0200
+++ b/rust/hg-core/src/revlog/changelog.rs	Thu Aug 10 11:01:07 2023 +0200
@@ -4,7 +4,7 @@
 use crate::revlog::{Revlog, RevlogEntry, RevlogError};
 use crate::utils::hg_path::HgPath;
 use crate::vfs::Vfs;
-use crate::UncheckedRevision;
+use crate::{Graph, GraphError, UncheckedRevision};
 use itertools::Itertools;
 use std::ascii::escape_default;
 use std::borrow::Cow;
@@ -76,6 +76,12 @@
     }
 }
 
+impl Graph for Changelog {
+    fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError> {
+        self.revlog.parents(rev)
+    }
+}
+
 /// A specialized `RevlogEntry` for `changelog` data format
 ///
 /// This is a `RevlogEntry` with the added semantics that the associated