Show More
@@ -1,6 +1,5 b'' | |||||
1 | use crate::errors::HgError; |
|
1 | use crate::errors::HgError; | |
2 | use crate::repo::Repo; |
|
2 | use crate::repo::Repo; | |
3 | use crate::revlog::node::NULL_NODE; |
|
|||
4 | use crate::revlog::revlog::{Revlog, RevlogError}; |
|
3 | use crate::revlog::revlog::{Revlog, RevlogError}; | |
5 | use crate::revlog::Revision; |
|
4 | use crate::revlog::Revision; | |
6 | use crate::revlog::{Node, NodePrefix}; |
|
5 | use crate::revlog::{Node, NodePrefix}; | |
@@ -33,7 +32,11 b' impl Changelog {' | |||||
33 | rev: Revision, |
|
32 | rev: Revision, | |
34 | ) -> Result<ChangelogRevisionData, RevlogError> { |
|
33 | ) -> Result<ChangelogRevisionData, RevlogError> { | |
35 | let bytes = self.revlog.get_rev_data(rev)?.into_owned(); |
|
34 | let bytes = self.revlog.get_rev_data(rev)?.into_owned(); | |
36 | Ok(ChangelogRevisionData { bytes }) |
|
35 | if bytes.is_empty() { | |
|
36 | Ok(ChangelogRevisionData::null()) | |||
|
37 | } else { | |||
|
38 | Ok(ChangelogRevisionData::new(bytes)) | |||
|
39 | } | |||
37 | } |
|
40 | } | |
38 |
|
41 | |||
39 | pub fn node_from_rev(&self, rev: Revision) -> Option<&Node> { |
|
42 | pub fn node_from_rev(&self, rev: Revision) -> Option<&Node> { | |
@@ -49,6 +52,16 b' pub struct ChangelogRevisionData {' | |||||
49 | } |
|
52 | } | |
50 |
|
53 | |||
51 | impl ChangelogRevisionData { |
|
54 | impl ChangelogRevisionData { | |
|
55 | fn new(bytes: Vec<u8>) -> Self { | |||
|
56 | Self { bytes } | |||
|
57 | } | |||
|
58 | ||||
|
59 | fn null() -> Self { | |||
|
60 | Self::new( | |||
|
61 | b"0000000000000000000000000000000000000000\n\n0 0\n\n".to_vec(), | |||
|
62 | ) | |||
|
63 | } | |||
|
64 | ||||
52 | /// Return an iterator over the lines of the entry. |
|
65 | /// Return an iterator over the lines of the entry. | |
53 | pub fn lines(&self) -> impl Iterator<Item = &[u8]> { |
|
66 | pub fn lines(&self) -> impl Iterator<Item = &[u8]> { | |
54 | self.bytes.split(|b| b == &b'\n') |
|
67 | self.bytes.split(|b| b == &b'\n') | |
@@ -59,10 +72,6 b' impl ChangelogRevisionData {' | |||||
59 | pub fn manifest_node(&self) -> Result<Node, HgError> { |
|
72 | pub fn manifest_node(&self) -> Result<Node, HgError> { | |
60 | let manifest_node_hex = |
|
73 | let manifest_node_hex = | |
61 | self.lines().next().expect("Empty iterator from split()?"); |
|
74 | self.lines().next().expect("Empty iterator from split()?"); | |
62 | if manifest_node_hex.is_empty() { |
|
75 | Node::from_hex_for_repo(manifest_node_hex) | |
63 | Ok(NULL_NODE) |
|
|||
64 | } else { |
|
|||
65 | Node::from_hex_for_repo(manifest_node_hex) |
|
|||
66 | } |
|
|||
67 | } |
|
76 | } | |
68 | } |
|
77 | } |
General Comments 0
You need to be logged in to leave comments.
Login now