rust/hg-core/src/revlog/revlog.rs
changeset 49065 5d205e476057
parent 48546 e91aa800ae5b
child 49085 07d8d144c222
--- a/rust/hg-core/src/revlog/revlog.rs	Tue Apr 05 08:47:04 2022 -0700
+++ b/rust/hg-core/src/revlog/revlog.rs	Tue Apr 05 12:06:32 2022 -0700
@@ -331,6 +331,10 @@
         self.rev
     }
 
+    pub fn node(&self) -> &Node {
+        &self.hash
+    }
+
     pub fn uncompressed_len(&self) -> Option<u32> {
         u32::try_from(self.uncompressed_len).ok()
     }
@@ -339,6 +343,38 @@
         self.p1 != NULL_REVISION
     }
 
+    pub fn p1_entry(&self) -> Result<Option<RevlogEntry>, RevlogError> {
+        if self.p1 == NULL_REVISION {
+            Ok(None)
+        } else {
+            Ok(Some(self.revlog.get_entry(self.p1)?))
+        }
+    }
+
+    pub fn p2_entry(&self) -> Result<Option<RevlogEntry>, RevlogError> {
+        if self.p2 == NULL_REVISION {
+            Ok(None)
+        } else {
+            Ok(Some(self.revlog.get_entry(self.p2)?))
+        }
+    }
+
+    pub fn p1(&self) -> Option<Revision> {
+        if self.p1 == NULL_REVISION {
+            None
+        } else {
+            Some(self.p1)
+        }
+    }
+
+    pub fn p2(&self) -> Option<Revision> {
+        if self.p2 == NULL_REVISION {
+            None
+        } else {
+            Some(self.p2)
+        }
+    }
+
     pub fn is_cencored(&self) -> bool {
         (self.flags & REVISION_FLAG_CENSORED) != 0
     }