# HG changeset patch # User Raphaël Gomès # Date 2024-09-30 15:46:24 # Node ID babfa9ddca0e40a97140efd39a75ff4270257ec4 # Parent b55f653a0b34bb52f2b9bbaab03b785d5fd5dc43 rust-repo: add a method to get a `Node` from a `Revision` to the `Repo` This is going to be more and more useful as we start writing higher-level code diff --git a/rust/hg-core/src/repo.rs b/rust/hg-core/src/repo.rs --- a/rust/hg-core/src/repo.rs +++ b/rust/hg-core/src/repo.rs @@ -797,6 +797,12 @@ impl Repo { )?, }) } + + pub fn node(&self, rev: UncheckedRevision) -> Option { + self.changelog() + .ok() + .and_then(|c| c.node_from_rev(rev).copied()) + } } /// Lazily-initialized component of `Repo` with interior mutability