Mercurial > public > mercurial-scm > hg
diff rust/hg-core/src/revlog/revlog.rs @ 49174:3f86ee422095
censor: make rhg fall back to python when encountering a censored node
This is to make it support censor.policy=ignore without having
to duplicate that logic.
Also, change the censor test in such a way that it uses rhg now,
because extensions are disabled except when we call [hg censor].
Differential Revision: https://phab.mercurial-scm.org/D12607
author | Arseniy Alekseyev <aalekseyev@janestreet.com> |
---|---|
date | Thu, 05 May 2022 15:38:29 +0100 |
parents | a9ece9796a97 |
children | 13dfad0f9f7a |
line wrap: on
line diff
--- 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> {