[Updated] [+- ] D12438: rust-changelog: remove special parsing of empty changelog data for null rev
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Mon Apr 11 16:07:15 UTC 2022
martinvonz updated this revision to Diff 33002.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D12438?vs=32780&id=33002
BRANCH
default
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D12438/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D12438
AFFECTED FILES
rust/hg-core/src/revlog/changelog.rs
CHANGE DETAILS
diff --git a/rust/hg-core/src/revlog/changelog.rs b/rust/hg-core/src/revlog/changelog.rs
--- a/rust/hg-core/src/revlog/changelog.rs
+++ b/rust/hg-core/src/revlog/changelog.rs
@@ -1,6 +1,5 @@
use crate::errors::HgError;
use crate::repo::Repo;
-use crate::revlog::node::NULL_NODE;
use crate::revlog::revlog::{Revlog, RevlogError};
use crate::revlog::Revision;
use crate::revlog::{Node, NodePrefix};
@@ -33,7 +32,11 @@
rev: Revision,
) -> Result<ChangelogRevisionData, RevlogError> {
let bytes = self.revlog.get_rev_data(rev)?.into_owned();
- Ok(ChangelogRevisionData { bytes })
+ if bytes.is_empty() {
+ Ok(ChangelogRevisionData::null())
+ } else {
+ Ok(ChangelogRevisionData::new(bytes))
+ }
}
pub fn node_from_rev(&self, rev: Revision) -> Option<&Node> {
@@ -49,6 +52,16 @@
}
impl ChangelogRevisionData {
+ fn new(bytes: Vec<u8>) -> Self {
+ Self { bytes }
+ }
+
+ fn null() -> Self {
+ Self::new(
+ b"0000000000000000000000000000000000000000\n\n0 0\n\n".to_vec(),
+ )
+ }
+
/// Return an iterator over the lines of the entry.
pub fn lines(&self) -> impl Iterator<Item = &[u8]> {
self.bytes.split(|b| b == &b'\n')
@@ -59,10 +72,6 @@
pub fn manifest_node(&self) -> Result<Node, HgError> {
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)
- }
+ Node::from_hex_for_repo(manifest_node_hex)
}
}
To: martinvonz, #hg-reviewers, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20220411/91e0a2bd/attachment-0002.html>
More information about the Mercurial-patches
mailing list