changeset 52035:babfa9ddca0e

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
author Raphaël Gomès <rgomes@octobus.net>
date Mon, 30 Sep 2024 17:46:24 +0200
parents b55f653a0b34
children d7bc6e482033
files rust/hg-core/src/repo.rs
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-core/src/repo.rs	Mon Sep 30 17:45:10 2024 +0200
+++ b/rust/hg-core/src/repo.rs	Mon Sep 30 17:46:24 2024 +0200
@@ -797,6 +797,12 @@
             )?,
         })
     }
+
+    pub fn node(&self, rev: UncheckedRevision) -> Option<crate::Node> {
+        self.changelog()
+            .ok()
+            .and_then(|c| c.node_from_rev(rev).copied())
+    }
 }
 
 /// Lazily-initialized component of `Repo` with interior mutability