rust-repo: add a method to get a `Node` from a `Revision` to the `Repo`
authorRaphaël Gomès <rgomes@octobus.net>
Mon, 30 Sep 2024 17:46:24 +0200
changeset 52035 babfa9ddca0e
parent 52034 b55f653a0b34
child 52036 d7bc6e482033
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
rust/hg-core/src/repo.rs
--- 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