Show More
@@ -79,6 +79,32 b' impl Revlog {' | |||
|
79 | 79 | }) |
|
80 | 80 | } |
|
81 | 81 | |
|
82 | /// Return number of entries of the `Revlog`. | |
|
83 | pub fn len(&self) -> usize { | |
|
84 | self.index().len() | |
|
85 | } | |
|
86 | ||
|
87 | /// Returns `true` if the `Revlog` has zero `entries`. | |
|
88 | pub fn is_empty(&self) -> bool { | |
|
89 | self.index().is_empty() | |
|
90 | } | |
|
91 | ||
|
92 | /// Return the full data associated to a node. | |
|
93 | #[timed] | |
|
94 | pub fn get_node_rev(&self, node: &[u8]) -> Result<Revision, RevlogError> { | |
|
95 | let index = self.index(); | |
|
96 | // This is brute force. But it is fast enough for now. | |
|
97 | // Optimization will come later. | |
|
98 | for rev in (0..self.len() as Revision).rev() { | |
|
99 | let index_entry = | |
|
100 | index.get_entry(rev).ok_or(RevlogError::Corrupted)?; | |
|
101 | if node == index_entry.hash() { | |
|
102 | return Ok(rev); | |
|
103 | } | |
|
104 | } | |
|
105 | Err(RevlogError::InvalidRevision) | |
|
106 | } | |
|
107 | ||
|
82 | 108 | /// Return the full data associated to a revision. |
|
83 | 109 | /// |
|
84 | 110 | /// All entries required to build the final data out of deltas will be |
General Comments 0
You need to be logged in to leave comments.
Login now