Collect all unique hashes referenced by hunks into the hash dedup table. This walks every position, graph node, and introduced_by field in every hunk and registers each `Some(Hash)` in the table.
(
&self,
table: &mut format_v3::HashDedupTable,
)
| 891 | /// This walks every position, graph node, and introduced_by field in |
| 892 | /// every hunk and registers each `Some(Hash)` in the table. |
| 893 | fn collect_hunk_hashes( |
| 894 | &self, |
| 895 | table: &mut format_v3::HashDedupTable, |
| 896 | ) -> Result<(), format_v3::FormatError> { |
| 897 | use crate::change::atom::{Atom, EdgeUpdate, Insertion, NewEdge}; |
| 898 | |
| 899 | fn collect_position_hash( |
| 900 | pos: &crate::Position<Option<Hash>>, |
| 901 | table: &mut format_v3::HashDedupTable, |
| 902 | ) -> Result<(), format_v3::FormatError> { |
| 903 | if let Some(ref h) = pos.change { |
| 904 | table.insert(*h.as_bytes())?; |
| 905 | } |
| 906 | Ok(()) |
| 907 | } |
| 908 | |
| 909 | fn collect_graph_node_hash( |
| 910 | node: &crate::GraphNode<Option<Hash>>, |
| 911 | table: &mut format_v3::HashDedupTable, |
| 912 | ) -> Result<(), format_v3::FormatError> { |
| 913 | if let Some(ref h) = node.change { |
| 914 | table.insert(*h.as_bytes())?; |
| 915 | } |
| 916 | Ok(()) |
| 917 | } |
| 918 | |
| 919 | fn collect_insertion_hashes( |
| 920 | v: &Insertion<Option<Hash>>, |
| 921 | table: &mut format_v3::HashDedupTable, |
| 922 | ) -> Result<(), format_v3::FormatError> { |
| 923 | for p in &v.predecessors { |
| 924 | collect_position_hash(p, table)?; |
| 925 | } |
| 926 | for p in &v.successors { |
| 927 | collect_position_hash(p, table)?; |
| 928 | } |
| 929 | collect_position_hash(&v.inode, table)?; |
| 930 | Ok(()) |
| 931 | } |
| 932 | |
| 933 | fn collect_new_edge_hashes( |
| 934 | e: &NewEdge<Option<Hash>>, |
| 935 | table: &mut format_v3::HashDedupTable, |
| 936 | ) -> Result<(), format_v3::FormatError> { |
| 937 | collect_position_hash(&e.from, table)?; |
| 938 | collect_graph_node_hash(&e.to, table)?; |
| 939 | if let Some(ref h) = e.introduced_by { |
| 940 | table.insert(*h.as_bytes())?; |
| 941 | } |
| 942 | Ok(()) |
| 943 | } |
| 944 | |
| 945 | fn collect_edge_update_hashes( |
| 946 | em: &EdgeUpdate<Option<Hash>>, |
| 947 | table: &mut format_v3::HashDedupTable, |
| 948 | ) -> Result<(), format_v3::FormatError> { |
| 949 | for e in &em.edges { |
| 950 | collect_new_edge_hashes(e, table)?; |