rust-changelog: don't skip empty lines when iterating over changeset lines
The first empty line in the changeset indicates the end of headers and
beginning of description. Callers can't know figure out where that
position is if empty lines are skipped.
Differential Revision: https://phab.mercurial-scm.org/D12426
--- a/rust/hg-core/src/revlog/changelog.rs Thu Mar 31 22:02:46 2022 -0700
+++ b/rust/hg-core/src/revlog/changelog.rs Thu Mar 31 22:06:26 2022 -0700
@@ -51,17 +51,18 @@
impl ChangelogRevisionData {
/// Return an iterator over the lines of the entry.
pub fn lines(&self) -> impl Iterator<Item = &[u8]> {
- self.bytes
- .split(|b| b == &b'\n')
- .filter(|line| !line.is_empty())
+ self.bytes.split(|b| b == &b'\n')
}
/// Return the node id of the `manifest` referenced by this `changelog`
/// entry.
pub fn manifest_node(&self) -> Result<Node, HgError> {
- match self.lines().next() {
- None => Ok(NULL_NODE),
- Some(x) => Node::from_hex_for_repo(x),
+ let manifest_node_hex =
+ self.lines().next().expect("Empty iterator from split()?");
+ if manifest_node_hex.is_empty() {
+ Ok(NULL_NODE)
+ } else {
+ Node::from_hex_for_repo(manifest_node_hex)
}
}
}