equal
deleted
inserted
replaced
16 use super::nodemap_docket::NodeMapDocket; |
16 use super::nodemap_docket::NodeMapDocket; |
17 use super::patch; |
17 use super::patch; |
18 use crate::errors::HgError; |
18 use crate::errors::HgError; |
19 use crate::repo::Repo; |
19 use crate::repo::Repo; |
20 use crate::revlog::Revision; |
20 use crate::revlog::Revision; |
21 use crate::NULL_REVISION; |
21 use crate::{Node, NULL_REVISION}; |
22 |
22 |
23 #[derive(derive_more::From)] |
23 #[derive(derive_more::From)] |
24 pub enum RevlogError { |
24 pub enum RevlogError { |
25 InvalidRevision, |
25 InvalidRevision, |
26 /// Working directory is not supported |
26 /// Working directory is not supported |
49 /// Read only implementation of revlog. |
49 /// Read only implementation of revlog. |
50 pub struct Revlog { |
50 pub struct Revlog { |
51 /// When index and data are not interleaved: bytes of the revlog index. |
51 /// When index and data are not interleaved: bytes of the revlog index. |
52 /// When index and data are interleaved: bytes of the revlog index and |
52 /// When index and data are interleaved: bytes of the revlog index and |
53 /// data. |
53 /// data. |
54 pub(crate) index: Index, |
54 index: Index, |
55 /// When index and data are not interleaved: bytes of the revlog data |
55 /// When index and data are not interleaved: bytes of the revlog data |
56 data_bytes: Option<Box<dyn Deref<Target = [u8]> + Send>>, |
56 data_bytes: Option<Box<dyn Deref<Target = [u8]> + Send>>, |
57 /// When present on disk: the persistent nodemap for this revlog |
57 /// When present on disk: the persistent nodemap for this revlog |
58 nodemap: Option<nodemap::NodeTree>, |
58 nodemap: Option<nodemap::NodeTree>, |
59 } |
59 } |
115 } |
115 } |
116 |
116 |
117 /// Returns `true` if the `Revlog` has zero `entries`. |
117 /// Returns `true` if the `Revlog` has zero `entries`. |
118 pub fn is_empty(&self) -> bool { |
118 pub fn is_empty(&self) -> bool { |
119 self.index.is_empty() |
119 self.index.is_empty() |
|
120 } |
|
121 |
|
122 /// Returns the node ID for the given revision number, if it exists in this revlog |
|
123 pub fn node_from_rev(&self, rev: Revision) -> Option<&Node> { |
|
124 Some(self.index.get_entry(rev)?.hash()) |
120 } |
125 } |
121 |
126 |
122 /// Return the full data associated to a node. |
127 /// Return the full data associated to a node. |
123 #[timed] |
128 #[timed] |
124 pub fn get_node_rev( |
129 pub fn get_node_rev( |