comparison rust/hg-core/src/revlog/changelog.rs @ 48198:61ce70fd420e

rhg: handle null changelog and manifest revisions Differential Revision: https://phab.mercurial-scm.org/D11650
author Arseniy Alekseyev <aalekseyev@janestreet.com>
date Tue, 12 Oct 2021 19:43:51 +0100
parents 87e3f878e65f
children 20d0d896183e
comparison
equal deleted inserted replaced
48197:63e86fc9bfec 48198:61ce70fd420e
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;
3 use crate::revlog::revlog::{Revlog, RevlogError}; 4 use crate::revlog::revlog::{Revlog, RevlogError};
4 use crate::revlog::Revision; 5 use crate::revlog::Revision;
5 use crate::revlog::{Node, NodePrefix}; 6 use crate::revlog::{Node, NodePrefix};
6 7
7 /// A specialized `Revlog` to work with `changelog` data format. 8 /// A specialized `Revlog` to work with `changelog` data format.
56 } 57 }
57 58
58 /// Return the node id of the `manifest` referenced by this `changelog` 59 /// Return the node id of the `manifest` referenced by this `changelog`
59 /// entry. 60 /// entry.
60 pub fn manifest_node(&self) -> Result<Node, HgError> { 61 pub fn manifest_node(&self) -> Result<Node, HgError> {
61 Node::from_hex_for_repo( 62 match self.lines().next() {
62 self.lines() 63 None => Ok(NULL_NODE),
63 .next() 64 Some(x) => Node::from_hex_for_repo(x),
64 .ok_or_else(|| HgError::corrupted("empty changelog entry"))?, 65 }
65 )
66 } 66 }
67 } 67 }