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 (3 of 3 files). Show all

Unified · Split

3 files
  1. git-commitgraph/src/graph/mod.rs +2 −0
  2. git-commitgraph/src/graph/verify.rs +9 −0
  3. git-commitgraph/src/lib.rs +11 −1
git-commitgraph/src/graph/mod.rs+2−0
@@ -1,6 +1,7 @@
11 //! Operations on a complete commit graph.
22 mod access;
33 mod init;
4+///
45 pub mod verify;
56
67 use crate::file::File;
@@ -15,6 +16,7 @@ pub struct Graph { · 8 unmodified lines
1516 files: Vec<File>,
1617 }
1718
19+/// A generalized position for use in [`Graph`].
1820 #[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, Hash)]
1921 pub struct Position(pub u32);
2022
git-commitgraph/src/graph/verify.rs+9−0
@@ -50,15 +50,24 @@ pub enum Error<E: std::error::Error + 'static> { · 49 unmodified lines
5050 TooManyFiles(usize),
5151 }
5252
53+/// Statistics gathered while verifying the integrity of the graph as returned by [`Graph::verify_integrity()]`.
5354 #[derive(Clone, Debug, Eq, PartialEq)]
5455 #[cfg_attr(feature = "serde1", derive(serde::Deserialize, serde::Serialize))]
5556 pub 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.
5660 pub longest_path_length: Option<u32>,
61+ /// The total amount traversed commits.
5762 pub num_commits: u32,
63+ /// A mapping of `parent-count -> amount of [commits][file::Commit] with that count`.
5864 pub parent_counts: BTreeMap<u32, u32>,
5965 }
6066
6167 impl 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.
6271 pub fn verify_integrity<E>(
6372 &self,
6473 mut processor: impl FnMut(&file::Commit<'_>) -> Result<(), E>,
git-commitgraph/src/lib.rs+11−1
@@ -1,12 +1,22 @@
1+//! Read, verify, and traverse git commit graphs.
2+//!
3+//! A [commit graph][Graph] acts as a cache is a set of [graph files][file::File] each storing
4+//! various commits in a way that accelerates lookups considerably compared to traversing the git history by usual means.
5+//!
6+//! A [`Graph`] is generated as each [`File`][file::File] only contains a subset of all commits in the git commit
7+//! history to avoid having to recreate the entire cache each time the cache should be updated, thus avoiding to traverse
8+//! the git history that is already present in the [`Graph`].
19 #![forbid(unsafe_code)]
2−#![deny(rust_2018_idioms)]
10+#![deny(rust_2018_idioms, missing_docs)]
311
412 pub mod file;
513 pub mod graph;
614
715 pub use graph::Graph;
816
17+/// The number of generations that are considered 'infinite' commit history.
918 pub const GENERATION_NUMBER_INFINITY: u32 = 0xffff_ffff;
19+/// The biggest possible amount of commits in the history of a repository.
1020 pub const GENERATION_NUMBER_MAX: u32 = 0x3fff_ffff;
1121
1222 /// The maximum number of commits that can be stored in a commit graph.