| 1 | //! Incremental graph queries backed by a [`ParentsProvider`]. |
| 2 | //! |
| 3 | //! Ported incrementally from `vcsgraph/graph.py`. Phase 1 covers the trivial |
| 4 | //! methods that don't need a BFS searcher: parent/child map queries, |
| 5 | //! topological ordering (delegated to [`crate::tsort::TopoSorter`]), and the |
| 6 | //! left-hand ancestry walks. |
| 7 | |
| 8 | use craterust-analyzer cargo vcs-graph 3.6.0 crate/::bfsrust-analyzer cargo vcs-graph 3.6.0 bfs/::BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#; |
| 9 | use craterust-analyzer cargo vcs-graph 3.6.0 crate/::parents_providerrust-analyzer cargo vcs-graph 3.6.0 parents_provider/::{DictParentsProviderrust-analyzer cargo vcs-graph 3.6.0 parents_provider/DictParentsProvider#, ParentsProviderrust-analyzer cargo vcs-graph 3.6.0 parents_provider/ParentsProvider#}; |
| 10 | use craterust-analyzer cargo vcs-graph 3.6.0 crate/::tsortrust-analyzer cargo vcs-graph 3.6.0 tsort/::TopoSorterrust-analyzer cargo vcs-graph 3.6.0 tsort/TopoSorter#; |
| 11 | use craterust-analyzer cargo vcs-graph 3.6.0 crate/::{Errorrust-analyzer cargo vcs-graph 3.6.0 Error#, ParentMaprust-analyzer cargo vcs-graph 3.6.0 ParentMap#, Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#}; |
| 12 | use rustc_hashrust-analyzer cargo rustc-hash 2.1.2 crate/::{FxHashMaprust-analyzer cargo rustc-hash 2.1.2 FxHashMap#, FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#}; |
| 13 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::{BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#, HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#}; |
| 14 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::hashrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/::Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#; |
| 15 | |
| 16 | /// A revision graph backed by an arbitrary [`ParentsProvider`]. |
| 17 | /// |
| 18 | /// Unlike [`crate::KnownGraph`] this type does not own the full ancestry — |
| 19 | /// queries are dispatched to the provider on demand. |
| 20 | pub struct Graphrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#<K, P> |
| 21 | where |
| 22 | K: Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 23 | P: ParentsProviderrust-analyzer cargo vcs-graph 3.6.0 parents_provider/ParentsProvider#<K>, |
| 24 | { |
| 25 | providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.: P, |
| 26 | _markerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#_marker.: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::markerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/::PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<K>, |
| 27 | } |
| 28 | |
| 29 | /// An error returned from one of `Graph`'s traversal methods. |
| 30 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)] |
| 31 | pub enum GraphErrorrust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#<K> { |
| 32 | /// A revision reachable via the ancestry walk turned out to be a ghost, |
| 33 | /// so we cannot compute a revno for it. |
| 34 | GhostRevisionrust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#GhostRevision# { targetrust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#GhostRevision#target.: K, ghostrust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#GhostRevision#ghost.: K }, |
| 35 | /// A revision was not known to the provider at all. |
| 36 | RevisionNotPresentrust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#RevisionNotPresent#(K), |
| 37 | /// A cycle was detected during a topological walk. |
| 38 | Cyclerust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#Cycle#(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K>), |
| 39 | } |
| 40 | |
| 41 | impl<K: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for GraphErrorrust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#<K> { |
| 42 | fn fmtrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`GraphError<K>`][Display]fmt().(&self, f: &mut stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 43 | match self { |
| 44 | GraphErrorrust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#::GhostRevisionrust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#GhostRevision# { targetrust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#GhostRevision#target., ghostrust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#GhostRevision#ghost. } => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!( |
| 45 | f, |
| 46 | "ghost revision {ghost} reached while finding revno for {target}" |
| 47 | ), |
| 48 | GraphErrorrust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#::RevisionNotPresentrust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#RevisionNotPresent#(key) => { |
| 49 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "revision {key} not present in graph") |
| 50 | } |
| 51 | GraphErrorrust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#::Cyclerust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#Cycle#(nodes) => { |
| 52 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "cycle detected: ")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 53 | for (i, n) in nodes.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 54 | if i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().0 { |
| 55 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, " -> ")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 56 | } |
| 57 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{n}")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 58 | } |
| 59 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | impl<K: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# + stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for GraphErrorrust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#<K> {} |
| 66 | |
| 67 | impl<K, P> Graphrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#<K, P> |
| 68 | where |
| 69 | K: Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, |
| 70 | P: ParentsProviderrust-analyzer cargo vcs-graph 3.6.0 parents_provider/ParentsProvider#<K>, |
| 71 | { |
| 72 | /// Construct a new `Graph` backed by `provider`. |
| 73 | pub fn newrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]new().(provider: P) -> Selfrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`] { |
| 74 | Graphrust-analyzer cargo vcs-graph 3.6.0 graph/Graph# { |
| 75 | providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider., |
| 76 | _markerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#_marker.: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::markerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/::PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | /// Borrow the underlying parents provider. |
| 81 | pub fn parents_providerrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]parents_provider().(&self) -> &P { |
| 82 | &self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider. |
| 83 | } |
| 84 | |
| 85 | /// Return a parent map for `keys`. Missing keys are omitted; ghosts are |
| 86 | /// reported as [`Parents::Ghost`]. |
| 87 | pub fn get_parent_maprust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]get_parent_map().<I>(&self, keys: I) -> ParentMaprust-analyzer cargo vcs-graph 3.6.0 ParentMap#<K> |
| 88 | where |
| 89 | I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = K>, |
| 90 | { |
| 91 | // ParentsProvider takes a std HashSet; collect directly into one |
| 92 | // rather than going via FxHashSet and copying. |
| 93 | let set: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#<K> = keys.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 94 | self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider..get_parent_maprust-analyzer cargo vcs-graph 3.6.0 parents_provider/ParentsProvider#get_parent_map().(&set) |
| 95 | } |
| 96 | |
| 97 | /// Return a mapping from parent → children for the requested keys. |
| 98 | /// |
| 99 | /// This is the inversion of [`get_parent_map`](Self::get_parent_map); |
| 100 | /// only the supplied `keys` are considered as potential children. Ghosts |
| 101 | /// are skipped. The children lists are sorted (by insertion order driven |
| 102 | /// by the BTreeMap iteration) to match Python's `sorted()` behavior. |
| 103 | pub fn get_child_maprust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]get_child_map().<I>(&self, keys: I) -> BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<K, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K>> |
| 104 | where |
| 105 | K: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#, |
| 106 | I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = K>, |
| 107 | { |
| 108 | let parent_map = self.get_parent_maprust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]get_parent_map().(keys); |
| 109 | // Walk children in sorted order so parent→children lists mirror the |
| 110 | // Python implementation's sorted() iteration. |
| 111 | let mut sorted: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<K, Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#<K>> = BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V>`]new().(); |
| 112 | for (k, v) in parent_map { |
| 113 | sorted.insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().(k, v); |
| 114 | } |
| 115 | let mut result: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<K, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K>> = BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V>`]new().(); |
| 116 | for (child, parents) in sorted { |
| 117 | if let Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Knownrust-analyzer cargo vcs-graph 3.6.0 Parents#Known#(ps) = parents { |
| 118 | for parent in ps { |
| 119 | result.entryrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]entry().(parent).or_defaultrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/entry/impl#[`Entry<'a, K, V, A>`]or_default().().pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(child.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 120 | } |
| 121 | } |
| 122 | } |
| 123 | result |
| 124 | } |
| 125 | |
| 126 | /// Iterate over the ancestry of `revision_ids` in topological order. |
| 127 | /// |
| 128 | /// This delegates to [`TopoSorter`]. The topological order only ensures |
| 129 | /// that parents come before children within the ancestry that is |
| 130 | /// reachable from the input revisions. |
| 131 | pub fn iter_topo_orderrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]iter_topo_order().<I>(&self, revisions: I) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K>, Errorrust-analyzer cargo vcs-graph 3.6.0 Error#<K>> |
| 132 | where |
| 133 | K: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#, |
| 134 | I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = K>, |
| 135 | { |
| 136 | let pm = self.get_parent_maprust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]get_parent_map().(revisions); |
| 137 | let iter = pm.into_iterrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`][IntoIterator]into_iter().().filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|(k, parents)| match parents { |
| 138 | Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Knownrust-analyzer cargo vcs-graph 3.6.0 Parents#Known#(ps) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((k, ps)), |
| 139 | Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Ghostrust-analyzer cargo vcs-graph 3.6.0 Parents#Ghost# => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 140 | }); |
| 141 | TopoSorterrust-analyzer cargo vcs-graph 3.6.0 tsort/TopoSorter#::newrust-analyzer cargo vcs-graph 3.6.0 tsort/impl#[`TopoSorter<K>`]new().(iter).sortedrust-analyzer cargo vcs-graph 3.6.0 tsort/impl#[`TopoSorter<K>`]sorted().() |
| 142 | } |
| 143 | |
| 144 | /// Walk the left-hand ancestry of `start_key`, stopping when a key in |
| 145 | /// `stop_keys` is encountered. Yields `start_key` first, then its |
| 146 | /// left-most parent, and so on. |
| 147 | /// |
| 148 | /// Errors with [`GraphError::RevisionNotPresent`] if a key in the walk is |
| 149 | /// missing from the provider. |
| 150 | pub fn iter_lefthand_ancestryrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]iter_lefthand_ancestry().<S>( |
| 151 | &self, |
| 152 | start_key: K, |
| 153 | stop_keys: S, |
| 154 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K>, GraphErrorrust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#<K>> |
| 155 | where |
| 156 | S: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = K>, |
| 157 | { |
| 158 | let stop_keys: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = stop_keys.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 159 | let mut result = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 160 | let mut next_key = start_key; |
| 161 | loop { |
| 162 | if stop_keys.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&next_key) { |
| 163 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(result); |
| 164 | } |
| 165 | let pm = self.get_parent_maprust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]get_parent_map().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/once/once().(next_key.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().())); |
| 166 | let parents = match pm.getrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]get().(&next_key) { |
| 167 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Knownrust-analyzer cargo vcs-graph 3.6.0 Parents#Known#(ps)) => ps.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().(), |
| 168 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Ghostrust-analyzer cargo vcs-graph 3.6.0 Parents#Ghost#) => { |
| 169 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(GraphErrorrust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#::RevisionNotPresentrust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#RevisionNotPresent#(next_key)); |
| 170 | } |
| 171 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(GraphErrorrust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#::RevisionNotPresentrust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#RevisionNotPresent#(next_key)), |
| 172 | }; |
| 173 | result.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(next_key.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 174 | if parents.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() { |
| 175 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(result); |
| 176 | } |
| 177 | next_key = parents.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().nextrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/into_iter/impl#[`IntoIter<T, A>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | /// Iterate over the ancestry reachable from `revision_ids`, yielding |
| 182 | /// `(key, parents)` pairs in a BFS order. Ghosts are yielded with |
| 183 | /// `Parents::Ghost`. |
| 184 | pub fn iter_ancestryrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]iter_ancestry().<I>(&self, revision_ids: I) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(K, Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#<K>)> |
| 185 | where |
| 186 | I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = K>, |
| 187 | { |
| 188 | let mut pending: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = revision_ids.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 189 | let mut processed: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().(); |
| 190 | let mut out: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(K, Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#<K>)> = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 191 | |
| 192 | while !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().pending.is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().() { |
| 193 | processed.extendrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][`Extend<T>`]extend().(pending.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().()); |
| 194 | let next_map = self.get_parent_maprust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]get_parent_map().(pending.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().()); |
| 195 | let mut next_pending: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().(); |
| 196 | let mut seen_in_map: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().(); |
| 197 | |
| 198 | for (k, parents) in next_map.iterrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]iter().() { |
| 199 | seen_in_map.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(k.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 200 | if let Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Knownrust-analyzer cargo vcs-graph 3.6.0 Parents#Known#(ps) = parents { |
| 201 | for p in ps { |
| 202 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().processed.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(p) { |
| 203 | next_pending.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(p.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 204 | } |
| 205 | } |
| 206 | } |
| 207 | out.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((k.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), parents.clonerust-analyzer cargo vcs-graph 3.6.0 impl#[`Parents<K>`][Clone]clone().())); |
| 208 | } |
| 209 | // Keys in `pending` that the provider didn't return are ghosts. |
| 210 | for ghost in pending.differencerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]difference().(&seen_in_map) { |
| 211 | out.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((ghost.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Ghostrust-analyzer cargo vcs-graph 3.6.0 Parents#Ghost#)); |
| 212 | } |
| 213 | pending = next_pending; |
| 214 | } |
| 215 | out |
| 216 | } |
| 217 | |
| 218 | /// Find the left-hand distance from `target_revision_id` to the origin. |
| 219 | /// |
| 220 | /// `known_distances` is an iterable of `(revision_id, distance)` pairs |
| 221 | /// that seed the search. The origin sentinel (any key equal to `null`, |
| 222 | /// supplied by the caller) should be included with distance 0. |
| 223 | /// |
| 224 | /// This mirrors Python's `find_distance_to_null`, which hard-codes the |
| 225 | /// sentinel `NULL_REVISION = b"null:"`. Keeping the sentinel Python-side |
| 226 | /// lets the Rust core stay string-typed without baking in bytes. |
| 227 | pub fn find_distance_to_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_distance_to_null().( |
| 228 | &self, |
| 229 | target_revision_id: K, |
| 230 | known_distances: impl IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = (K, i64)>, |
| 231 | null: K, |
| 232 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<i64, GraphErrorrust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#<K>> { |
| 233 | let mut known_revnos: FxHashMaprust-analyzer cargo rustc-hash 2.1.2 FxHashMap#<K, i64> = known_distances.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 234 | let mut cur_tip = target_revision_id.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(); |
| 235 | let mut num_steps: i64 = 0; |
| 236 | known_revnos.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().(null.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), 0); |
| 237 | |
| 238 | let mut searching_known_tips: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K> = known_revnos.keysrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]keys().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 239 | let mut unknown_searched: FxHashMaprust-analyzer cargo rustc-hash 2.1.2 FxHashMap#<K, i64> = FxHashMaprust-analyzer cargo rustc-hash 2.1.2 FxHashMap#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S>`][Default]default().(); |
| 240 | |
| 241 | while !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().known_revnos.contains_keyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]contains_key().(&cur_tip) { |
| 242 | unknown_searched.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().(cur_tip.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), num_steps); |
| 243 | num_steps rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign().1; |
| 244 | |
| 245 | let mut to_search: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = searching_known_tips.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 246 | to_search.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(cur_tip.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 247 | let parent_map = self.get_parent_maprust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]get_parent_map().(to_search); |
| 248 | |
| 249 | let parents = match parent_map.getrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]get().(&cur_tip) { |
| 250 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Knownrust-analyzer cargo vcs-graph 3.6.0 Parents#Known#(ps)) if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().ps.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() => ps, |
| 251 | _ => { |
| 252 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(GraphErrorrust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#::GhostRevisionrust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#GhostRevision# { |
| 253 | targetrust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#GhostRevision#target.: target_revision_id, |
| 254 | ghostrust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#GhostRevision#ghost.: cur_tip, |
| 255 | }); |
| 256 | } |
| 257 | }; |
| 258 | let next_tip = parents[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(); |
| 259 | |
| 260 | let mut next_known_tips: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K> = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 261 | for revision_id in &searching_known_tips { |
| 262 | let parents = match parent_map.getrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]get().(revision_id) { |
| 263 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Knownrust-analyzer cargo vcs-graph 3.6.0 Parents#Known#(ps)) if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().ps.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() => ps, |
| 264 | _ => continue, |
| 265 | }; |
| 266 | let next = parents[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(); |
| 267 | let next_revno = known_revnos[rust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`][`Index<&Q>`]index().revision_id]rust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`][`Index<&Q>`]index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub().1; |
| 268 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(unknown_steps) = unknown_searched.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(&next) { |
| 269 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(next_revno rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<&i64>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<&i64>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<&i64>`]add().unknown_steps); |
| 270 | } |
| 271 | if known_revnos.contains_keyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]contains_key().(&next) { |
| 272 | continue; |
| 273 | } |
| 274 | known_revnos.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().(next.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), next_revno); |
| 275 | next_known_tips.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(next); |
| 276 | } |
| 277 | searching_known_tips = next_known_tips; |
| 278 | cur_tip = next_tip; |
| 279 | } |
| 280 | |
| 281 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(known_revnos[rust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`][`Index<&Q>`]index().&cur_tip]rust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`][`Index<&Q>`]index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<Self>`]add().num_steps) |
| 282 | } |
| 283 | |
| 284 | /// Find left-hand distances for every key in `keys`. |
| 285 | /// |
| 286 | /// Ghosts are reported as distance `-1`, matching the Python contract. |
| 287 | pub fn find_lefthand_distancesrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_lefthand_distances().( |
| 288 | &self, |
| 289 | keys: impl IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = K>, |
| 290 | null: K, |
| 291 | ) -> FxHashMaprust-analyzer cargo rustc-hash 2.1.2 FxHashMap#<K, i64> { |
| 292 | let mut result: FxHashMaprust-analyzer cargo rustc-hash 2.1.2 FxHashMap#<K, i64> = FxHashMaprust-analyzer cargo rustc-hash 2.1.2 FxHashMap#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S>`][Default]default().(); |
| 293 | let mut known: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(K, i64)> = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 294 | let mut ghosts: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K> = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 295 | for key in keys { |
| 296 | match self.find_distance_to_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_distance_to_null().(key.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), known.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().(), null.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()) { |
| 297 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(d) => { |
| 298 | known.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((key.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), d)); |
| 299 | result.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().(key, d); |
| 300 | } |
| 301 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(GraphErrorrust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#::GhostRevisionrust-analyzer cargo vcs-graph 3.6.0 graph/GraphError#GhostRevision# { .. }) => ghosts.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(key), |
| 302 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => { |
| 303 | // Other errors are unreachable from find_distance_to_null |
| 304 | // in practice. Match Python by skipping. |
| 305 | } |
| 306 | } |
| 307 | } |
| 308 | for ghost in ghosts { |
| 309 | result.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().(ghost, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][Neg]neg().1); |
| 310 | } |
| 311 | result |
| 312 | } |
| 313 | |
| 314 | /// Find the first lefthand ancestor of `tip_key` that merged `merged_key`. |
| 315 | /// |
| 316 | /// Walks the lefthand ancestry of `tip_key` one step at a time, stopping |
| 317 | /// as soon as a candidate is not a descendant of `merged_key`. Returns |
| 318 | /// the last candidate that *was* a descendant — or `None` if none is. |
| 319 | pub fn find_lefthand_mergerrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_lefthand_merger().(&self, merged_key: K, tip_key: K) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<K> |
| 320 | where |
| 321 | K: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#, |
| 322 | { |
| 323 | let descendants = self.find_descendantsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_descendants().(merged_key, tip_key.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 324 | let mut last_candidate: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<K> = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 325 | let mut next_key = tip_key; |
| 326 | loop { |
| 327 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().descendants.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&next_key) { |
| 328 | return last_candidate; |
| 329 | } |
| 330 | let pm = self.get_parent_maprust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]get_parent_map().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/once/once().(next_key.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().())); |
| 331 | let parents = match pm.getrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]get().(&next_key) { |
| 332 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Knownrust-analyzer cargo vcs-graph 3.6.0 Parents#Known#(ps)) => ps.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().(), |
| 333 | _ => { |
| 334 | // Missing entry or ghost — treat as end of walk. |
| 335 | return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(next_key); |
| 336 | } |
| 337 | }; |
| 338 | last_candidate = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(next_key); |
| 339 | if parents.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() { |
| 340 | return last_candidate; |
| 341 | } |
| 342 | next_key = parents.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().nextrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/into_iter/impl#[`IntoIter<T, A>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | /// Compute `(left_only, right_only)` — the set difference between the |
| 347 | /// ancestries of `left` and `right`. |
| 348 | pub fn find_differencerust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_difference().(&self, left: K, right: K) -> (FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K>, FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K>) |
| 349 | where |
| 350 | K: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#, |
| 351 | { |
| 352 | let (_border, common, searchers) = self.find_border_ancestorsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_border_ancestors().([left, right]); |
| 353 | // find_border_ancestors always returns one searcher per input |
| 354 | // revision, so for a 2-element input we know we get exactly two. |
| 355 | let mut pair: [BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>; 2] = match <[BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>; 2]>::try_fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`[T; N]`][`TryFrom<Vec<T, A>>`]try_from().(searchers) { |
| 356 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(pair) => pair, |
| 357 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!("find_border_ancestors returned a non-2 pair"), |
| 358 | }; |
| 359 | self.search_for_extra_commonrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]search_for_extra_common().(&common, &mut pair); |
| 360 | let [left_searcher, right_searcher] = pair; |
| 361 | let left_seen = &left_searcher.seenrust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#seen.; |
| 362 | let right_seen = &right_searcher.seenrust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#seen.; |
| 363 | ( |
| 364 | left_seen.differencerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]difference().(right_seen).clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(), |
| 365 | right_seen.differencerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]difference().(left_seen).clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(), |
| 366 | ) |
| 367 | } |
| 368 | |
| 369 | /// Run the "extra common" reconvergence pass on a pair of searchers |
| 370 | /// left in the state they finished `find_border_ancestors` in. Mirrors |
| 371 | /// Python's `_search_for_extra_common`. |
| 372 | /// |
| 373 | /// Takes a fixed-size `[BfsState; 2]` so the two-searcher restriction |
| 374 | /// is enforced at compile time instead of via a runtime assertion. |
| 375 | fn search_for_extra_commonrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]search_for_extra_common().(&self, _common: &FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K>, searchers: &mut [BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>; 2]) |
| 376 | where |
| 377 | K: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#, |
| 378 | { |
| 379 | let unique: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = searchers[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). |
| 380 | .seenrust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#seen. |
| 381 | .symmetric_differencerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]symmetric_difference().(&searchers[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..seenrust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#seen.) |
| 382 | .clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().() |
| 383 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 384 | if unique.is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().() { |
| 385 | return; |
| 386 | } |
| 387 | let parent_map = self.get_parent_maprust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]get_parent_map().(unique.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().()); |
| 388 | let unique = Selfrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]::remove_simple_descendantsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]remove_simple_descendants().(&unique, &parent_map); |
| 389 | |
| 390 | // Build unique-searchers: one per unique revision. |
| 391 | let mut unique_searchers: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>> = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 392 | for revision_id in unique.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().() { |
| 393 | let revs_to_search: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = { |
| 394 | let parent_idx = if searchers[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..seenrust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#seen..containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(revision_id) { |
| 395 | 0 |
| 396 | } else { |
| 397 | 1 |
| 398 | }; |
| 399 | let seed = [revision_id.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()]; |
| 400 | let anc = searchers[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().parent_idx]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..find_seen_ancestorsrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]find_seen_ancestors().(seed, &self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.); |
| 401 | if anc.is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().() { |
| 402 | [revision_id.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()].into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/iter/impl#[`[T; N]`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().() |
| 403 | } else { |
| 404 | anc |
| 405 | } |
| 406 | }; |
| 407 | let mut s = BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#::newrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]new().(revs_to_search); |
| 408 | s.next_setrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]next_set().(&self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.); |
| 409 | unique_searchers.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(s); |
| 410 | } |
| 411 | |
| 412 | // Compute initial ancestor_all_unique: intersection of all seen sets. |
| 413 | let mut ancestor_all_unique: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().(); |
| 414 | for (i, s) in unique_searchers.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 415 | if i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 { |
| 416 | ancestor_all_unique = s.seenrust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#seen..clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][Clone]clone().(); |
| 417 | } else { |
| 418 | ancestor_all_unique = ancestor_all_unique.intersectionrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]intersection().(&s.seenrust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#seen.).clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | loop { |
| 423 | let mut newly_seen_common: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().(); |
| 424 | for s in searchers.iter_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter_mut().() { |
| 425 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(set) = s.next_setrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]next_set().(&self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.) { |
| 426 | newly_seen_common.extendrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][`Extend<T>`]extend().(set); |
| 427 | } |
| 428 | } |
| 429 | let mut newly_seen_unique: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().(); |
| 430 | for s in unique_searchers.iter_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter_mut().() { |
| 431 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(set) = s.next_setrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]next_set().(&self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.) { |
| 432 | newly_seen_unique.extendrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][`Extend<T>`]extend().(set); |
| 433 | } |
| 434 | } |
| 435 | let mut new_common_unique: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().(); |
| 436 | for revision in &newly_seen_unique { |
| 437 | if unique_searchers.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]all().(|s| s.seenrust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#seen..containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(revision)) { |
| 438 | new_common_unique.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(revision.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 439 | } |
| 440 | } |
| 441 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().newly_seen_common.is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().() { |
| 442 | // Merge newly_seen_common seen-ancestors from each common searcher. |
| 443 | let mut expanded = newly_seen_common.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][Clone]clone().(); |
| 444 | for s in searchers.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() { |
| 445 | expanded |
| 446 | .extendrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][`Extend<T>`]extend().(s.find_seen_ancestorsrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]find_seen_ancestors().(expanded.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().(), &self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.)); |
| 447 | } |
| 448 | let expanded_frozen = expanded; |
| 449 | for s in searchers.iter_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter_mut().() { |
| 450 | s.start_searchingrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]start_searching().(expanded_frozen.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().(), &self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.); |
| 451 | } |
| 452 | let stop_searching_common: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = ancestor_all_unique |
| 453 | .intersectionrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]intersection().(&expanded_frozen) |
| 454 | .clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().() |
| 455 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 456 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().stop_searching_common.is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().() { |
| 457 | for s in searchers.iter_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter_mut().() { |
| 458 | s.stop_searching_anyrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]stop_searching_any().(stop_searching_common.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().()); |
| 459 | } |
| 460 | } |
| 461 | } |
| 462 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().new_common_unique.is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().() { |
| 463 | let mut expanded = new_common_unique.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][Clone]clone().(); |
| 464 | for s in unique_searchers.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() { |
| 465 | expanded |
| 466 | .extendrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][`Extend<T>`]extend().(s.find_seen_ancestorsrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]find_seen_ancestors().(expanded.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().(), &self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.)); |
| 467 | } |
| 468 | for s in searchers.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() { |
| 469 | expanded |
| 470 | .extendrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][`Extend<T>`]extend().(s.find_seen_ancestorsrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]find_seen_ancestors().(expanded.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().(), &self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.)); |
| 471 | } |
| 472 | for s in unique_searchers.iter_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter_mut().() { |
| 473 | s.start_searchingrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]start_searching().(expanded.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().(), &self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.); |
| 474 | } |
| 475 | for s in searchers.iter_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter_mut().() { |
| 476 | s.stop_searching_anyrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]stop_searching_any().(expanded.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().()); |
| 477 | } |
| 478 | ancestor_all_unique.extendrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][`Extend<T>`]extend().(expanded); |
| 479 | |
| 480 | // Collapse unique searchers that ended up with the same frontier. |
| 481 | let mut seen_frontiers: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K>> = |
| 482 | stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T>`]new().(); |
| 483 | let mut next_unique: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>> = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 484 | for searcher in unique_searchers { |
| 485 | let mut key: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K> = searcher.next_queryrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]next_query().().iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 486 | key.sort_by_keyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]sort_by_key().(|k| { |
| 487 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::hash_maprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash_map/::DefaultHasherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/random/DefaultHasher#; |
| 488 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::hashrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/::Hasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hasher#; |
| 489 | let mut h = DefaultHasherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/random/DefaultHasher#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/random/impl#[DefaultHasher]new().(); |
| 490 | k.hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#hash().(&mut h); |
| 491 | h.finishrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/random/impl#[DefaultHasher][Hasher]finish().() |
| 492 | }); |
| 493 | if seen_frontiers.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(key) { |
| 494 | next_unique.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(searcher); |
| 495 | } |
| 496 | } |
| 497 | unique_searchers = next_unique; |
| 498 | } |
| 499 | |
| 500 | let any_common_active = searchers.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|s| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().s.next_queryrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]next_query().().is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().()); |
| 501 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().any_common_active { |
| 502 | return; |
| 503 | } |
| 504 | } |
| 505 | } |
| 506 | |
| 507 | /// Find a unique lowest common ancestor by iterating `find_lca`. |
| 508 | /// |
| 509 | /// If there are multiple LCAs, recursively find the LCA of that set |
| 510 | /// until exactly one remains. Returns `None` if there is no common |
| 511 | /// ancestor. If `count_steps` is true, also returns the number of |
| 512 | /// iterations. |
| 513 | pub fn find_unique_lcarust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_lca().(&self, left: K, right: K, null: &K) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(K, usize)> { |
| 514 | let mut revisions: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![left, right]; |
| 515 | let mut steps: usize = 0; |
| 516 | loop { |
| 517 | steps rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1; |
| 518 | let lca = self.find_lcarust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_lca().(revisions.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().(), null); |
| 519 | match lca.lenrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]len().() { |
| 520 | 1 => return lca.into_iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][IntoIterator]into_iter().().nextrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`IntoIter<K, A>`][Iterator]next().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|k| (k, steps)), |
| 521 | 0 => return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 522 | _ => revisions = lca.into_iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(), |
| 523 | } |
| 524 | } |
| 525 | } |
| 526 | |
| 527 | /// Find the unique ancestors of `unique_revision` relative to |
| 528 | /// `common_revisions`. |
| 529 | /// |
| 530 | /// Returns the set of revisions that are ancestors of `unique_revision` |
| 531 | /// but not of any of `common_revisions`. If `unique_revision` is itself |
| 532 | /// in `common_revisions`, returns an empty set. |
| 533 | /// |
| 534 | /// Algorithm description: |
| 535 | /// |
| 536 | /// 1. Walk backwards from the unique node and all common nodes. |
| 537 | /// 2. When a node is seen by both sides, stop searching it in the unique |
| 538 | /// walker, include it in the common walker. |
| 539 | /// 3. Stop searching when there are no nodes left for the unique walker. |
| 540 | /// At this point, you have a maximal set of unique nodes. Some of |
| 541 | /// them may actually be common, and you haven't reached them yet. |
| 542 | /// 4. Start new searchers for the unique nodes, seeded with the |
| 543 | /// information you have so far. |
| 544 | /// 5. Continue searching, stopping the common searches when the search |
| 545 | /// tip is an ancestor of all unique nodes. |
| 546 | /// 6. Aggregate together unique searchers when they are searching the |
| 547 | /// same tips. When all unique searchers are searching the same node, |
| 548 | /// stop move it to a single 'all_unique_searcher'. |
| 549 | /// 7. The 'all_unique_searcher' represents the very 'tip' of searching. |
| 550 | /// Most of the time this produces very little important information. |
| 551 | /// So don't step it as quickly as the other searchers. |
| 552 | /// 8. Search is done when all common searchers have completed. |
| 553 | pub fn find_unique_ancestorsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_ancestors().( |
| 554 | &self, |
| 555 | unique_revision: K, |
| 556 | common_revisions: impl IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = K>, |
| 557 | ) -> FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> |
| 558 | where |
| 559 | K: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#, |
| 560 | { |
| 561 | let common_revisions: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K> = common_revisions.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 562 | if common_revisions.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&unique_revision) { |
| 563 | return FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().(); |
| 564 | } |
| 565 | |
| 566 | // Phase 1: find maximal unique set. |
| 567 | let (mut unique_searcher, mut common_searcher) = |
| 568 | self.find_initial_unique_nodesrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_initial_unique_nodes().([unique_revision], common_revisions); |
| 569 | let unique_nodes: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = unique_searcher |
| 570 | .seenrust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#seen. |
| 571 | .differencerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]difference().(&common_searcher.seenrust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#seen.) |
| 572 | .clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().() |
| 573 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 574 | if unique_nodes.is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().() { |
| 575 | return unique_nodes; |
| 576 | } |
| 577 | |
| 578 | // Phase 2: refine via unique-tip searchers. |
| 579 | let (mut all_unique_searcher, mut unique_tip_searchers) = |
| 580 | self.make_unique_searchersrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]make_unique_searchers().(&unique_nodes, &mut unique_searcher, &mut common_searcher); |
| 581 | self.refine_unique_nodesrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]refine_unique_nodes().( |
| 582 | &mut unique_searcher, |
| 583 | &mut all_unique_searcher, |
| 584 | &mut unique_tip_searchers, |
| 585 | &mut common_searcher, |
| 586 | ); |
| 587 | unique_nodes |
| 588 | .differencerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]difference().(&common_searcher.seenrust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#seen.) |
| 589 | .clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().() |
| 590 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().() |
| 591 | } |
| 592 | |
| 593 | /// Phase 1 of find_unique_ancestors: find the maximal unique set. |
| 594 | fn find_initial_unique_nodesrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_initial_unique_nodes().( |
| 595 | &self, |
| 596 | unique_revisions: impl IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = K>, |
| 597 | common_revisions: impl IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = K>, |
| 598 | ) -> (BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>, BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>) { |
| 599 | let mut unique_searcher = BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#::newrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]new().(unique_revisions); |
| 600 | // Skip past the starting unique revisions themselves. |
| 601 | unique_searcher.next_setrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]next_set().(&self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.); |
| 602 | let mut common_searcher = BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#::newrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]new().(common_revisions); |
| 603 | |
| 604 | while !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().unique_searcher.next_queryrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]next_query().().is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().() { |
| 605 | let next_unique_nodes: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = |
| 606 | unique_searcher.next_setrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]next_set().(&self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.).unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().(); |
| 607 | let next_common_nodes: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = |
| 608 | common_searcher.next_setrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]next_set().(&self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.).unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().(); |
| 609 | |
| 610 | let mut unique_are_common_nodes: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = next_unique_nodes |
| 611 | .intersectionrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]intersection().(&common_searcher.seenrust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#seen.) |
| 612 | .clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().() |
| 613 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 614 | unique_are_common_nodes.extendrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][`Extend<T>`]extend().( |
| 615 | next_common_nodes |
| 616 | .intersectionrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]intersection().(&unique_searcher.seenrust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#seen.) |
| 617 | .clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().(), |
| 618 | ); |
| 619 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().unique_are_common_nodes.is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().() { |
| 620 | let mut ancestors = |
| 621 | unique_searcher.find_seen_ancestorsrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]find_seen_ancestors().(unique_are_common_nodes, &self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.); |
| 622 | let more = common_searcher.find_seen_ancestorsrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]find_seen_ancestors().(ancestors.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][Clone]clone().(), &self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.); |
| 623 | ancestors.extendrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][`Extend<T>`]extend().(more); |
| 624 | unique_searcher.stop_searching_anyrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]stop_searching_any().(ancestors.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().()); |
| 625 | common_searcher.start_searchingrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]start_searching().(ancestors, &self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.); |
| 626 | } |
| 627 | } |
| 628 | (unique_searcher, common_searcher) |
| 629 | } |
| 630 | |
| 631 | /// Phase 2 setup: create a searcher for each unique-node tip plus an |
| 632 | /// `all_unique_searcher` covering ancestry shared by every unique tip. |
| 633 | fn make_unique_searchersrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]make_unique_searchers().( |
| 634 | &self, |
| 635 | unique_nodes: &FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K>, |
| 636 | unique_searcher: &mut BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>, |
| 637 | common_searcher: &mut BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>, |
| 638 | ) -> (BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>>) |
| 639 | where |
| 640 | K: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#, |
| 641 | { |
| 642 | let parent_map = self.get_parent_maprust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]get_parent_map().(unique_nodes.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().()); |
| 643 | let unique_tips = Selfrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]::remove_simple_descendantsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]remove_simple_descendants().(unique_nodes, &parent_map); |
| 644 | |
| 645 | let mut unique_tip_searchers: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>> = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 646 | let ancestor_all_unique: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = if unique_tips.lenrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().1 { |
| 647 | unique_searcher.find_seen_ancestorsrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]find_seen_ancestors().(unique_tips, &self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.) |
| 648 | } else { |
| 649 | for tip in unique_tips { |
| 650 | let mut revs_to_search = |
| 651 | unique_searcher.find_seen_ancestorsrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]find_seen_ancestors().([tip.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()], &self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.); |
| 652 | let more = |
| 653 | common_searcher.find_seen_ancestorsrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]find_seen_ancestors().(revs_to_search.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][Clone]clone().(), &self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.); |
| 654 | revs_to_search.extendrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][`Extend<T>`]extend().(more); |
| 655 | let mut searcher = BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#::newrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]new().(revs_to_search); |
| 656 | // Skip past the starting nodes — we don't care about them. |
| 657 | searcher.next_setrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]next_set().(&self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.); |
| 658 | unique_tip_searchers.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(searcher); |
| 659 | } |
| 660 | // Fold the intersection from the borrowed `seen` sets so we |
| 661 | // don't have to snapshot each searcher's seen set as we go. |
| 662 | unique_tip_searchers |
| 663 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 664 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|s| &s.seenrust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#seen.) |
| 665 | .foldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]fold().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#::<FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K>>, |acc, s| match acc { |
| 666 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(s.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][Clone]clone().()), |
| 667 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(a) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(a.intersectionrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]intersection().(s).clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()), |
| 668 | }) |
| 669 | .unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().() |
| 670 | }; |
| 671 | |
| 672 | // Collapse all common nodes into a single searcher covering the |
| 673 | // `ancestor_all_unique` set, then advance it once. |
| 674 | let mut all_unique_searcher = BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#::newrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]new().(ancestor_all_unique.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().()); |
| 675 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().ancestor_all_unique.is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().() { |
| 676 | all_unique_searcher.next_setrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]next_set().(&self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.); |
| 677 | |
| 678 | // Stop common-searcher tips that are already ancestors of all uniques. |
| 679 | let to_stop = common_searcher |
| 680 | .find_seen_ancestorsrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]find_seen_ancestors().(ancestor_all_unique.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().(), &self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.); |
| 681 | common_searcher.stop_searching_anyrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]stop_searching_any().(to_stop); |
| 682 | |
| 683 | for searcher in unique_tip_searchers.iter_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter_mut().() { |
| 684 | let to_stop = searcher |
| 685 | .find_seen_ancestorsrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]find_seen_ancestors().(ancestor_all_unique.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().(), &self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.); |
| 686 | searcher.stop_searching_anyrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]stop_searching_any().(to_stop); |
| 687 | } |
| 688 | } |
| 689 | |
| 690 | (all_unique_searcher, unique_tip_searchers) |
| 691 | } |
| 692 | |
| 693 | /// Remove revisions which are descendants (via the parent_map) of other |
| 694 | /// revisions in the set. This is a cheap O(E) pass that doesn't walk |
| 695 | /// ancestry — it just drops keys whose parents are already in `revisions`. |
| 696 | fn remove_simple_descendantsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]remove_simple_descendants().( |
| 697 | revisions: &FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K>, |
| 698 | parent_map: &ParentMaprust-analyzer cargo vcs-graph 3.6.0 ParentMap#<K>, |
| 699 | ) -> FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> { |
| 700 | let mut simple = revisions.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][Clone]clone().(); |
| 701 | for (revision, parents) in parent_map.iterrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]iter().() { |
| 702 | if let Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Knownrust-analyzer cargo vcs-graph 3.6.0 Parents#Known#(ps) = parents { |
| 703 | for parent_id in ps { |
| 704 | if revisions.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(parent_id) { |
| 705 | simple.removerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]remove().(revision); |
| 706 | break; |
| 707 | } |
| 708 | } |
| 709 | } |
| 710 | } |
| 711 | simple |
| 712 | } |
| 713 | |
| 714 | /// One BFS step across unique tip searchers, the unique_searcher, and |
| 715 | /// the common_searcher, propagating find_seen_ancestors cross-checks. |
| 716 | fn step_unique_and_common_searchersrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]step_unique_and_common_searchers().( |
| 717 | &self, |
| 718 | common_searcher: &mut BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>, |
| 719 | unique_tip_searchers: &mut [BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>], |
| 720 | unique_searcher: &BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>, |
| 721 | ) -> (FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K>, FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K>) { |
| 722 | let newly_seen_common: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = |
| 723 | common_searcher.next_setrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]next_set().(&self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.).unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().(); |
| 724 | |
| 725 | let mut newly_seen_unique: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().(); |
| 726 | // Snapshot seen sets of all tip searchers so we can cross-reference |
| 727 | // without re-borrowing mid-loop. |
| 728 | let tip_count = unique_tip_searchers.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(); |
| 729 | // Collect (index, next_step) pairs first. |
| 730 | let mut per_tip_next: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(usize, FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K>)> = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(tip_count); |
| 731 | for (i, s) in unique_tip_searchers.iter_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter_mut().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 732 | let mut next_set = s.next_setrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]next_set().(&self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.).unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().(); |
| 733 | // Include ancestors already known to the main unique_searcher. |
| 734 | next_set.extendrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][`Extend<T>`]extend().(unique_searcher.find_seen_ancestorsrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]find_seen_ancestors().(next_set.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][Clone]clone().(), &self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.)); |
| 735 | // And to the common_searcher. |
| 736 | next_set.extendrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][`Extend<T>`]extend().(common_searcher.find_seen_ancestorsrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]find_seen_ancestors().(next_set.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][Clone]clone().(), &self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.)); |
| 737 | per_tip_next.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((i, next_set)); |
| 738 | } |
| 739 | // Cross-check: each tip pulls in seen ancestors from every other tip. |
| 740 | // We need to compute additions per tip from the current (pre-start) |
| 741 | // state of the other tips, so snapshot their seen sets first. |
| 742 | let seen_per_tip: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K>> = unique_tip_searchers |
| 743 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 744 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|s| s.seenrust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#seen..clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][Clone]clone().()) |
| 745 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 746 | for (i, next_set) in per_tip_next.iter_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter_mut().() { |
| 747 | for (j, seen_j) in seen_per_tip.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 748 | if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().j { |
| 749 | continue; |
| 750 | } |
| 751 | // We can't call `alt_searcher.find_seen_ancestors` here |
| 752 | // because that would re-borrow the slice we're already |
| 753 | // iterating. Use the free-standing equivalent that takes |
| 754 | // the other searcher's seen set by reference. |
| 755 | let additions = |
| 756 | Selfrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]::find_seen_ancestors_againstrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_seen_ancestors_against().(next_set.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][Clone]clone().(), seen_j, &self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.); |
| 757 | next_set.extendrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][`Extend<T>`]extend().(additions); |
| 758 | } |
| 759 | } |
| 760 | // Apply start_searching and accumulate newly_seen_unique. |
| 761 | for (i, next_set) in per_tip_next { |
| 762 | unique_tip_searchers[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut()..start_searchingrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]start_searching().(next_set.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().(), &self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.); |
| 763 | newly_seen_unique.extendrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][`Extend<T>`]extend().(next_set); |
| 764 | } |
| 765 | (newly_seen_common, newly_seen_unique) |
| 766 | } |
| 767 | |
| 768 | /// Free-standing equivalent of `BfsState::find_seen_ancestors` that |
| 769 | /// walks the provider restricted to a given `seen` set. Used by |
| 770 | /// `step_unique_and_common_searchers` to cross-check tip searchers |
| 771 | /// without mid-loop re-borrows of the slice. |
| 772 | fn find_seen_ancestors_againstrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_seen_ancestors_against().( |
| 773 | revisions: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K>, |
| 774 | seen: &FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K>, |
| 775 | provider: &P, |
| 776 | ) -> FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> { |
| 777 | let mut pending: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = |
| 778 | revisions.into_iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][IntoIterator]into_iter().().filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|r| seen.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(r)).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 779 | let mut seen_ancestors: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = pending.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 780 | while !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().pending.is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().() { |
| 781 | let mut std_set: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#<K> = |
| 782 | stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#::with_capacityrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T>`]with_capacity().(pending.lenrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]len().()); |
| 783 | for k in &pending { |
| 784 | std_set.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(k.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 785 | } |
| 786 | let parent_map = provider.get_parent_maprust-analyzer cargo vcs-graph 3.6.0 parents_provider/ParentsProvider#get_parent_map().(&std_set); |
| 787 | let mut all_parents: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K> = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 788 | for (_, parents) in parent_map.iterrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]iter().() { |
| 789 | if let Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Knownrust-analyzer cargo vcs-graph 3.6.0 Parents#Known#(ps) = parents { |
| 790 | all_parents.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(ps.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().()); |
| 791 | } |
| 792 | } |
| 793 | let mut next_pending: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().(); |
| 794 | for p in all_parents { |
| 795 | if seen.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&p) && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().seen_ancestors.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&p) { |
| 796 | next_pending.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(p); |
| 797 | } |
| 798 | } |
| 799 | seen_ancestors.extendrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][`Extend<T>`]extend().(next_pending.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().()); |
| 800 | pending = next_pending; |
| 801 | } |
| 802 | seen_ancestors |
| 803 | } |
| 804 | |
| 805 | /// Find nodes common to all unique tip searchers (and optionally step |
| 806 | /// the `all_unique_searcher`). |
| 807 | fn find_nodes_common_to_all_uniquerust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_nodes_common_to_all_unique().( |
| 808 | &self, |
| 809 | unique_tip_searchers: &[BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>], |
| 810 | all_unique_searcher: &mut BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>, |
| 811 | newly_seen_unique: &FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K>, |
| 812 | step_all_unique: bool, |
| 813 | ) -> FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> { |
| 814 | let mut common: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = newly_seen_unique.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][Clone]clone().(); |
| 815 | for searcher in unique_tip_searchers { |
| 816 | common = common.intersectionrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]intersection().(&searcher.seenrust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#seen.).clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 817 | } |
| 818 | common = common |
| 819 | .intersectionrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]intersection().(&all_unique_searcher.seenrust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#seen.) |
| 820 | .clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().() |
| 821 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 822 | if step_all_unique { |
| 823 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(nodes) = all_unique_searcher.next_setrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]next_set().(&self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.) { |
| 824 | common.extendrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][`Extend<T>`]extend().(nodes); |
| 825 | } |
| 826 | } |
| 827 | common |
| 828 | } |
| 829 | |
| 830 | /// Combine unique tip searchers that are searching the same frontier. |
| 831 | fn collapse_unique_searchersrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]collapse_unique_searchers().( |
| 832 | &self, |
| 833 | unique_tip_searchers: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>>, |
| 834 | common_to_all_unique_nodes: &FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K>, |
| 835 | ) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>> { |
| 836 | // First pass: stop searching the common-to-all set on each searcher |
| 837 | // and bucket by resulting frontier. |
| 838 | let mut buckets: FxHashMaprust-analyzer cargo rustc-hash 2.1.2 FxHashMap#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K>, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>>> = FxHashMaprust-analyzer cargo rustc-hash 2.1.2 FxHashMap#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S>`][Default]default().(); |
| 839 | let mut empty_bucket: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>> = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 840 | for mut searcher in unique_tip_searchers { |
| 841 | searcher.stop_searching_anyrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]stop_searching_any().(common_to_all_unique_nodes.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().()); |
| 842 | let nq = searcher.next_queryrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]next_query().().clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][Clone]clone().(); |
| 843 | if nq.is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().() { |
| 844 | empty_bucket.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(searcher); |
| 845 | continue; |
| 846 | } |
| 847 | // Sort the frontier by hash for a deterministic bucket key. |
| 848 | let mut key: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K> = nq.into_iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 849 | key.sort_by_keyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]sort_by_key().(|k| { |
| 850 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::hash_maprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash_map/::DefaultHasherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/random/DefaultHasher#; |
| 851 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::hashrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/::Hasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hasher#; |
| 852 | let mut h = DefaultHasherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/random/DefaultHasher#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/random/impl#[DefaultHasher]new().(); |
| 853 | k.hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#hash().(&mut h); |
| 854 | h.finishrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/random/impl#[DefaultHasher][Hasher]finish().() |
| 855 | }); |
| 856 | buckets.entryrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]entry().(key).or_defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`Entry<'a, K, V>`]or_default().().pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(searcher); |
| 857 | } |
| 858 | let _ = empty_bucket; // drop empties — those searchers are done. |
| 859 | |
| 860 | let mut next_unique_searchers: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>> = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 861 | for (_key, mut searchers) in buckets { |
| 862 | if searchers.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().1 { |
| 863 | next_unique_searchers.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(searchers.poprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]pop().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()); |
| 864 | } else { |
| 865 | // Combine: intersect all their seen sets into the first. |
| 866 | let mut first = searchers.removerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]remove().(0); |
| 867 | for s in searchers { |
| 868 | first.seenrust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#seen. = first.seenrust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#seen..intersectionrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]intersection().(&s.seenrust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#seen.).clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 869 | } |
| 870 | next_unique_searchers.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(first); |
| 871 | } |
| 872 | } |
| 873 | next_unique_searchers |
| 874 | } |
| 875 | |
| 876 | /// Phase 2 main loop: refine unique-vs-common by stepping searchers |
| 877 | /// until `common_searcher` has nothing left to search. |
| 878 | fn refine_unique_nodesrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]refine_unique_nodes().( |
| 879 | &self, |
| 880 | unique_searcher: &mut BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>, |
| 881 | all_unique_searcher: &mut BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>, |
| 882 | unique_tip_searchers: &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>>, |
| 883 | common_searcher: &mut BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>, |
| 884 | ) { |
| 885 | // Step the all_unique_searcher every N steps (Python's |
| 886 | // STEP_UNIQUE_SEARCHER_EVERY = 5). |
| 887 | const STEP_ALL_UNIQUE_EVERYrust-analyzer cargo vcs-graph 3.6.0 graph/STEP_ALL_UNIQUE_EVERY.: usize = 5; |
| 888 | let mut step_all_unique_counter: usize = 0; |
| 889 | |
| 890 | while !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().common_searcher.next_queryrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]next_query().().is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().() { |
| 891 | let (newly_seen_common, newly_seen_unique) = self.step_unique_and_common_searchersrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]step_unique_and_common_searchers().( |
| 892 | common_searcher, |
| 893 | unique_tip_searchers, |
| 894 | unique_searcher, |
| 895 | ); |
| 896 | let common_to_all_unique_nodes = self.find_nodes_common_to_all_uniquerust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_nodes_common_to_all_unique().( |
| 897 | unique_tip_searchers, |
| 898 | all_unique_searcher, |
| 899 | &newly_seen_unique, |
| 900 | step_all_unique_counter rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0, |
| 901 | ); |
| 902 | step_all_unique_counter = (step_all_unique_counter rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().STEP_ALL_UNIQUE_EVERYrust-analyzer cargo vcs-graph 3.6.0 graph/STEP_ALL_UNIQUE_EVERY.; |
| 903 | |
| 904 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().newly_seen_common.is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().() { |
| 905 | let stop: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = all_unique_searcher |
| 906 | .seenrust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#seen. |
| 907 | .intersectionrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]intersection().(&newly_seen_common) |
| 908 | .clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().() |
| 909 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 910 | common_searcher.stop_searching_anyrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]stop_searching_any().(stop); |
| 911 | } |
| 912 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().common_to_all_unique_nodes.is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().() { |
| 913 | let mut expanded = common_to_all_unique_nodes.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][Clone]clone().(); |
| 914 | expanded.extendrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][`Extend<T>`]extend().(common_searcher.find_seen_ancestorsrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]find_seen_ancestors().( |
| 915 | common_to_all_unique_nodes.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().(), |
| 916 | &self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider., |
| 917 | )); |
| 918 | all_unique_searcher.start_searchingrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]start_searching().(expanded.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().(), &self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.); |
| 919 | common_searcher.stop_searching_anyrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]stop_searching_any().(expanded); |
| 920 | } |
| 921 | let old_searchers = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/take().(unique_tip_searchers); |
| 922 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().unique_tip_searchers = |
| 923 | self.collapse_unique_searchersrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]collapse_unique_searchers().(old_searchers, &common_to_all_unique_nodes); |
| 924 | } |
| 925 | } |
| 926 | |
| 927 | /// Find ancestors of `new_key` that may be descendants of `old_key`. |
| 928 | /// |
| 929 | /// Drives two parallel searchers: `stop` walks up from `old_key` and |
| 930 | /// `descendants` walks up from `new_key`. For each iteration, prune |
| 931 | /// nodes already seen by `stop` from `descendants`, then advance `stop` |
| 932 | /// and prune any nodes in the newly-visited stop set that `descendants` |
| 933 | /// has already reached (via `find_seen_ancestors`). |
| 934 | /// |
| 935 | /// Returns the set of keys reached by `descendants` but not by `stop`. |
| 936 | pub fn find_descendant_ancestorsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_descendant_ancestors().(&self, old_key: K, new_key: K) -> FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> { |
| 937 | let mut stop = BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#::newrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]new().([old_key]); |
| 938 | let mut descendants = BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#::newrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]new().([new_key]); |
| 939 | // Python's `for revisions in descendants:` iterates `next()` until |
| 940 | // StopIteration. Our next_set returns None to signal the end. |
| 941 | while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(revisions) = descendants.next_setrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]next_set().(&self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.) { |
| 942 | let old_stop: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = stop.seenrust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#seen..intersectionrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]intersection().(&revisions).clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 943 | descendants.stop_searching_anyrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]stop_searching_any().(old_stop); |
| 944 | let step = stop.next_setrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]next_set().(&self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.).unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().(); |
| 945 | let seen_stop = descendants.find_seen_ancestorsrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]find_seen_ancestors().(step, &self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.); |
| 946 | descendants.stop_searching_anyrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]stop_searching_any().(seen_stop); |
| 947 | } |
| 948 | descendants.seenrust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#seen..differencerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]difference().(&stop.seenrust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#seen.).clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().() |
| 949 | } |
| 950 | |
| 951 | /// Find border ancestors of a set of revisions via a concurrent BFS. |
| 952 | /// |
| 953 | /// Returns `(border_ancestors, common_ancestors, searchers)`. The |
| 954 | /// searchers are left in the state they finished in so callers can |
| 955 | /// inspect `seen` for graph-difference calculations. |
| 956 | pub fn find_border_ancestorsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_border_ancestors().( |
| 957 | &self, |
| 958 | revisions: impl IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = K>, |
| 959 | ) -> (FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K>, FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K>, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>>) { |
| 960 | let revisions: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K> = revisions.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 961 | let mut searchers: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>> = revisions |
| 962 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 963 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|r| BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#::newrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]new().([r.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()])) |
| 964 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 965 | let mut common_ancestors: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().(); |
| 966 | let mut border_ancestors: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().(); |
| 967 | |
| 968 | loop { |
| 969 | let mut newly_seen: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().(); |
| 970 | for searcher in searchers.iter_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter_mut().() { |
| 971 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(new_ancestors) = searcher.next_setrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]next_set().(&self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.) { |
| 972 | newly_seen.extendrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][`Extend<T>`]extend().(new_ancestors); |
| 973 | } |
| 974 | } |
| 975 | let mut new_common: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().(); |
| 976 | for revision in &newly_seen { |
| 977 | if common_ancestors.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(revision) { |
| 978 | new_common.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(revision.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 979 | continue; |
| 980 | } |
| 981 | if searchers.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]all().(|s| s.seenrust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#seen..containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(revision)) { |
| 982 | border_ancestors.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(revision.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 983 | new_common.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(revision.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 984 | } |
| 985 | } |
| 986 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().new_common.is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().() { |
| 987 | // Pull in ancestors that are already seen by each searcher. |
| 988 | // We can't borrow searchers twice in one pass, so snapshot |
| 989 | // each searcher's contribution and merge. |
| 990 | let mut expanded = new_common.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][Clone]clone().(); |
| 991 | for searcher in searchers.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() { |
| 992 | let seen_anc = searcher.find_seen_ancestorsrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]find_seen_ancestors().(new_common.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][Clone]clone().(), &self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.); |
| 993 | expanded.extendrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][`Extend<T>`]extend().(seen_anc); |
| 994 | } |
| 995 | let new_common = expanded; |
| 996 | for searcher in searchers.iter_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter_mut().() { |
| 997 | searcher.start_searchingrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]start_searching().(new_common.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().(), &self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.); |
| 998 | } |
| 999 | common_ancestors.extendrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][`Extend<T>`]extend().(new_common); |
| 1000 | } |
| 1001 | |
| 1002 | // Convergence check: if all searchers have the same next query, |
| 1003 | // we've merged into a single common line and can stop. |
| 1004 | let first_frontier: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = searchers |
| 1005 | .firstrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]first().() |
| 1006 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|s| s.next_queryrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]next_query().().clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][Clone]clone().()) |
| 1007 | .unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().(); |
| 1008 | let all_same = searchers.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]all().(|s| s.next_queryrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]next_query().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().&first_frontier); |
| 1009 | if all_same { |
| 1010 | let uncommon: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = first_frontier |
| 1011 | .differencerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]difference().(&common_ancestors) |
| 1012 | .clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().() |
| 1013 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 1014 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().uncommon.is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().() { |
| 1015 | // Shouldn't happen in well-formed graphs, but instead of |
| 1016 | // panicking we just continue — matches Python's |
| 1017 | // AssertionError shape without crashing. |
| 1018 | // (Callers of find_difference etc. will see this as an |
| 1019 | // empty difference; tests never exercise this path.) |
| 1020 | } |
| 1021 | break; |
| 1022 | } |
| 1023 | } |
| 1024 | |
| 1025 | (border_ancestors, common_ancestors, searchers) |
| 1026 | } |
| 1027 | |
| 1028 | /// Return the heads from amongst `keys`. |
| 1029 | /// |
| 1030 | /// This walks each candidate's ancestry and prunes any key reachable |
| 1031 | /// from another. The `null` parameter is the sentinel the caller uses |
| 1032 | /// for the origin (`b"null:"` in the Python layer); passing it lets the |
| 1033 | /// Rust core stay string-typed without baking bytes into the API. |
| 1034 | pub fn heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(&self, keys: impl IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = K>, null: &K) -> FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> { |
| 1035 | let mut candidate_heads: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = keys.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 1036 | if candidate_heads.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(null) { |
| 1037 | candidate_heads.removerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]remove().(null); |
| 1038 | if candidate_heads.is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().() { |
| 1039 | let mut r = FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().(); |
| 1040 | r.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(null.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 1041 | return r; |
| 1042 | } |
| 1043 | } |
| 1044 | if candidate_heads.lenrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().2 { |
| 1045 | return candidate_heads; |
| 1046 | } |
| 1047 | // One searcher per candidate, keyed by the candidate revision. |
| 1048 | let mut searchers: FxHashMaprust-analyzer cargo rustc-hash 2.1.2 FxHashMap#<K, BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K>> = candidate_heads |
| 1049 | .iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().() |
| 1050 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|c| (c.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#::newrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]new().([c.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()]))) |
| 1051 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 1052 | let mut active: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = candidate_heads.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 1053 | // Skip the first yield (the candidate itself). |
| 1054 | for (_, searcher) in searchers.iter_mutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]iter_mut().() { |
| 1055 | searcher.next_setrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]next_set().(&self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.); |
| 1056 | } |
| 1057 | // Common walker: tracks nodes known to be common across all |
| 1058 | // searchers, so that a searcher hitting one can stop early. |
| 1059 | let mut common_walker: BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#<K> = BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#::newrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]new().([] as [K; 0]); |
| 1060 | while !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().active.is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().() { |
| 1061 | let mut ancestors: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().(); |
| 1062 | // Advance the common walker one step if there's anything to advance. |
| 1063 | common_walker.next_setrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]next_set().(&self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.); |
| 1064 | // Advance each active searcher one step. |
| 1065 | let active_list: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K> = active.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 1066 | for candidate in active_list { |
| 1067 | let finished = { |
| 1068 | let searcher = searchers.get_mutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get_mut().(&candidate).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 1069 | match searcher.next_setrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]next_set().(&self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.) { |
| 1070 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(set) => { |
| 1071 | ancestors.extendrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][`Extend<T>`]extend().(set); |
| 1072 | false |
| 1073 | } |
| 1074 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => true, |
| 1075 | } |
| 1076 | }; |
| 1077 | if finished { |
| 1078 | active.removerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]remove().(&candidate); |
| 1079 | } |
| 1080 | } |
| 1081 | // Process found ancestors. |
| 1082 | let mut new_common: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().(); |
| 1083 | for ancestor in ancestors { |
| 1084 | if candidate_heads.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&ancestor) { |
| 1085 | candidate_heads.removerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]remove().(&ancestor); |
| 1086 | searchers.removerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]remove().(&ancestor); |
| 1087 | active.removerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]remove().(&ancestor); |
| 1088 | } |
| 1089 | if common_walker.seenrust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#seen..containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&ancestor) { |
| 1090 | // Known common: tell every searcher to stop on it. |
| 1091 | let stop_set: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = [ancestor].into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/iter/impl#[`[T; N]`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 1092 | for searcher in searchers.values_mutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]values_mut().() { |
| 1093 | searcher.stop_searching_anyrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]stop_searching_any().(stop_set.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().()); |
| 1094 | } |
| 1095 | } else if searchers.valuesrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]values().().allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#all().(|s| s.seenrust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#seen..containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&ancestor)) { |
| 1096 | // All searchers have reached this node — it's newly |
| 1097 | // common. Stop any of its seen ancestors in each searcher. |
| 1098 | new_common.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(ancestor.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 1099 | // Collect seen ancestors per searcher, then apply stops. |
| 1100 | let seen_per_searcher: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K>> = searchers |
| 1101 | .valuesrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]values().() |
| 1102 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|s| s.find_seen_ancestorsrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]find_seen_ancestors().([ancestor.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()], &self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.)) |
| 1103 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 1104 | for (searcher, seen_anc) in searchers.values_mutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]values_mut().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(seen_per_searcher) { |
| 1105 | searcher.stop_searching_anyrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]stop_searching_any().(seen_anc); |
| 1106 | } |
| 1107 | } |
| 1108 | } |
| 1109 | common_walker.start_searchingrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]start_searching().(new_common, &self.providerrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#provider.); |
| 1110 | } |
| 1111 | candidate_heads |
| 1112 | } |
| 1113 | |
| 1114 | /// Find the lowest common ancestors of `revisions`. |
| 1115 | pub fn find_lcarust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_lca().(&self, revisions: impl IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = K>, null: &K) -> FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> { |
| 1116 | let (border_common, _common, _searchers) = self.find_border_ancestorsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_border_ancestors().(revisions); |
| 1117 | self.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(border_common, null) |
| 1118 | } |
| 1119 | |
| 1120 | /// Return whether `candidate_ancestor` is an ancestor of `candidate_descendant`. |
| 1121 | pub fn is_ancestorrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]is_ancestor().(&self, candidate_ancestor: K, candidate_descendant: K, null: &K) -> bool { |
| 1122 | let heads = self.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().( |
| 1123 | [candidate_ancestor.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), candidate_descendant.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()], |
| 1124 | null, |
| 1125 | ); |
| 1126 | heads.lenrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().1 && heads.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&candidate_descendant) |
| 1127 | } |
| 1128 | |
| 1129 | /// Return whether `revid` is between `lower_bound_revid` and |
| 1130 | /// `upper_bound_revid` (inclusive). `None` bounds are skipped. |
| 1131 | pub fn is_betweenrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]is_between().( |
| 1132 | &self, |
| 1133 | revid: K, |
| 1134 | lower_bound_revid: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<K>, |
| 1135 | upper_bound_revid: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<K>, |
| 1136 | null: &K, |
| 1137 | ) -> bool { |
| 1138 | let upper_ok = match upper_bound_revid { |
| 1139 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => true, |
| 1140 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(upper) => self.is_ancestorrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]is_ancestor().(revid.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), upper, null), |
| 1141 | }; |
| 1142 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().upper_ok { |
| 1143 | return false; |
| 1144 | } |
| 1145 | match lower_bound_revid { |
| 1146 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => true, |
| 1147 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(lower) => self.is_ancestorrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]is_ancestor().(lower, revid, null), |
| 1148 | } |
| 1149 | } |
| 1150 | |
| 1151 | /// Find the order in which `lca_revision_ids` were merged into `tip`. |
| 1152 | /// |
| 1153 | /// Walks backwards from `tip` with a stack, left-first, collecting the |
| 1154 | /// LCA revisions in the order they are encountered. |
| 1155 | pub fn find_merge_orderrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_merge_order().( |
| 1156 | &self, |
| 1157 | tip: K, |
| 1158 | lca_revision_ids: impl IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = K>, |
| 1159 | ) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K> { |
| 1160 | let mut looking_for: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = lca_revision_ids.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 1161 | if looking_for.lenrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().1 { |
| 1162 | return looking_for.into_iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 1163 | } |
| 1164 | let mut stack: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![tip]; |
| 1165 | let mut found: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K> = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 1166 | let mut stop: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> = FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().(); |
| 1167 | while !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().stack.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().looking_for.is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().() { |
| 1168 | let next_key = stack.poprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]pop().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 1169 | stop.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(next_key.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 1170 | if looking_for.removerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]remove().(&next_key) { |
| 1171 | found.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(next_key); |
| 1172 | if looking_for.lenrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().1 { |
| 1173 | // Only one LCA left — add it and break without walking. |
| 1174 | let last = looking_for.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().().nextrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`Iter<'a, K>`][Iterator]next().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<&T>`]cloned().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 1175 | looking_for.clearrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]clear().(); |
| 1176 | found.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(last); |
| 1177 | break; |
| 1178 | } |
| 1179 | continue; |
| 1180 | } |
| 1181 | let pm = self.get_parent_maprust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]get_parent_map().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/once/once().(next_key.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().())); |
| 1182 | let parents = match pm.getrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]get().(&next_key) { |
| 1183 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Knownrust-analyzer cargo vcs-graph 3.6.0 Parents#Known#(ps)) if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().ps.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() => ps.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().(), |
| 1184 | _ => continue, |
| 1185 | }; |
| 1186 | // Walk parents in reverse so the left-most parent is popped first. |
| 1187 | for parent_id in parents.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().() { |
| 1188 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().stop.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&parent_id) { |
| 1189 | stack.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(parent_id.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 1190 | } |
| 1191 | stop.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(parent_id); |
| 1192 | } |
| 1193 | } |
| 1194 | found |
| 1195 | } |
| 1196 | |
| 1197 | /// Find descendants of `old_key` that are ancestors of `new_key`. |
| 1198 | /// |
| 1199 | /// Uses [`find_descendant_ancestors`](Self::find_descendant_ancestors) |
| 1200 | /// to narrow down candidates, then walks forwards through the child |
| 1201 | /// relationships by running a BFS over a [`DictParentsProvider`] built |
| 1202 | /// from the inverted parent map. |
| 1203 | pub fn find_descendantsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_descendants().(&self, old_key: K, new_key: K) -> FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<K> |
| 1204 | where |
| 1205 | K: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#, |
| 1206 | { |
| 1207 | let candidates = self.find_descendant_ancestorsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_descendant_ancestors().(old_key.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(), new_key); |
| 1208 | let child_map = self.get_child_maprust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]get_child_map().(candidates); |
| 1209 | // Walk forwards via a DictParentsProvider built from the child map. |
| 1210 | let dict: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<K, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<K>> = child_map.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 1211 | let provider = DictParentsProviderrust-analyzer cargo vcs-graph 3.6.0 parents_provider/DictParentsProvider#::fromrust-analyzer cargo vcs-graph 3.6.0 parents_provider/impl#[`DictParentsProvider<K>`][`From<HashMap<K, Vec<K>>>`]from().(dict); |
| 1212 | let mut searcher = BfsStaterust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#::newrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]new().([old_key]); |
| 1213 | while searcher.next_setrust-analyzer cargo vcs-graph 3.6.0 bfs/impl#[`BfsState<K>`]next_set().(&provider).is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() {} |
| 1214 | searcher.seenrust-analyzer cargo vcs-graph 3.6.0 bfs/BfsState#seen. |
| 1215 | } |
| 1216 | } |
| 1217 | |
| 1218 | #[cfg(test)] |
| 1219 | mod testsrust-analyzer cargo vcs-graph 3.6.0 graph/tests/ { |
| 1220 | use superrust-analyzer cargo vcs-graph 3.6.0 graph/::*; |
| 1221 | use craterust-analyzer cargo vcs-graph 3.6.0 crate/::DictParentsProviderrust-analyzer cargo vcs-graph 3.6.0 parents_provider/DictParentsProvider#; |
| 1222 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#; |
| 1223 | |
| 1224 | const NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.: &str = "null:"; |
| 1225 | |
| 1226 | fn makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().( |
| 1227 | edges: &[(&'static str, &[&'static str])], |
| 1228 | ) -> Graphrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#<&'static str, DictParentsProviderrust-analyzer cargo vcs-graph 3.6.0 parents_provider/DictParentsProvider#<&'static str>> { |
| 1229 | let map: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<&'static str, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&'static str>> = |
| 1230 | edges.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(k, ps)| (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().k, ps.to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().())).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 1231 | Graphrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#::newrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]new().(DictParentsProviderrust-analyzer cargo vcs-graph 3.6.0 parents_provider/DictParentsProvider#::fromrust-analyzer cargo vcs-graph 3.6.0 parents_provider/impl#[`DictParentsProvider<K>`][`From<HashMap<K, Vec<K>>>`]from().(map)) |
| 1232 | } |
| 1233 | |
| 1234 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1235 | fn get_parent_map_basicrust-analyzer cargo vcs-graph 3.6.0 graph/tests/get_parent_map_basic().() { |
| 1236 | let g = makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[("a", &[]), ("b", &["a"])]); |
| 1237 | let pm = g.get_parent_maprust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]get_parent_map().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["a", "b", "missing"]); |
| 1238 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(pm.getrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]get().(&"a"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Knownrust-analyzer cargo vcs-graph 3.6.0 Parents#Known#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]))); |
| 1239 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(pm.getrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]get().(&"b"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Knownrust-analyzer cargo vcs-graph 3.6.0 Parents#Known#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["a"]))); |
| 1240 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(pm.getrust-analyzer cargo vcs-graph 3.6.0 impl#[`ParentMap<K>`]get().(&"missing"), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 1241 | } |
| 1242 | |
| 1243 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1244 | fn get_child_map_invertsrust-analyzer cargo vcs-graph 3.6.0 graph/tests/get_child_map_inverts().() { |
| 1245 | let g = makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[("a", &[]), ("b", &["a"]), ("c", &["a"]), ("d", &["b", "c"])]); |
| 1246 | let cm = g.get_child_maprust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]get_child_map().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["a", "b", "c", "d"]); |
| 1247 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cm.getrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]get().(&"a"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["b", "c"])); |
| 1248 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cm.getrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]get().(&"b"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["d"])); |
| 1249 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cm.getrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]get().(&"c"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["d"])); |
| 1250 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cm.getrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]get().(&"d"), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 1251 | } |
| 1252 | |
| 1253 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1254 | fn iter_lefthand_ancestry_linearrust-analyzer cargo vcs-graph 3.6.0 graph/tests/iter_lefthand_ancestry_linear().() { |
| 1255 | // null <- a <- b <- c |
| 1256 | let g = makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[("a", &[NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.]), ("b", &["a"]), ("c", &["b"])]); |
| 1257 | let out = g.iter_lefthand_ancestryrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]iter_lefthand_ancestry().("c", [NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1258 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(out, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["c", "b", "a"]); |
| 1259 | } |
| 1260 | |
| 1261 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1262 | fn find_distance_to_null_linearrust-analyzer cargo vcs-graph 3.6.0 graph/tests/find_distance_to_null_linear().() { |
| 1263 | // null <- a (1) <- b (2) <- c (3) |
| 1264 | let g = makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[("a", &[NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.]), ("b", &["a"]), ("c", &["b"])]); |
| 1265 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1266 | g.find_distance_to_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_distance_to_null().("c", stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/empty/empty().(), NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.) |
| 1267 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 1268 | 3 |
| 1269 | ); |
| 1270 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1271 | g.find_distance_to_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_distance_to_null().("a", stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/empty/empty().(), NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.) |
| 1272 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 1273 | 1 |
| 1274 | ); |
| 1275 | } |
| 1276 | |
| 1277 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1278 | fn find_distance_to_null_with_known_seedrust-analyzer cargo vcs-graph 3.6.0 graph/tests/find_distance_to_null_with_known_seed().() { |
| 1279 | // null <- a (1) <- b (2) <- c (3) <- d (4) |
| 1280 | let g = makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[("a", &[NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.]), ("b", &["a"]), ("c", &["b"]), ("d", &["c"])]); |
| 1281 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1282 | g.find_distance_to_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_distance_to_null().("d", stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/once/once().(("b", 2)), NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.) |
| 1283 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 1284 | 4 |
| 1285 | ); |
| 1286 | } |
| 1287 | |
| 1288 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1289 | fn find_lefthand_distances_allrust-analyzer cargo vcs-graph 3.6.0 graph/tests/find_lefthand_distances_all().() { |
| 1290 | let g = makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[("a", &[NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.]), ("b", &["a"]), ("c", &["b"])]); |
| 1291 | let d = g.find_lefthand_distancesrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_lefthand_distances().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["a", "b", "c"], NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.); |
| 1292 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(&"a"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&1)); |
| 1293 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(&"b"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&2)); |
| 1294 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(&"c"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&3)); |
| 1295 | } |
| 1296 | |
| 1297 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1298 | fn iter_topo_order_parents_firstrust-analyzer cargo vcs-graph 3.6.0 graph/tests/iter_topo_order_parents_first().() { |
| 1299 | let g = makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[("a", &[]), ("b", &["a"]), ("c", &["a"]), ("d", &["b", "c"])]); |
| 1300 | let order = g.iter_topo_orderrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]iter_topo_order().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["a", "b", "c", "d"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1301 | let pos = |x: &&str| order.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().positionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]position().(|n| n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().x).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 1302 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(pos(&"a") <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). pos(&"b")); |
| 1303 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(pos(&"a") <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). pos(&"c")); |
| 1304 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(pos(&"b") <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). pos(&"d")); |
| 1305 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(pos(&"c") <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). pos(&"d")); |
| 1306 | } |
| 1307 | |
| 1308 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1309 | fn iter_ancestry_reaches_allrust-analyzer cargo vcs-graph 3.6.0 graph/tests/iter_ancestry_reaches_all().() { |
| 1310 | let g = makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[("a", &[]), ("b", &["a"]), ("c", &["a"]), ("d", &["b", "c"])]); |
| 1311 | let anc = g.iter_ancestryrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]iter_ancestry().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["d"]); |
| 1312 | let keys: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<&'static str> = anc.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(k, _)| *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().k).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 1313 | let expected: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<&'static str> = ["a", "b", "c", "d"].into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/iter/impl#[`[T; N]`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 1314 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(keys, expected); |
| 1315 | } |
| 1316 | |
| 1317 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1318 | fn find_descendants_diamondrust-analyzer cargo vcs-graph 3.6.0 graph/tests/find_descendants_diamond().() { |
| 1319 | // a |
| 1320 | // / \ |
| 1321 | // b c |
| 1322 | // \ / |
| 1323 | // d |
| 1324 | let g = makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[("a", &[]), ("b", &["a"]), ("c", &["a"]), ("d", &["b", "c"])]); |
| 1325 | let descendants = g.find_descendantsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_descendants().("a", "d"); |
| 1326 | let expected: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<&'static str> = ["a", "b", "c", "d"].into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/iter/impl#[`[T; N]`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 1327 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(descendants, expected); |
| 1328 | } |
| 1329 | |
| 1330 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1331 | fn find_descendants_linearrust-analyzer cargo vcs-graph 3.6.0 graph/tests/find_descendants_linear().() { |
| 1332 | // a <- b <- c <- d |
| 1333 | let g = makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[("a", &[]), ("b", &["a"]), ("c", &["b"]), ("d", &["c"])]); |
| 1334 | let descendants = g.find_descendantsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_descendants().("b", "d"); |
| 1335 | let expected: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<&'static str> = ["b", "c", "d"].into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/iter/impl#[`[T; N]`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 1336 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(descendants, expected); |
| 1337 | } |
| 1338 | |
| 1339 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1340 | fn heads_single_candidaterust-analyzer cargo vcs-graph 3.6.0 graph/tests/heads_single_candidate().() { |
| 1341 | let g = makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[("a", &[]), ("b", &["a"])]); |
| 1342 | let h = g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["b"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.); |
| 1343 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(h, ["b"].into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/iter/impl#[`[T; N]`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()); |
| 1344 | } |
| 1345 | |
| 1346 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1347 | fn heads_prunes_ancestorsrust-analyzer cargo vcs-graph 3.6.0 graph/tests/heads_prunes_ancestors().() { |
| 1348 | // a <- b <- c |
| 1349 | let g = makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[("a", &[]), ("b", &["a"]), ("c", &["b"])]); |
| 1350 | let h = g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["a", "c"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.); |
| 1351 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(h, ["c"].into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/iter/impl#[`[T; N]`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()); |
| 1352 | } |
| 1353 | |
| 1354 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1355 | fn heads_diamond_returns_bothrust-analyzer cargo vcs-graph 3.6.0 graph/tests/heads_diamond_returns_both().() { |
| 1356 | // a |
| 1357 | // / \ |
| 1358 | // b c |
| 1359 | // \ / |
| 1360 | // d |
| 1361 | let g = makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[("a", &[]), ("b", &["a"]), ("c", &["a"]), ("d", &["b", "c"])]); |
| 1362 | let h = g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["b", "c"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.); |
| 1363 | let expected: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<_> = ["b", "c"].into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/iter/impl#[`[T; N]`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 1364 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(h, expected); |
| 1365 | } |
| 1366 | |
| 1367 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1368 | fn heads_null_alonerust-analyzer cargo vcs-graph 3.6.0 graph/tests/heads_null_alone().() { |
| 1369 | let g = makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[("a", &[])]); |
| 1370 | let h = g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.); |
| 1371 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(h, [NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.].into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/iter/impl#[`[T; N]`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()); |
| 1372 | } |
| 1373 | |
| 1374 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1375 | fn find_lca_diamondrust-analyzer cargo vcs-graph 3.6.0 graph/tests/find_lca_diamond().() { |
| 1376 | // a |
| 1377 | // / \ |
| 1378 | // b c |
| 1379 | // \ / |
| 1380 | // d |
| 1381 | let g = makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[("a", &[]), ("b", &["a"]), ("c", &["a"]), ("d", &["b", "c"])]); |
| 1382 | let lca = g.find_lcarust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_lca().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["b", "c"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.); |
| 1383 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(lca, ["a"].into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/iter/impl#[`[T; N]`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()); |
| 1384 | } |
| 1385 | |
| 1386 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1387 | fn is_ancestor_true_and_falserust-analyzer cargo vcs-graph 3.6.0 graph/tests/is_ancestor_true_and_false().() { |
| 1388 | // a <- b <- c |
| 1389 | let g = makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[("a", &[]), ("b", &["a"]), ("c", &["b"])]); |
| 1390 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(g.is_ancestorrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]is_ancestor().("a", "c", &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.)); |
| 1391 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(g.is_ancestorrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]is_ancestor().("b", "c", &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.)); |
| 1392 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().g.is_ancestorrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]is_ancestor().("c", "a", &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.)); |
| 1393 | } |
| 1394 | |
| 1395 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1396 | fn find_merge_order_singlerust-analyzer cargo vcs-graph 3.6.0 graph/tests/find_merge_order_single().() { |
| 1397 | let g = makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[("a", &[]), ("b", &["a"])]); |
| 1398 | let order = g.find_merge_orderrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_merge_order().("b", vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["a"]); |
| 1399 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(order, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["a"]); |
| 1400 | } |
| 1401 | |
| 1402 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1403 | fn find_descendants_unrelatedrust-analyzer cargo vcs-graph 3.6.0 graph/tests/find_descendants_unrelated().() { |
| 1404 | // new_key is not a descendant of old_key. |
| 1405 | let g = makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[("a", &[]), ("b", &["a"]), ("c", &["a"])]); |
| 1406 | let descendants = g.find_descendantsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_descendants().("b", "c"); |
| 1407 | // b is not reachable from c, so no descendants of b among c's ancestry. |
| 1408 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(descendants.is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().() || descendants == ["b"].into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/iter/impl#[`[T; N]`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()); |
| 1409 | } |
| 1410 | |
| 1411 | /// Build a set literal from an array of strings. |
| 1412 | fn setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().<const N: usize>(xs: [&'static str; N]) -> FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<&'static str> { |
| 1413 | xs.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/iter/impl#[`[T; N]`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().() |
| 1414 | } |
| 1415 | |
| 1416 | fn ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/ancestry_1().() -> Graphrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#<&'static str, DictParentsProviderrust-analyzer cargo vcs-graph 3.6.0 parents_provider/DictParentsProvider#<&'static str>> { |
| 1417 | makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[ |
| 1418 | ("rev1", &[NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.]), |
| 1419 | ("rev2a", &["rev1"]), |
| 1420 | ("rev2b", &["rev1"]), |
| 1421 | ("rev3", &["rev2a"]), |
| 1422 | ("rev4", &["rev3", "rev2b"]), |
| 1423 | ]) |
| 1424 | } |
| 1425 | |
| 1426 | fn ancestry_2rust-analyzer cargo vcs-graph 3.6.0 graph/tests/ancestry_2().() -> Graphrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#<&'static str, DictParentsProviderrust-analyzer cargo vcs-graph 3.6.0 parents_provider/DictParentsProvider#<&'static str>> { |
| 1427 | makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[ |
| 1428 | ("rev1a", &[NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.]), |
| 1429 | ("rev2a", &["rev1a"]), |
| 1430 | ("rev1b", &[NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.]), |
| 1431 | ("rev3a", &["rev2a"]), |
| 1432 | ("rev4a", &["rev3a"]), |
| 1433 | ]) |
| 1434 | } |
| 1435 | |
| 1436 | fn criss_crossrust-analyzer cargo vcs-graph 3.6.0 graph/tests/criss_cross().() -> Graphrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#<&'static str, DictParentsProviderrust-analyzer cargo vcs-graph 3.6.0 parents_provider/DictParentsProvider#<&'static str>> { |
| 1437 | makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[ |
| 1438 | ("rev1", &[NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.]), |
| 1439 | ("rev2a", &["rev1"]), |
| 1440 | ("rev2b", &["rev1"]), |
| 1441 | ("rev3a", &["rev2a", "rev2b"]), |
| 1442 | ("rev3b", &["rev2b", "rev2a"]), |
| 1443 | ]) |
| 1444 | } |
| 1445 | |
| 1446 | fn criss_cross2rust-analyzer cargo vcs-graph 3.6.0 graph/tests/criss_cross2().() -> Graphrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#<&'static str, DictParentsProviderrust-analyzer cargo vcs-graph 3.6.0 parents_provider/DictParentsProvider#<&'static str>> { |
| 1447 | makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[ |
| 1448 | ("rev1a", &[NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.]), |
| 1449 | ("rev1b", &[NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.]), |
| 1450 | ("rev2a", &["rev1a", "rev1b"]), |
| 1451 | ("rev2b", &["rev1b", "rev1a"]), |
| 1452 | ]) |
| 1453 | } |
| 1454 | |
| 1455 | fn history_shortcutrust-analyzer cargo vcs-graph 3.6.0 graph/tests/history_shortcut().() -> Graphrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#<&'static str, DictParentsProviderrust-analyzer cargo vcs-graph 3.6.0 parents_provider/DictParentsProvider#<&'static str>> { |
| 1456 | makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[ |
| 1457 | ("rev1", &[NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.]), |
| 1458 | ("rev2a", &["rev1"]), |
| 1459 | ("rev2b", &["rev1"]), |
| 1460 | ("rev2c", &["rev1"]), |
| 1461 | ("rev3a", &["rev2a", "rev2b"]), |
| 1462 | ("rev3b", &["rev2b", "rev2c"]), |
| 1463 | ]) |
| 1464 | } |
| 1465 | |
| 1466 | fn extended_history_shortcutrust-analyzer cargo vcs-graph 3.6.0 graph/tests/extended_history_shortcut().() -> Graphrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#<&'static str, DictParentsProviderrust-analyzer cargo vcs-graph 3.6.0 parents_provider/DictParentsProvider#<&'static str>> { |
| 1467 | makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[ |
| 1468 | ("a", &[NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.]), |
| 1469 | ("b", &["a"]), |
| 1470 | ("c", &["b"]), |
| 1471 | ("d", &["c"]), |
| 1472 | ("e", &["d"]), |
| 1473 | ("f", &["a", "d"]), |
| 1474 | ]) |
| 1475 | } |
| 1476 | |
| 1477 | fn double_shortcut_fixturerust-analyzer cargo vcs-graph 3.6.0 graph/tests/double_shortcut_fixture().() -> Graphrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#<&'static str, DictParentsProviderrust-analyzer cargo vcs-graph 3.6.0 parents_provider/DictParentsProvider#<&'static str>> { |
| 1478 | makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[ |
| 1479 | ("a", &[NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.]), |
| 1480 | ("b", &["a"]), |
| 1481 | ("c", &["b"]), |
| 1482 | ("d", &["c"]), |
| 1483 | ("e", &["c"]), |
| 1484 | ("f", &["a", "d"]), |
| 1485 | ("g", &["a", "e"]), |
| 1486 | ]) |
| 1487 | } |
| 1488 | |
| 1489 | fn complex_shortcutrust-analyzer cargo vcs-graph 3.6.0 graph/tests/complex_shortcut().() -> Graphrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#<&'static str, DictParentsProviderrust-analyzer cargo vcs-graph 3.6.0 parents_provider/DictParentsProvider#<&'static str>> { |
| 1490 | makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[ |
| 1491 | ("a", &[NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.]), |
| 1492 | ("b", &["a"]), |
| 1493 | ("c", &["b"]), |
| 1494 | ("d", &["c"]), |
| 1495 | ("e", &["d"]), |
| 1496 | ("f", &["d"]), |
| 1497 | ("g", &["f"]), |
| 1498 | ("h", &["f"]), |
| 1499 | ("i", &["e", "g"]), |
| 1500 | ("j", &["g"]), |
| 1501 | ("k", &["j"]), |
| 1502 | ("l", &["k"]), |
| 1503 | ("m", &["i", "l"]), |
| 1504 | ("n", &["l", "h"]), |
| 1505 | ]) |
| 1506 | } |
| 1507 | |
| 1508 | fn complex_shortcut2rust-analyzer cargo vcs-graph 3.6.0 graph/tests/complex_shortcut2().() -> Graphrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#<&'static str, DictParentsProviderrust-analyzer cargo vcs-graph 3.6.0 parents_provider/DictParentsProvider#<&'static str>> { |
| 1509 | makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[ |
| 1510 | ("a", &[NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.]), |
| 1511 | ("b", &["a"]), |
| 1512 | ("c", &["b"]), |
| 1513 | ("d", &["c"]), |
| 1514 | ("e", &["d"]), |
| 1515 | ("f", &["e"]), |
| 1516 | ("g", &["f"]), |
| 1517 | ("h", &["d"]), |
| 1518 | ("i", &["g"]), |
| 1519 | ("j", &["h"]), |
| 1520 | ("k", &["h", "i"]), |
| 1521 | ("l", &["k"]), |
| 1522 | ("m", &["l"]), |
| 1523 | ("n", &["m"]), |
| 1524 | ("o", &["n"]), |
| 1525 | ("p", &["o"]), |
| 1526 | ("q", &["p"]), |
| 1527 | ("r", &["q"]), |
| 1528 | ("s", &["r"]), |
| 1529 | ("t", &["i", "s"]), |
| 1530 | ("u", &["s", "j"]), |
| 1531 | ]) |
| 1532 | } |
| 1533 | |
| 1534 | fn multiple_interesting_uniquerust-analyzer cargo vcs-graph 3.6.0 graph/tests/multiple_interesting_unique().() -> Graphrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#<&'static str, DictParentsProviderrust-analyzer cargo vcs-graph 3.6.0 parents_provider/DictParentsProvider#<&'static str>> { |
| 1535 | makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[ |
| 1536 | ("a", &[NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.]), |
| 1537 | ("b", &["a"]), |
| 1538 | ("c", &["b"]), |
| 1539 | ("d", &["c"]), |
| 1540 | ("e", &["d"]), |
| 1541 | ("f", &["d"]), |
| 1542 | ("g", &["e"]), |
| 1543 | ("h", &["e"]), |
| 1544 | ("i", &["f"]), |
| 1545 | ("j", &["g"]), |
| 1546 | ("k", &["g"]), |
| 1547 | ("l", &["h"]), |
| 1548 | ("m", &["i"]), |
| 1549 | ("n", &["k", "l"]), |
| 1550 | ("o", &["m"]), |
| 1551 | ("p", &["m", "l"]), |
| 1552 | ("q", &["n", "o"]), |
| 1553 | ("r", &["q"]), |
| 1554 | ("s", &["r"]), |
| 1555 | ("t", &["s"]), |
| 1556 | ("u", &["t"]), |
| 1557 | ("v", &["u"]), |
| 1558 | ("w", &["v"]), |
| 1559 | ("x", &["w"]), |
| 1560 | ("y", &["j", "x"]), |
| 1561 | ("z", &["x", "p"]), |
| 1562 | ]) |
| 1563 | } |
| 1564 | |
| 1565 | fn shortcut_extra_rootrust-analyzer cargo vcs-graph 3.6.0 graph/tests/shortcut_extra_root().() -> Graphrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#<&'static str, DictParentsProviderrust-analyzer cargo vcs-graph 3.6.0 parents_provider/DictParentsProvider#<&'static str>> { |
| 1566 | makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[ |
| 1567 | ("a", &[NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.]), |
| 1568 | ("b", &["a"]), |
| 1569 | ("c", &["b"]), |
| 1570 | ("d", &["c"]), |
| 1571 | ("e", &["d"]), |
| 1572 | ("f", &["a", "d", "g"]), |
| 1573 | ("g", &[NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.]), |
| 1574 | ]) |
| 1575 | } |
| 1576 | |
| 1577 | fn boundaryrust-analyzer cargo vcs-graph 3.6.0 graph/tests/boundary().() -> Graphrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#<&'static str, DictParentsProviderrust-analyzer cargo vcs-graph 3.6.0 parents_provider/DictParentsProvider#<&'static str>> { |
| 1578 | makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[ |
| 1579 | ("a", &["b"]), |
| 1580 | ("c", &["b", "d"]), |
| 1581 | ("b", &["e"]), |
| 1582 | ("d", &["e"]), |
| 1583 | ("e", &["f"]), |
| 1584 | ("f", &[NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.]), |
| 1585 | ]) |
| 1586 | } |
| 1587 | |
| 1588 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1589 | fn test_lca_ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_lca_ancestry_1().() { |
| 1590 | let g = ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/ancestry_1().(); |
| 1591 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.find_lcarust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_lca().([NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL., NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().([NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.])); |
| 1592 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.find_lcarust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_lca().([NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL., "rev1"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().([NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.])); |
| 1593 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.find_lcarust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_lca().(["rev1", "rev1"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev1"])); |
| 1594 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.find_lcarust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_lca().(["rev2a", "rev2b"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev1"])); |
| 1595 | } |
| 1596 | |
| 1597 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1598 | fn test_lca_criss_crossrust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_lca_criss_cross().() { |
| 1599 | let g = criss_crossrust-analyzer cargo vcs-graph 3.6.0 graph/tests/criss_cross().(); |
| 1600 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1601 | g.find_lcarust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_lca().(["rev3a", "rev3b"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), |
| 1602 | setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev2a", "rev2b"]) |
| 1603 | ); |
| 1604 | } |
| 1605 | |
| 1606 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1607 | fn test_lca_shortcutrust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_lca_shortcut().() { |
| 1608 | let g = history_shortcutrust-analyzer cargo vcs-graph 3.6.0 graph/tests/history_shortcut().(); |
| 1609 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.find_lcarust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_lca().(["rev3a", "rev3b"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev2b"])); |
| 1610 | } |
| 1611 | |
| 1612 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1613 | fn test_lca_double_shortcutrust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_lca_double_shortcut().() { |
| 1614 | let g = double_shortcut_fixturerust-analyzer cargo vcs-graph 3.6.0 graph/tests/double_shortcut_fixture().(); |
| 1615 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.find_lcarust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_lca().(["f", "g"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["c"])); |
| 1616 | } |
| 1617 | |
| 1618 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1619 | fn test_unique_lca_ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_unique_lca_ancestry_1().() { |
| 1620 | let g = ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/ancestry_1().(); |
| 1621 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.find_unique_lcarust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_lca().(NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL., NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL., &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL., 1))); |
| 1622 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.find_unique_lcarust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_lca().(NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL., "rev1", &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL., 1))); |
| 1623 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.find_unique_lcarust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_lca().("rev1", "rev1", &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(("rev1", 1))); |
| 1624 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1625 | g.find_unique_lcarust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_lca().("rev2a", "rev2b", &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), |
| 1626 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(("rev1", 1)) |
| 1627 | ); |
| 1628 | } |
| 1629 | |
| 1630 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1631 | fn test_unique_lca_criss_crossrust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_unique_lca_criss_cross().() { |
| 1632 | let g = criss_crossrust-analyzer cargo vcs-graph 3.6.0 graph/tests/criss_cross().(); |
| 1633 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1634 | g.find_unique_lcarust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_lca().("rev3a", "rev3b", &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), |
| 1635 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(("rev1", 2)) |
| 1636 | ); |
| 1637 | } |
| 1638 | |
| 1639 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1640 | fn test_unique_lca_null_revision_criss_cross2rust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_unique_lca_null_revision_criss_cross2().() { |
| 1641 | let g = criss_cross2rust-analyzer cargo vcs-graph 3.6.0 graph/tests/criss_cross2().(); |
| 1642 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1643 | g.find_unique_lcarust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_lca().("rev2a", "rev1b", &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(k, _)| k), |
| 1644 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("rev1b") |
| 1645 | ); |
| 1646 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1647 | g.find_unique_lcarust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_lca().("rev2a", "rev2b", &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(k, _)| k), |
| 1648 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.) |
| 1649 | ); |
| 1650 | } |
| 1651 | |
| 1652 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1653 | fn test_unique_lca_separate_ancestryrust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_unique_lca_separate_ancestry().() { |
| 1654 | let g = ancestry_2rust-analyzer cargo vcs-graph 3.6.0 graph/tests/ancestry_2().(); |
| 1655 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1656 | g.find_unique_lcarust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_lca().("rev4a", "rev1b", &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(k, _)| k), |
| 1657 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.) |
| 1658 | ); |
| 1659 | } |
| 1660 | |
| 1661 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1662 | fn test_heads_nullrust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_heads_null().() { |
| 1663 | let g = ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/ancestry_1().(); |
| 1664 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().([NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().([NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.])); |
| 1665 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().([NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL., "rev1"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev1"])); |
| 1666 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["rev1", NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev1"])); |
| 1667 | } |
| 1668 | |
| 1669 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1670 | fn test_heads_onerust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_heads_one().() { |
| 1671 | let g = ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/ancestry_1().(); |
| 1672 | for key in [NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL., "rev1", "rev2a", "rev2b", "rev3", "rev4"] { |
| 1673 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().([key], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().([key])); |
| 1674 | } |
| 1675 | } |
| 1676 | |
| 1677 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1678 | fn test_heads_single_from_pairrust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_heads_single_from_pair().() { |
| 1679 | let g = ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/ancestry_1().(); |
| 1680 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().([NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL., "rev4"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev4"])); |
| 1681 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["rev1", "rev2a"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev2a"])); |
| 1682 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["rev1", "rev2b"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev2b"])); |
| 1683 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["rev1", "rev3"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev3"])); |
| 1684 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["rev1", "rev4"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev4"])); |
| 1685 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["rev2a", "rev4"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev4"])); |
| 1686 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["rev2b", "rev4"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev4"])); |
| 1687 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["rev3", "rev4"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev4"])); |
| 1688 | } |
| 1689 | |
| 1690 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1691 | fn test_heads_two_headsrust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_heads_two_heads().() { |
| 1692 | let g = ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/ancestry_1().(); |
| 1693 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1694 | g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["rev2a", "rev2b"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), |
| 1695 | setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev2a", "rev2b"]) |
| 1696 | ); |
| 1697 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1698 | g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["rev3", "rev2b"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), |
| 1699 | setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev3", "rev2b"]) |
| 1700 | ); |
| 1701 | } |
| 1702 | |
| 1703 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1704 | fn test_heads_criss_crossrust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_heads_criss_cross().() { |
| 1705 | let g = criss_crossrust-analyzer cargo vcs-graph 3.6.0 graph/tests/criss_cross().(); |
| 1706 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["rev2a", "rev1"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev2a"])); |
| 1707 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["rev2b", "rev1"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev2b"])); |
| 1708 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["rev3a", "rev1"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev3a"])); |
| 1709 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["rev3b", "rev1"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev3b"])); |
| 1710 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1711 | g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["rev2a", "rev2b"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), |
| 1712 | setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev2a", "rev2b"]) |
| 1713 | ); |
| 1714 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["rev3a", "rev2a"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev3a"])); |
| 1715 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["rev3a", "rev2b"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev3a"])); |
| 1716 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1717 | g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["rev3a", "rev2a", "rev2b"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), |
| 1718 | setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev3a"]) |
| 1719 | ); |
| 1720 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["rev3b", "rev2a"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev3b"])); |
| 1721 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["rev3b", "rev2b"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev3b"])); |
| 1722 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1723 | g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["rev3b", "rev2a", "rev2b"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), |
| 1724 | setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev3b"]) |
| 1725 | ); |
| 1726 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1727 | g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["rev3a", "rev3b"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), |
| 1728 | setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev3a", "rev3b"]) |
| 1729 | ); |
| 1730 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1731 | g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["rev3a", "rev3b", "rev2a", "rev2b"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), |
| 1732 | setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev3a", "rev3b"]) |
| 1733 | ); |
| 1734 | } |
| 1735 | |
| 1736 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1737 | fn test_heads_shortcutrust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_heads_shortcut().() { |
| 1738 | let g = history_shortcutrust-analyzer cargo vcs-graph 3.6.0 graph/tests/history_shortcut().(); |
| 1739 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1740 | g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["rev2a", "rev2b", "rev2c"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), |
| 1741 | setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev2a", "rev2b", "rev2c"]) |
| 1742 | ); |
| 1743 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1744 | g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["rev3a", "rev3b"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), |
| 1745 | setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev3a", "rev3b"]) |
| 1746 | ); |
| 1747 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1748 | g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["rev2a", "rev3a", "rev3b"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), |
| 1749 | setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev3a", "rev3b"]) |
| 1750 | ); |
| 1751 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1752 | g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["rev2a", "rev3b"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), |
| 1753 | setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev2a", "rev3b"]) |
| 1754 | ); |
| 1755 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1756 | g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["rev2c", "rev3a"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), |
| 1757 | setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev2c", "rev3a"]) |
| 1758 | ); |
| 1759 | } |
| 1760 | |
| 1761 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1762 | fn test_graph_difference_ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_graph_difference_ancestry_1().() { |
| 1763 | let g = ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/ancestry_1().(); |
| 1764 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1765 | g.find_differencerust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_difference().("rev1", "rev1"), |
| 1766 | (FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().(), FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().()) |
| 1767 | ); |
| 1768 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1769 | g.find_differencerust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_difference().(NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL., "rev1"), |
| 1770 | (FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().(), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev1"])) |
| 1771 | ); |
| 1772 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1773 | g.find_differencerust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_difference().("rev1", NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), |
| 1774 | (setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev1"]), FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().()) |
| 1775 | ); |
| 1776 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1777 | g.find_differencerust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_difference().("rev3", "rev2b"), |
| 1778 | (setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev2a", "rev3"]), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev2b"])) |
| 1779 | ); |
| 1780 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1781 | g.find_differencerust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_difference().("rev4", "rev2b"), |
| 1782 | (setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev4", "rev3", "rev2a"]), FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().()) |
| 1783 | ); |
| 1784 | } |
| 1785 | |
| 1786 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1787 | fn test_graph_difference_separate_ancestryrust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_graph_difference_separate_ancestry().() { |
| 1788 | let g = ancestry_2rust-analyzer cargo vcs-graph 3.6.0 graph/tests/ancestry_2().(); |
| 1789 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1790 | g.find_differencerust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_difference().("rev1a", "rev1b"), |
| 1791 | (setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev1a"]), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev1b"])) |
| 1792 | ); |
| 1793 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1794 | g.find_differencerust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_difference().("rev4a", "rev1b"), |
| 1795 | (setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev1a", "rev2a", "rev3a", "rev4a"]), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev1b"])) |
| 1796 | ); |
| 1797 | } |
| 1798 | |
| 1799 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1800 | fn test_graph_difference_criss_crossrust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_graph_difference_criss_cross().() { |
| 1801 | let g = criss_crossrust-analyzer cargo vcs-graph 3.6.0 graph/tests/criss_cross().(); |
| 1802 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1803 | g.find_differencerust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_difference().("rev3a", "rev3b"), |
| 1804 | (setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev3a"]), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev3b"])) |
| 1805 | ); |
| 1806 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1807 | g.find_differencerust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_difference().("rev2a", "rev3b"), |
| 1808 | (FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().(), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev3b", "rev2b"])) |
| 1809 | ); |
| 1810 | } |
| 1811 | |
| 1812 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1813 | fn test_graph_difference_extended_historyrust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_graph_difference_extended_history().() { |
| 1814 | let g = extended_history_shortcutrust-analyzer cargo vcs-graph 3.6.0 graph/tests/extended_history_shortcut().(); |
| 1815 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.find_differencerust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_difference().("e", "f"), (setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["e"]), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["f"]))); |
| 1816 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.find_differencerust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_difference().("f", "e"), (setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["f"]), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["e"]))); |
| 1817 | } |
| 1818 | |
| 1819 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1820 | fn test_graph_difference_double_shortcutrust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_graph_difference_double_shortcut().() { |
| 1821 | let g = double_shortcut_fixturerust-analyzer cargo vcs-graph 3.6.0 graph/tests/double_shortcut_fixture().(); |
| 1822 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1823 | g.find_differencerust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_difference().("f", "g"), |
| 1824 | (setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["d", "f"]), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["e", "g"])) |
| 1825 | ); |
| 1826 | } |
| 1827 | |
| 1828 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1829 | fn test_graph_difference_complex_shortcutrust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_graph_difference_complex_shortcut().() { |
| 1830 | let g = complex_shortcutrust-analyzer cargo vcs-graph 3.6.0 graph/tests/complex_shortcut().(); |
| 1831 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1832 | g.find_differencerust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_difference().("m", "n"), |
| 1833 | (setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["m", "i", "e"]), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["n", "h"])) |
| 1834 | ); |
| 1835 | } |
| 1836 | |
| 1837 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1838 | fn test_graph_difference_complex_shortcut2rust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_graph_difference_complex_shortcut2().() { |
| 1839 | let g = complex_shortcut2rust-analyzer cargo vcs-graph 3.6.0 graph/tests/complex_shortcut2().(); |
| 1840 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.find_differencerust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_difference().("t", "u"), (setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["t"]), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["j", "u"]))); |
| 1841 | } |
| 1842 | |
| 1843 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1844 | fn test_graph_difference_shortcut_extra_rootrust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_graph_difference_shortcut_extra_root().() { |
| 1845 | let g = shortcut_extra_rootrust-analyzer cargo vcs-graph 3.6.0 graph/tests/shortcut_extra_root().(); |
| 1846 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.find_differencerust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_difference().("e", "f"), (setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["e"]), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["f", "g"]))); |
| 1847 | } |
| 1848 | |
| 1849 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1850 | fn test_unique_ancestors_empty_setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_unique_ancestors_empty_set().() { |
| 1851 | let g = ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/ancestry_1().(); |
| 1852 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1853 | g.find_unique_ancestorsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_ancestors().("rev1", ["rev1"]), |
| 1854 | FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().() |
| 1855 | ); |
| 1856 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1857 | g.find_unique_ancestorsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_ancestors().("rev2b", ["rev2b"]), |
| 1858 | FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().() |
| 1859 | ); |
| 1860 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1861 | g.find_unique_ancestorsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_ancestors().("rev3", ["rev1", "rev3"]), |
| 1862 | FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().() |
| 1863 | ); |
| 1864 | } |
| 1865 | |
| 1866 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1867 | fn test_unique_ancestors_single_noderust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_unique_ancestors_single_node().() { |
| 1868 | let g = ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/ancestry_1().(); |
| 1869 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.find_unique_ancestorsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_ancestors().("rev2a", ["rev1"]), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev2a"])); |
| 1870 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.find_unique_ancestorsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_ancestors().("rev2b", ["rev1"]), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev2b"])); |
| 1871 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.find_unique_ancestorsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_ancestors().("rev3", ["rev2a"]), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev3"])); |
| 1872 | } |
| 1873 | |
| 1874 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1875 | fn test_unique_ancestors_in_ancestryrust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_unique_ancestors_in_ancestry().() { |
| 1876 | let g = ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/ancestry_1().(); |
| 1877 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1878 | g.find_unique_ancestorsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_ancestors().("rev1", ["rev3"]), |
| 1879 | FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().() |
| 1880 | ); |
| 1881 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1882 | g.find_unique_ancestorsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_ancestors().("rev2b", ["rev4"]), |
| 1883 | FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().() |
| 1884 | ); |
| 1885 | } |
| 1886 | |
| 1887 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1888 | fn test_unique_ancestors_multiple_revisionsrust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_unique_ancestors_multiple_revisions().() { |
| 1889 | let g = ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/ancestry_1().(); |
| 1890 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1891 | g.find_unique_ancestorsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_ancestors().("rev4", ["rev3", "rev2b"]), |
| 1892 | setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev4"]) |
| 1893 | ); |
| 1894 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1895 | g.find_unique_ancestorsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_ancestors().("rev4", ["rev2b"]), |
| 1896 | setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev2a", "rev3", "rev4"]) |
| 1897 | ); |
| 1898 | } |
| 1899 | |
| 1900 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1901 | fn test_unique_ancestors_complex_shortcutrust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_unique_ancestors_complex_shortcut().() { |
| 1902 | let g = complex_shortcutrust-analyzer cargo vcs-graph 3.6.0 graph/tests/complex_shortcut().(); |
| 1903 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.find_unique_ancestorsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_ancestors().("n", ["m"]), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["h", "n"])); |
| 1904 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.find_unique_ancestorsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_ancestors().("m", ["n"]), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["e", "i", "m"])); |
| 1905 | } |
| 1906 | |
| 1907 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1908 | fn test_unique_ancestors_complex_shortcut2rust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_unique_ancestors_complex_shortcut2().() { |
| 1909 | let g = complex_shortcut2rust-analyzer cargo vcs-graph 3.6.0 graph/tests/complex_shortcut2().(); |
| 1910 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.find_unique_ancestorsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_ancestors().("u", ["t"]), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["j", "u"])); |
| 1911 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.find_unique_ancestorsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_ancestors().("t", ["u"]), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["t"])); |
| 1912 | } |
| 1913 | |
| 1914 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1915 | fn test_unique_ancestors_multiple_interesting_uniquerust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_unique_ancestors_multiple_interesting_unique().() { |
| 1916 | let g = multiple_interesting_uniquerust-analyzer cargo vcs-graph 3.6.0 graph/tests/multiple_interesting_unique().(); |
| 1917 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.find_unique_ancestorsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_ancestors().("y", ["z"]), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["j", "y"])); |
| 1918 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.find_unique_ancestorsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_ancestors().("z", ["y"]), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["p", "z"])); |
| 1919 | } |
| 1920 | |
| 1921 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1922 | fn test_is_ancestor_ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_is_ancestor_ancestry_1().() { |
| 1923 | let g = ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/ancestry_1().(); |
| 1924 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(g.is_ancestorrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]is_ancestor().(NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL., NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL., &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.)); |
| 1925 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(g.is_ancestorrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]is_ancestor().(NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL., "rev1", &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.)); |
| 1926 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().g.is_ancestorrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]is_ancestor().("rev1", NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL., &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.)); |
| 1927 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(g.is_ancestorrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]is_ancestor().(NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL., "rev4", &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.)); |
| 1928 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().g.is_ancestorrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]is_ancestor().("rev4", NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL., &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.)); |
| 1929 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().g.is_ancestorrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]is_ancestor().("rev4", "rev2b", &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.)); |
| 1930 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(g.is_ancestorrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]is_ancestor().("rev2b", "rev4", &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.)); |
| 1931 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().g.is_ancestorrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]is_ancestor().("rev2b", "rev3", &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.)); |
| 1932 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().g.is_ancestorrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]is_ancestor().("rev3", "rev2b", &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.)); |
| 1933 | } |
| 1934 | |
| 1935 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1936 | fn test_is_ancestor_boundaryrust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_is_ancestor_boundary().() { |
| 1937 | // Python's test_is_ancestor_boundary: verify a is not an ancestor |
| 1938 | // of c despite both sharing a common ancestor further down. |
| 1939 | let g = boundaryrust-analyzer cargo vcs-graph 3.6.0 graph/tests/boundary().(); |
| 1940 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().g.is_ancestorrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]is_ancestor().("a", "c", &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.)); |
| 1941 | } |
| 1942 | |
| 1943 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1944 | fn test_is_between_ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_is_between_ancestry_1().() { |
| 1945 | let g = ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/ancestry_1().(); |
| 1946 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(g.is_betweenrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]is_between().(NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL., Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.)); |
| 1947 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(g.is_betweenrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]is_between().("rev1", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("rev1"), &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.)); |
| 1948 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(g.is_betweenrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]is_between().("rev1", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("rev1"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("rev4"), &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.)); |
| 1949 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(g.is_betweenrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]is_between().("rev4", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("rev1"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("rev4"), &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.)); |
| 1950 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(g.is_betweenrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]is_between().("rev3", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("rev1"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("rev4"), &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.)); |
| 1951 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().g.is_betweenrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]is_between().("rev4", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("rev1"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("rev3"), &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.)); |
| 1952 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().g.is_betweenrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]is_between().("rev1", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("rev2a"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("rev4"), &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.)); |
| 1953 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().g.is_betweenrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]is_between().(NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL., Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("rev1"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("rev4"), &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.)); |
| 1954 | } |
| 1955 | |
| 1956 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1957 | fn test_find_merge_order_single_lcarust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_find_merge_order_single_lca().() { |
| 1958 | let g = ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/ancestry_1().(); |
| 1959 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.find_merge_orderrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_merge_order().("rev4", ["rev2b"]), vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["rev2b"]); |
| 1960 | } |
| 1961 | |
| 1962 | fn with_ghostrust-analyzer cargo vcs-graph 3.6.0 graph/tests/with_ghost().() -> Graphrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#<&'static str, DictParentsProviderrust-analyzer cargo vcs-graph 3.6.0 parents_provider/DictParentsProvider#<&'static str>> { |
| 1963 | // NULL_REVISION itself is explicitly included as a root so it |
| 1964 | // survives as a key in iter_ancestry's output. |
| 1965 | makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[ |
| 1966 | ("a", &["b"]), |
| 1967 | ("c", &["b", "d"]), |
| 1968 | ("b", &["e"]), |
| 1969 | ("d", &["e", "g"]), |
| 1970 | ("e", &["f"]), |
| 1971 | ("f", &[NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.]), |
| 1972 | (NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL., &[]), |
| 1973 | ]) |
| 1974 | } |
| 1975 | |
| 1976 | fn racing_shortcutsrust-analyzer cargo vcs-graph 3.6.0 graph/tests/racing_shortcuts().() -> Graphrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#<&'static str, DictParentsProviderrust-analyzer cargo vcs-graph 3.6.0 parents_provider/DictParentsProvider#<&'static str>> { |
| 1977 | makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[ |
| 1978 | ("a", &[NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.]), |
| 1979 | ("b", &["a"]), |
| 1980 | ("c", &["b"]), |
| 1981 | ("d", &["c"]), |
| 1982 | ("e", &["d"]), |
| 1983 | ("f", &["e"]), |
| 1984 | ("g", &["f"]), |
| 1985 | ("h", &["g"]), |
| 1986 | ("i", &["h", "o"]), |
| 1987 | ("j", &["i", "y"]), |
| 1988 | ("k", &["d"]), |
| 1989 | ("l", &["k"]), |
| 1990 | ("m", &["l"]), |
| 1991 | ("n", &["m"]), |
| 1992 | ("o", &["n", "g"]), |
| 1993 | ("p", &["f"]), |
| 1994 | ("q", &["p", "m"]), |
| 1995 | ("r", &["o"]), |
| 1996 | ("s", &["r"]), |
| 1997 | ("t", &["s"]), |
| 1998 | ("u", &["t"]), |
| 1999 | ("v", &["u"]), |
| 2000 | ("w", &["v"]), |
| 2001 | ("x", &["w"]), |
| 2002 | ("y", &["x"]), |
| 2003 | ("z", &["x", "q"]), |
| 2004 | ]) |
| 2005 | } |
| 2006 | |
| 2007 | /// Python's `alt_merge` fixture. |
| 2008 | /// |
| 2009 | /// ```text |
| 2010 | /// a |
| 2011 | /// |\ |
| 2012 | /// b | |
| 2013 | /// | | |
| 2014 | /// c | |
| 2015 | /// \| |
| 2016 | /// d |
| 2017 | /// ``` |
| 2018 | fn alt_mergerust-analyzer cargo vcs-graph 3.6.0 graph/tests/alt_merge().() -> Graphrust-analyzer cargo vcs-graph 3.6.0 graph/Graph#<&'static str, DictParentsProviderrust-analyzer cargo vcs-graph 3.6.0 parents_provider/DictParentsProvider#<&'static str>> { |
| 2019 | makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[("a", &[]), ("b", &["a"]), ("c", &["b"]), ("d", &["a", "c"])]) |
| 2020 | } |
| 2021 | |
| 2022 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 2023 | fn test_heads_alt_mergerust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_heads_alt_merge().() { |
| 2024 | let g = alt_mergerust-analyzer cargo vcs-graph 3.6.0 graph/tests/alt_merge().(); |
| 2025 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["a", "c"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["c"])); |
| 2026 | } |
| 2027 | |
| 2028 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 2029 | fn test_heads_with_ghost_fixturerust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_heads_with_ghost_fixture().() { |
| 2030 | let g = with_ghostrust-analyzer cargo vcs-graph 3.6.0 graph/tests/with_ghost().(); |
| 2031 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["e", "g"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["e", "g"])); |
| 2032 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["a", "c"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["a", "c"])); |
| 2033 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["a", "g"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["a", "g"])); |
| 2034 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["f", "g"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["f", "g"])); |
| 2035 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["c", "g"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["c"])); |
| 2036 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["c", "b", "d", "g"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["c"])); |
| 2037 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 2038 | g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["a", "c", "e", "g"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), |
| 2039 | setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["a", "c"]) |
| 2040 | ); |
| 2041 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["a", "c", "f"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["a", "c"])); |
| 2042 | } |
| 2043 | |
| 2044 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 2045 | fn test_filter_candidate_lcarust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_filter_candidate_lca().() { |
| 2046 | // Corner case from Python: |
| 2047 | // NULL |
| 2048 | // / \ |
| 2049 | // a e |
| 2050 | // | | |
| 2051 | // b d |
| 2052 | // \ / |
| 2053 | // c |
| 2054 | // `a`'s descendant is `c`; `e`'s descendant is also `c`. So |
| 2055 | // heads([a, c, e]) should be just {c}. |
| 2056 | let g = makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[ |
| 2057 | ("c", &["b", "d"]), |
| 2058 | ("d", &["e"]), |
| 2059 | ("b", &["a"]), |
| 2060 | ("a", &[NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.]), |
| 2061 | ("e", &[NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.]), |
| 2062 | ]); |
| 2063 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.heads_with_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]heads_with_null().(["a", "c", "e"], &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["c"])); |
| 2064 | } |
| 2065 | |
| 2066 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 2067 | fn test_iter_topo_order_ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_iter_topo_order_ancestry_1().() { |
| 2068 | let g = ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/ancestry_1().(); |
| 2069 | let order = g.iter_topo_orderrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]iter_topo_order().(["rev2a", "rev3", "rev1"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 2070 | let pos = |k: &&str| order.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().positionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]position().(|n| n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().k).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 2071 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 2072 | order.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<_>>(), |
| 2073 | setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["rev1", "rev2a", "rev3"]) |
| 2074 | ); |
| 2075 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(pos(&"rev2a") >rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). pos(&"rev1")); |
| 2076 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(pos(&"rev2a") <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). pos(&"rev3")); |
| 2077 | } |
| 2078 | |
| 2079 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 2080 | fn test_iter_ancestry_boundaryrust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_iter_ancestry_boundary().() { |
| 2081 | let g = with_ghostrust-analyzer cargo vcs-graph 3.6.0 graph/tests/with_ghost().(); |
| 2082 | // `a` is not in the ancestry of `c`; everything else is. |
| 2083 | let anc = g.iter_ancestryrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]iter_ancestry().(["c"]); |
| 2084 | let keys: FxHashSetrust-analyzer cargo rustc-hash 2.1.2 FxHashSet#<&'static str> = anc.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(k, _)| *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().k).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 2085 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().keys.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&"a")); |
| 2086 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(keys.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&"c")); |
| 2087 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(keys.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&"b")); |
| 2088 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(keys.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&"d")); |
| 2089 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(keys.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&"e")); |
| 2090 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(keys.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&"f")); |
| 2091 | } |
| 2092 | |
| 2093 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 2094 | fn test_iter_ancestry_with_ghost_reports_nonerust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_iter_ancestry_with_ghost_reports_none().() { |
| 2095 | let g = with_ghostrust-analyzer cargo vcs-graph 3.6.0 graph/tests/with_ghost().(); |
| 2096 | // `g` is a ghost (present as parent of `d` but not as key). |
| 2097 | // iter_ancestry should yield it with Parents::Ghost. |
| 2098 | let anc = g.iter_ancestryrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]iter_ancestry().(["a", "c"]); |
| 2099 | let mut ghost_seen = false; |
| 2100 | for (k, parents) in &anc { |
| 2101 | if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().k rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."g" { |
| 2102 | ghost_seen = true; |
| 2103 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(parents, Parentsrust-analyzer cargo vcs-graph 3.6.0 Parents#::Ghostrust-analyzer cargo vcs-graph 3.6.0 Parents#Ghost#)); |
| 2104 | } |
| 2105 | } |
| 2106 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(ghost_seen, "ghost `g` should appear in iter_ancestry"); |
| 2107 | } |
| 2108 | |
| 2109 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 2110 | fn test_find_lefthand_merger_rev2brust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_find_lefthand_merger_rev2b().() { |
| 2111 | // In ancestry_1, rev4 merged rev2b (rev4 has parents [rev3, rev2b]). |
| 2112 | // Walking rev4's lefthand ancestry from rev2b: rev4 is the merger. |
| 2113 | let g = ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/ancestry_1().(); |
| 2114 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.find_lefthand_mergerrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_lefthand_merger().("rev2b", "rev4"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("rev4")); |
| 2115 | } |
| 2116 | |
| 2117 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 2118 | fn test_find_lefthand_merger_rev2arust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_find_lefthand_merger_rev2a().() { |
| 2119 | // rev2a is itself a lefthand ancestor of rev4 (via rev3), so it's |
| 2120 | // its own "merger". |
| 2121 | let g = ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/ancestry_1().(); |
| 2122 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.find_lefthand_mergerrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_lefthand_merger().("rev2a", "rev4"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("rev2a")); |
| 2123 | } |
| 2124 | |
| 2125 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 2126 | fn test_find_lefthand_merger_rev4_not_ancestorrust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_find_lefthand_merger_rev4_not_ancestor().() { |
| 2127 | // rev4 is a descendant of rev2a, not an ancestor. |
| 2128 | let g = ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/ancestry_1().(); |
| 2129 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.find_lefthand_mergerrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_lefthand_merger().("rev4", "rev2a"), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 2130 | } |
| 2131 | |
| 2132 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 2133 | fn test_unique_lca_recursive_ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_unique_lca_recursive_ancestry_1().() { |
| 2134 | // In ancestry_1, rev1 is the unique LCA of rev2a and rev2b. |
| 2135 | let g = ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/ancestry_1().(); |
| 2136 | let (key, steps) = g.find_unique_lcarust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_lca().("rev2a", "rev2b", &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 2137 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(key, "rev1"); |
| 2138 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(steps, 1); |
| 2139 | } |
| 2140 | |
| 2141 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 2142 | fn test_unique_lca_no_common_ancestorrust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_unique_lca_no_common_ancestor().() { |
| 2143 | // Two disjoint ancestries share only NULL_REVISION as a common |
| 2144 | // ancestor. find_unique_lca returns NULL (never errors). |
| 2145 | let g = ancestry_2rust-analyzer cargo vcs-graph 3.6.0 graph/tests/ancestry_2().(); |
| 2146 | let (key, _steps) = g.find_unique_lcarust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_lca().("rev4a", "rev1b", &NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 2147 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(key, NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.); |
| 2148 | } |
| 2149 | |
| 2150 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 2151 | fn test_unique_ancestors_racing_shortcutsrust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_unique_ancestors_racing_shortcuts().() { |
| 2152 | let g = racing_shortcutsrust-analyzer cargo vcs-graph 3.6.0 graph/tests/racing_shortcuts().(); |
| 2153 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(g.find_unique_ancestorsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_ancestors().("z", ["y"]), setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["p", "q", "z"])); |
| 2154 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 2155 | g.find_unique_ancestorsrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_unique_ancestors().("j", ["z"]), |
| 2156 | setrust-analyzer cargo vcs-graph 3.6.0 graph/tests/set().(["h", "i", "j", "y"]) |
| 2157 | ); |
| 2158 | } |
| 2159 | |
| 2160 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 2161 | fn test_find_distance_to_null_ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_find_distance_to_null_ancestry_1().() { |
| 2162 | let g = ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/ancestry_1().(); |
| 2163 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 2164 | g.find_distance_to_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_distance_to_null().(NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL., stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/empty/empty().(), NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.) |
| 2165 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 2166 | 0 |
| 2167 | ); |
| 2168 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 2169 | g.find_distance_to_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_distance_to_null().("rev1", stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/empty/empty().(), NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.) |
| 2170 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 2171 | 1 |
| 2172 | ); |
| 2173 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 2174 | g.find_distance_to_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_distance_to_null().("rev2a", stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/empty/empty().(), NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.) |
| 2175 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 2176 | 2 |
| 2177 | ); |
| 2178 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 2179 | g.find_distance_to_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_distance_to_null().("rev2b", stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/empty/empty().(), NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.) |
| 2180 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 2181 | 2 |
| 2182 | ); |
| 2183 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 2184 | g.find_distance_to_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_distance_to_null().("rev3", stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/empty/empty().(), NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.) |
| 2185 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 2186 | 3 |
| 2187 | ); |
| 2188 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 2189 | g.find_distance_to_nullrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_distance_to_null().("rev4", stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/empty/empty().(), NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.) |
| 2190 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 2191 | 4 |
| 2192 | ); |
| 2193 | } |
| 2194 | |
| 2195 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 2196 | fn test_find_lefthand_distances_ghostsrust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_find_lefthand_distances_ghosts().() { |
| 2197 | let g = makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[("nonghost", &[NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.]), ("toghost", &["ghost"])]); |
| 2198 | let d = g.find_lefthand_distancesrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_lefthand_distances().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["nonghost", "toghost"], NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.); |
| 2199 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(&"nonghost"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&1)); |
| 2200 | // Ghosts are reported as distance -1. |
| 2201 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(&"toghost"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][Neg]neg().1)); |
| 2202 | } |
| 2203 | |
| 2204 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 2205 | fn test_find_lefthand_distances_smokerust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_find_lefthand_distances_smoke().() { |
| 2206 | let g = makerust-analyzer cargo vcs-graph 3.6.0 graph/tests/make().(&[ |
| 2207 | ("rev1", &[NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.]), |
| 2208 | ("rev2a", &["rev1"]), |
| 2209 | ("rev2b", &["rev1"]), |
| 2210 | ("rev2c", &["rev1"]), |
| 2211 | ("rev3a", &["rev2a", "rev2b"]), |
| 2212 | ("rev3b", &["rev2b", "rev2c"]), |
| 2213 | ]); |
| 2214 | let d = g.find_lefthand_distancesrust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]find_lefthand_distances().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["rev3b", "rev2a"], NULLrust-analyzer cargo vcs-graph 3.6.0 graph/tests/NULL.); |
| 2215 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(&"rev2a"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&2)); |
| 2216 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(&"rev3b"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&3)); |
| 2217 | } |
| 2218 | |
| 2219 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 2220 | fn test_get_child_map_ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/test_get_child_map_ancestry_1().() { |
| 2221 | let g = ancestry_1rust-analyzer cargo vcs-graph 3.6.0 graph/tests/ancestry_1().(); |
| 2222 | let cm = g.get_child_maprust-analyzer cargo vcs-graph 3.6.0 graph/impl#[`Graph<K, P>`]get_child_map().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["rev4", "rev3", "rev2a", "rev2b"]); |
| 2223 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cm.getrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]get().(&"rev1"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["rev2a", "rev2b"])); |
| 2224 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cm.getrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]get().(&"rev2a"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["rev3"])); |
| 2225 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cm.getrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]get().(&"rev2b"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["rev4"])); |
| 2226 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cm.getrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]get().(&"rev3"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["rev4"])); |
| 2227 | } |
| 2228 | } |