Mercurial > hg
comparison rust/hg-core/src/dirstate_tree/on_disk.rs @ 51617:f808fa119212 stable
dirstate-v2: check that root nodes are at the root before writing
More explanations in the previous changeset.
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Mon, 06 May 2024 13:07:02 +0200 |
parents | 9dbbaecfc950 |
children | 918ceb5a3d25 |
comparison
equal
deleted
inserted
replaced
51616:9dbbaecfc950 | 51617:f808fa119212 |
---|---|
638 dirstate_map, | 638 dirstate_map, |
639 append, | 639 append, |
640 out: Vec::with_capacity(size_guess), | 640 out: Vec::with_capacity(size_guess), |
641 }; | 641 }; |
642 | 642 |
643 let root_nodes = writer.write_nodes(dirstate_map.root.as_ref())?; | 643 let root_nodes = dirstate_map.root.as_ref(); |
644 for node in root_nodes.iter() { | |
645 // Catch some corruptions before we write to disk | |
646 let full_path = node.full_path(dirstate_map.on_disk)?; | |
647 let base_name = node.base_name(dirstate_map.on_disk)?; | |
648 if full_path != base_name { | |
649 let explanation = format!( | |
650 "Dirstate root node '{}' is not at the root", | |
651 full_path | |
652 ); | |
653 return Err(HgError::corrupted(explanation).into()); | |
654 } | |
655 } | |
656 let root_nodes = writer.write_nodes(root_nodes)?; | |
644 | 657 |
645 let unreachable_bytes = if append { | 658 let unreachable_bytes = if append { |
646 dirstate_map.unreachable_bytes | 659 dirstate_map.unreachable_bytes |
647 } else { | 660 } else { |
648 0 | 661 0 |