]>
git.proxmox.com Git - rustc.git/blob - vendor/gix-revwalk/src/lib.rs
1 //! Utility types for traversing the git commit-graph.
3 //! This crate considers itself very much *plumbing* and is meant for consumption by other plumbing crates.
4 #![deny(missing_docs, rust_2018_idioms)]
5 #![forbid(unsafe_code)]
7 /// A graph of commits which additionally allows to associate data with commits.
9 /// It starts empty, but each access may fill it with commit information.
10 /// Note that the traversal can be accelerated if a [commit-graph][gix_commitgraph::Graph] is also made available.
12 /// ### About replacements
14 /// Object replacements is an object database feature to substitute one object with another. We assume that this is transparently
15 /// implemented by the `find` function that returns objects. Also we assume that the commitgraph as been written with replacements
16 /// active to provide a consistent view.
18 /// ### Odb or `find` configuration
20 /// The `find` handle should be setup to *quickly determine if an object exists or not* to assure quick operation *on shallow repositories*.
21 /// This typically means that it should not re-read the odb if there is an object miss.
23 /// Most usage of the Graph will benefit from fast ODB lookups, so setting up an object cache will be beneficial. If that's not the case,
24 /// the method docs will inform about that.
26 /// Additionally, and only if `T` is [`Commit<T>`][graph::Commit], there is *no need for an object cache* as we keep track of
27 /// everything related to commit traversal in our own hashmap.
28 pub struct Graph
<'find
, T
> {
29 /// A way to resolve a commit from the object database.
30 find
: Box
<graph
::FindFn
<'find
>>,
31 /// A way to speedup commit access, essentially a multi-file commit database.
32 cache
: Option
<gix_commitgraph
::Graph
>,
33 /// The set of cached commits that we have seen once, along with data associated with them.
35 /// A buffer for writing commit data into.
37 /// Another buffer we typically use to store parents.
44 /// A utility type implementing a queue which can be used to automatically sort data by its time in ascending order.
46 /// Note that the performance of this queue is very relevant to overall algorithm performance of many graph-walking algorithms,
47 /// and as it stands our implementation is about 6% slower in practice, probably also depending on the size of the stored data.
49 pub struct PriorityQueue
<K
: Ord
, T
>(std
::collections
::BinaryHeap
<queue
::Item
<K
, T
>>);