History

remaining docs for git-commitgraph crate

Sebastian Thiel committed 5 years ago

Commit 91461761 parent a81ea673 files · +22 −1Browse files

Showing the changes to git-commitgraph/src/graph (2 of 3 files). Show all

Unified · Split

2 files
  1. git-commitgraph/src/graph/mod.rs +2 −0
  2. git-commitgraph/src/graph/verify.rs +9 −0
git-commitgraph/src/graph/mod.rs+2−0
@@ -1,6 +1,7 @@
1//! Operations on a complete commit graph.1//! Operations on a complete commit graph.
2mod access;2mod access;
3mod init;3mod init;
4///
4pub mod verify;5pub mod verify;
5 6
6use crate::file::File;7use crate::file::File;
@@ -15,6 +16,7 @@ pub struct Graph { · 8 unmodified lines
15 files: Vec<File>,16 files: Vec<File>,
16}17}
17 18
19/// A generalized position for use in [`Graph`].
18#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, Hash)]20#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, Hash)]
19pub struct Position(pub u32);21pub struct Position(pub u32);
20 22
git-commitgraph/src/graph/verify.rs+9−0
@@ -50,15 +50,24 @@ pub enum Error<E: std::error::Error + 'static> { · 49 unmodified lines
50 TooManyFiles(usize),50 TooManyFiles(usize),
51}51}
52 52
53/// Statistics gathered while verifying the integrity of the graph as returned by [`Graph::verify_integrity()]`.
53#[derive(Clone, Debug, Eq, PartialEq)]54#[derive(Clone, Debug, Eq, PartialEq)]
54#[cfg_attr(feature = "serde1", derive(serde::Deserialize, serde::Serialize))]55#[cfg_attr(feature = "serde1", derive(serde::Deserialize, serde::Serialize))]
55pub struct Outcome {56pub struct Outcome {
57 /// The longest consecutive amount of commits in a chain of commits.
58 ///
59 /// For example, a repository with 10 commits would have 10 as value.
56 pub longest_path_length: Option<u32>,60 pub longest_path_length: Option<u32>,
61 /// The total amount traversed commits.
57 pub num_commits: u32,62 pub num_commits: u32,
63 /// A mapping of `parent-count -> amount of [commits][file::Commit] with that count`.
58 pub parent_counts: BTreeMap<u32, u32>,64 pub parent_counts: BTreeMap<u32, u32>,
59}65}
60 66
61impl Graph {67impl Graph {
68 /// Traverse all commits in the graph and call `processor(&commit) -> Result<(), E>` on it while verifying checksums.
69 ///
70 /// When `processor` returns an error, the entire verification is stopped and the error returned.
62 pub fn verify_integrity<E>(71 pub fn verify_integrity<E>(
63 &self,72 &self,
64 mut processor: impl FnMut(&file::Commit<'_>) -> Result<(), E>,73 mut processor: impl FnMut(&file::Commit<'_>) -> Result<(), E>,