rust/hg-core/src/revlog/revlog.rs
changeset 49174 3f86ee422095
parent 49094 a9ece9796a97
child 49217 13dfad0f9f7a
--- a/rust/hg-core/src/revlog/revlog.rs	Wed May 04 16:01:55 2022 -0400
+++ b/rust/hg-core/src/revlog/revlog.rs	Thu May 05 15:38:29 2022 +0100
@@ -378,7 +378,7 @@
         }
     }
 
-    pub fn is_cencored(&self) -> bool {
+    pub fn is_censored(&self) -> bool {
         (self.flags & REVISION_FLAG_CENSORED) != 0
     }
 
@@ -389,7 +389,7 @@
     }
 
     /// The data for this entry, after resolving deltas if any.
-    pub fn data(&self) -> Result<Cow<'a, [u8]>, HgError> {
+    pub fn rawdata(&self) -> Result<Cow<'a, [u8]>, HgError> {
         let mut entry = self.clone();
         let mut delta_chain = vec![];
 
@@ -414,6 +414,13 @@
             Revlog::build_data_from_deltas(entry, &delta_chain)?.into()
         };
 
+        Ok(data)
+    }
+
+    fn check_data(
+        &self,
+        data: Cow<'a, [u8]>,
+    ) -> Result<Cow<'a, [u8]>, HgError> {
         if self.revlog.check_hash(
             self.p1,
             self.p2,
@@ -426,6 +433,14 @@
         }
     }
 
+    pub fn data(&self) -> Result<Cow<'a, [u8]>, HgError> {
+        let data = self.rawdata()?;
+        if self.is_censored() {
+            return Err(HgError::CensoredNodeError);
+        }
+        self.check_data(data)
+    }
+
     /// Extract the data contained in the entry.
     /// This may be a delta. (See `is_delta`.)
     fn data_chunk(&self) -> Result<Cow<'a, [u8]>, HgError> {