| 1 | use gix_daterust-analyzer cargo gix-date 0.15.3 crate/::SecondsSinceUnixEpochrust-analyzer cargo gix-date 0.15.3 SecondsSinceUnixEpoch#; |
| 2 | use gix_hashrust-analyzer cargo gix-hash 0.25.0 crate/::ObjectIdrust-analyzer cargo gix-hash 0.25.0 object_id/ObjectId#; |
| 3 | |
| 4 | use craterust-analyzer cargo gix-negotiate 0.31.0 crate/::{Errorrust-analyzer cargo gix-negotiate 0.31.0 Error#, Flagsrust-analyzer cargo gix-negotiate 0.31.0 Flags#, Metadatarust-analyzer cargo gix-negotiate 0.31.0 Metadata#, Negotiatorrust-analyzer cargo gix-negotiate 0.31.0 Negotiator#}; |
| 5 | |
| 6 | pub(craterust-analyzer cargo gix-negotiate 0.31.0 crate/) struct Algorithmrust-analyzer cargo gix-negotiate 0.31.0 skipping/Algorithm# { |
| 7 | revsrust-analyzer cargo gix-negotiate 0.31.0 skipping/Algorithm#revs.: gix_revwalkrust-analyzer cargo gix-revwalk 0.31.0 crate/::PriorityQueuerust-analyzer cargo gix-revwalk 0.31.0 PriorityQueue#<SecondsSinceUnixEpochrust-analyzer cargo gix-date 0.15.3 SecondsSinceUnixEpoch#, ObjectIdrust-analyzer cargo gix-hash 0.25.0 object_id/ObjectId#>, |
| 8 | non_common_revsrust-analyzer cargo gix-negotiate 0.31.0 skipping/Algorithm#non_common_revs.: usize, |
| 9 | } |
| 10 | |
| 11 | impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for Algorithmrust-analyzer cargo gix-negotiate 0.31.0 skipping/Algorithm# { |
| 12 | fn defaultrust-analyzer cargo gix-negotiate 0.31.0 skipping/impl#[Algorithm][Default]default().() -> Selfrust-analyzer cargo gix-negotiate 0.31.0 skipping/impl#[Algorithm][Default] { |
| 13 | Selfrust-analyzer cargo gix-negotiate 0.31.0 skipping/impl#[Algorithm][Default] { |
| 14 | revsrust-analyzer cargo gix-negotiate 0.31.0 skipping/Algorithm#revs.: gix_revwalkrust-analyzer cargo gix-revwalk 0.31.0 crate/::PriorityQueuerust-analyzer cargo gix-revwalk 0.31.0 PriorityQueue#::newrust-analyzer cargo gix-revwalk 0.31.0 queue/impl#[`PriorityQueue<K, T>`]new().(), |
| 15 | non_common_revsrust-analyzer cargo gix-negotiate 0.31.0 skipping/Algorithm#non_common_revs.: 0, |
| 16 | } |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | impl Algorithmrust-analyzer cargo gix-negotiate 0.31.0 skipping/Algorithm# { |
| 21 | /// Add `id` to our priority queue and *add* `flags` to it. |
| 22 | fn add_to_queuerust-analyzer cargo gix-negotiate 0.31.0 skipping/impl#[Algorithm]add_to_queue().(&mut self, id: ObjectIdrust-analyzer cargo gix-hash 0.25.0 object_id/ObjectId#, mark: Flagsrust-analyzer cargo gix-negotiate 0.31.0 Flags#, graph: &mut craterust-analyzer cargo gix-negotiate 0.31.0 crate/::Graphrust-analyzer cargo gix-negotiate 0.31.0 Graph#<'_, '_>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo gix-negotiate 0.31.0 Error#> { |
| 23 | let commit = graph.get_or_insert_commitrust-analyzer cargo gix-revwalk 0.31.0 graph/impl#[`Graph<'_, '_, Commit<T>>`]get_or_insert_commit().(id, |entry| { |
| 24 | entry.flagsrust-analyzer cargo gix-negotiate 0.31.0 Metadata#flags. rust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags][`BitOrAssign<Self>`]bitor_assign().|=rust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags][`BitOrAssign<Self>`]bitor_assign(). rust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags][`BitOrAssign<Self>`]bitor_assign().mark rust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags][`BitOr<Self>`]bitor().|rust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags][`BitOr<Self>`]bitor(). rust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags][`BitOr<Self>`]bitor().Flagsrust-analyzer cargo gix-negotiate 0.31.0 Flags#::SEENrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]SEEN.; |
| 25 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 26 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(timestamp) = commit.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|c| c.commit_timerust-analyzer cargo gix-revwalk 0.31.0 graph/Commit#commit_time.) { |
| 27 | self.revsrust-analyzer cargo gix-negotiate 0.31.0 skipping/Algorithm#revs..insertrust-analyzer cargo gix-revwalk 0.31.0 queue/impl#[`PriorityQueue<K, T>`]insert().(timestamp, id); |
| 28 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().mark.containsrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]contains().(Flagsrust-analyzer cargo gix-negotiate 0.31.0 Flags#::COMMONrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]COMMON.) { |
| 29 | self.non_common_revsrust-analyzer cargo gix-negotiate 0.31.0 skipping/Algorithm#non_common_revs. 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; |
| 30 | } |
| 31 | } |
| 32 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 33 | } |
| 34 | |
| 35 | fn mark_commonrust-analyzer cargo gix-negotiate 0.31.0 skipping/impl#[Algorithm]mark_common().(&mut self, id: ObjectIdrust-analyzer cargo gix-hash 0.25.0 object_id/ObjectId#, graph: &mut craterust-analyzer cargo gix-negotiate 0.31.0 crate/::Graphrust-analyzer cargo gix-negotiate 0.31.0 Graph#<'_, '_>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo gix-negotiate 0.31.0 Error#> { |
| 36 | let mut is_common = false; |
| 37 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(commit) = graph |
| 38 | .get_or_insert_commitrust-analyzer cargo gix-revwalk 0.31.0 graph/impl#[`Graph<'_, '_, Commit<T>>`]get_or_insert_commit().(id, |entry| { |
| 39 | is_common = entry.flagsrust-analyzer cargo gix-negotiate 0.31.0 Metadata#flags..containsrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]contains().(Flagsrust-analyzer cargo gix-negotiate 0.31.0 Flags#::COMMONrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]COMMON.); |
| 40 | entry.flagsrust-analyzer cargo gix-negotiate 0.31.0 Metadata#flags. rust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags][`BitOrAssign<Self>`]bitor_assign().|=rust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags][`BitOrAssign<Self>`]bitor_assign(). rust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags][`BitOrAssign<Self>`]bitor_assign().Flagsrust-analyzer cargo gix-negotiate 0.31.0 Flags#::COMMONrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]COMMON.; |
| 41 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 42 | .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]filter().(|_| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_common) |
| 43 | { |
| 44 | let mut queue = gix_revwalkrust-analyzer cargo gix-revwalk 0.31.0 crate/::PriorityQueuerust-analyzer cargo gix-revwalk 0.31.0 PriorityQueue#::from_iterrust-analyzer cargo gix-revwalk 0.31.0 queue/impl#[`PriorityQueue<K, T>`][`FromIterator<(K, T)>`]from_iter().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((commit.commit_timerust-analyzer cargo gix-revwalk 0.31.0 graph/Commit#commit_time., id))); |
| 45 | while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(id) = queue.pop_valuerust-analyzer cargo gix-revwalk 0.31.0 queue/impl#[`PriorityQueue<K, T>`]pop_value().() { |
| 46 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(commit) = graph.get_or_insert_commitrust-analyzer cargo gix-revwalk 0.31.0 graph/impl#[`Graph<'_, '_, Commit<T>>`]get_or_insert_commit().(id, |entry| { |
| 47 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().entry.flagsrust-analyzer cargo gix-negotiate 0.31.0 Metadata#flags..containsrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]contains().(Flagsrust-analyzer cargo gix-negotiate 0.31.0 Flags#::POPPEDrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]POPPED.) { |
| 48 | self.non_common_revsrust-analyzer cargo gix-negotiate 0.31.0 skipping/Algorithm#non_common_revs. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().1; |
| 49 | } |
| 50 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). { |
| 51 | for parent_id in commit.parentsrust-analyzer cargo gix-revwalk 0.31.0 graph/Commit#parents..clonerust-analyzer cargo smallvec 1.15.1 impl#[`SmallVec<A>`][Clone]clone().() { |
| 52 | // This is a bit of a problem as there is no representation of the `parsed` based skip. However, |
| 53 | // We assume that parents that aren't in the graph yet haven't been seen, and that's all we need. |
| 54 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().graph.containsrust-analyzer cargo gix-revwalk 0.31.0 graph/impl#[`Graph<'_, 'cache, T>`]contains().(&parent_id) { |
| 55 | continue; |
| 56 | } |
| 57 | let mut was_unseen_or_common = false; |
| 58 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(parent) = graph |
| 59 | .get_or_insert_commitrust-analyzer cargo gix-revwalk 0.31.0 graph/impl#[`Graph<'_, '_, Commit<T>>`]get_or_insert_commit().(parent_id, |entry| { |
| 60 | was_unseen_or_common = |
| 61 | !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().entry.flagsrust-analyzer cargo gix-negotiate 0.31.0 Metadata#flags..containsrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]contains().(Flagsrust-analyzer cargo gix-negotiate 0.31.0 Flags#::SEENrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]SEEN.) || entry.flagsrust-analyzer cargo gix-negotiate 0.31.0 Metadata#flags..containsrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]contains().(Flagsrust-analyzer cargo gix-negotiate 0.31.0 Flags#::COMMONrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]COMMON.); |
| 62 | entry.flagsrust-analyzer cargo gix-negotiate 0.31.0 Metadata#flags. rust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags][`BitOrAssign<Self>`]bitor_assign().|=rust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags][`BitOrAssign<Self>`]bitor_assign(). rust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags][`BitOrAssign<Self>`]bitor_assign().Flagsrust-analyzer cargo gix-negotiate 0.31.0 Flags#::COMMONrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]COMMON.; |
| 63 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 64 | .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]filter().(|_| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().was_unseen_or_common) |
| 65 | { |
| 66 | queue.insertrust-analyzer cargo gix-revwalk 0.31.0 queue/impl#[`PriorityQueue<K, T>`]insert().(parent.commit_timerust-analyzer cargo gix-revwalk 0.31.0 graph/Commit#commit_time., parent_id); |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 73 | } |
| 74 | |
| 75 | fn push_parentrust-analyzer cargo gix-negotiate 0.31.0 skipping/impl#[Algorithm]push_parent().( |
| 76 | &mut self, |
| 77 | entry: Metadatarust-analyzer cargo gix-negotiate 0.31.0 Metadata#, |
| 78 | parent_id: ObjectIdrust-analyzer cargo gix-hash 0.25.0 object_id/ObjectId#, |
| 79 | graph: &mut craterust-analyzer cargo gix-negotiate 0.31.0 crate/::Graphrust-analyzer cargo gix-negotiate 0.31.0 Graph#<'_, '_>, |
| 80 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<bool, Errorrust-analyzer cargo gix-negotiate 0.31.0 Error#> { |
| 81 | let mut was_seen = false; |
| 82 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(parent) = graph |
| 83 | .getrust-analyzer cargo gix-revwalk 0.31.0 graph/impl#[`Graph<'_, 'cache, T>`]get().(&parent_id) |
| 84 | .inspectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]inspect().(|parent| { |
| 85 | was_seen = parent.datarust-analyzer cargo gix-revwalk 0.31.0 graph/Commit#data..flagsrust-analyzer cargo gix-negotiate 0.31.0 Metadata#flags..containsrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]contains().(Flagsrust-analyzer cargo gix-negotiate 0.31.0 Flags#::SEENrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]SEEN.); |
| 86 | }) |
| 87 | .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]filter().(|_| was_seen) |
| 88 | { |
| 89 | if parent.datarust-analyzer cargo gix-revwalk 0.31.0 graph/Commit#data..flagsrust-analyzer cargo gix-negotiate 0.31.0 Metadata#flags..containsrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]contains().(Flagsrust-analyzer cargo gix-negotiate 0.31.0 Flags#::POPPEDrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]POPPED.) { |
| 90 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(false); |
| 91 | } |
| 92 | } else { |
| 93 | self.add_to_queuerust-analyzer cargo gix-negotiate 0.31.0 skipping/impl#[Algorithm]add_to_queue().(parent_id, Flagsrust-analyzer cargo gix-negotiate 0.31.0 Flags#::defaultrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags][Default]default().(), graph)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 94 | } |
| 95 | if entry.flagsrust-analyzer cargo gix-negotiate 0.31.0 Metadata#flags..intersectsrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]intersects().(Flagsrust-analyzer cargo gix-negotiate 0.31.0 Flags#::COMMONrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]COMMON. rust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags][`BitOr<Self>`]bitor().|rust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags][`BitOr<Self>`]bitor(). rust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags][`BitOr<Self>`]bitor().Flagsrust-analyzer cargo gix-negotiate 0.31.0 Flags#::ADVERTISEDrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]ADVERTISED.) { |
| 96 | self.mark_commonrust-analyzer cargo gix-negotiate 0.31.0 skipping/impl#[Algorithm]mark_common().(parent_id, graph)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 97 | } else { |
| 98 | let new_original_ttl = if entry.ttlrust-analyzer cargo gix-negotiate 0.31.0 Metadata#ttl. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]gt().0 { |
| 99 | entry.original_ttlrust-analyzer cargo gix-negotiate 0.31.0 Metadata#original_ttl. |
| 100 | } else { |
| 101 | entry.original_ttlrust-analyzer cargo gix-negotiate 0.31.0 Metadata#original_ttl. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Mul<Self>`]mul().3 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Div<Self>`]div().2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().1 |
| 102 | }; |
| 103 | let new_ttl = if entry.ttlrust-analyzer cargo gix-negotiate 0.31.0 Metadata#ttl. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]gt().0 { entry.ttlrust-analyzer cargo gix-negotiate 0.31.0 Metadata#ttl. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub().1 } else { new_original_ttl }; |
| 104 | let parent = graph.get_mutrust-analyzer cargo gix-revwalk 0.31.0 graph/impl#[`Graph<'_, 'cache, T>`]get_mut().(&parent_id).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("present or inserted"); |
| 105 | if parent.datarust-analyzer cargo gix-revwalk 0.31.0 graph/Commit#data..original_ttlrust-analyzer cargo gix-negotiate 0.31.0 Metadata#original_ttl. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]lt().new_original_ttl { |
| 106 | parent.datarust-analyzer cargo gix-revwalk 0.31.0 graph/Commit#data..original_ttlrust-analyzer cargo gix-negotiate 0.31.0 Metadata#original_ttl. = new_original_ttl; |
| 107 | parent.datarust-analyzer cargo gix-revwalk 0.31.0 graph/Commit#data..ttlrust-analyzer cargo gix-negotiate 0.31.0 Metadata#ttl. = new_ttl; |
| 108 | } |
| 109 | } |
| 110 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(true) |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | impl Negotiatorrust-analyzer cargo gix-negotiate 0.31.0 Negotiator# for Algorithmrust-analyzer cargo gix-negotiate 0.31.0 skipping/Algorithm# { |
| 115 | fn known_commonrust-analyzer cargo gix-negotiate 0.31.0 skipping/impl#[Algorithm][Negotiator]known_common().(&mut self, id: ObjectIdrust-analyzer cargo gix-hash 0.25.0 object_id/ObjectId#, graph: &mut craterust-analyzer cargo gix-negotiate 0.31.0 crate/::Graphrust-analyzer cargo gix-negotiate 0.31.0 Graph#<'_, '_>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo gix-negotiate 0.31.0 Error#> { |
| 116 | if graph |
| 117 | .getrust-analyzer cargo gix-revwalk 0.31.0 graph/impl#[`Graph<'_, 'cache, T>`]get().(&id) |
| 118 | .is_some_andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some_and().(|commit| commit.datarust-analyzer cargo gix-revwalk 0.31.0 graph/Commit#data..flagsrust-analyzer cargo gix-negotiate 0.31.0 Metadata#flags..containsrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]contains().(Flagsrust-analyzer cargo gix-negotiate 0.31.0 Flags#::SEENrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]SEEN.)) |
| 119 | { |
| 120 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()); |
| 121 | } |
| 122 | self.add_to_queuerust-analyzer cargo gix-negotiate 0.31.0 skipping/impl#[Algorithm]add_to_queue().(id, Flagsrust-analyzer cargo gix-negotiate 0.31.0 Flags#::ADVERTISEDrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]ADVERTISED., graph) |
| 123 | } |
| 124 | |
| 125 | fn add_tiprust-analyzer cargo gix-negotiate 0.31.0 skipping/impl#[Algorithm][Negotiator]add_tip().(&mut self, id: ObjectIdrust-analyzer cargo gix-hash 0.25.0 object_id/ObjectId#, graph: &mut craterust-analyzer cargo gix-negotiate 0.31.0 crate/::Graphrust-analyzer cargo gix-negotiate 0.31.0 Graph#<'_, '_>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo gix-negotiate 0.31.0 Error#> { |
| 126 | if graph |
| 127 | .getrust-analyzer cargo gix-revwalk 0.31.0 graph/impl#[`Graph<'_, 'cache, T>`]get().(&id) |
| 128 | .is_some_andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some_and().(|commit| commit.datarust-analyzer cargo gix-revwalk 0.31.0 graph/Commit#data..flagsrust-analyzer cargo gix-negotiate 0.31.0 Metadata#flags..containsrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]contains().(Flagsrust-analyzer cargo gix-negotiate 0.31.0 Flags#::SEENrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]SEEN.)) |
| 129 | { |
| 130 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()); |
| 131 | } |
| 132 | self.add_to_queuerust-analyzer cargo gix-negotiate 0.31.0 skipping/impl#[Algorithm]add_to_queue().(id, Flagsrust-analyzer cargo gix-negotiate 0.31.0 Flags#::defaultrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags][Default]default().(), graph) |
| 133 | } |
| 134 | |
| 135 | fn next_haverust-analyzer cargo gix-negotiate 0.31.0 skipping/impl#[Algorithm][Negotiator]next_have().(&mut self, graph: &mut craterust-analyzer cargo gix-negotiate 0.31.0 crate/::Graphrust-analyzer cargo gix-negotiate 0.31.0 Graph#<'_, '_>) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<ObjectIdrust-analyzer cargo gix-hash 0.25.0 object_id/ObjectId#, Errorrust-analyzer cargo gix-negotiate 0.31.0 Error#>> { |
| 136 | loop { |
| 137 | let id = self.revsrust-analyzer cargo gix-negotiate 0.31.0 skipping/Algorithm#revs..pop_valuerust-analyzer cargo gix-revwalk 0.31.0 queue/impl#[`PriorityQueue<K, T>`]pop_value().().filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]filter().(|_| self.non_common_revsrust-analyzer cargo gix-negotiate 0.31.0 skipping/Algorithm#non_common_revs. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().0)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().; |
| 138 | let commit = graph.get_mutrust-analyzer cargo gix-revwalk 0.31.0 graph/impl#[`Graph<'_, 'cache, T>`]get_mut().(&id).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("it was added to the graph by now"); |
| 139 | commit.datarust-analyzer cargo gix-revwalk 0.31.0 graph/Commit#data..flagsrust-analyzer cargo gix-negotiate 0.31.0 Metadata#flags. rust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags][`BitOrAssign<Self>`]bitor_assign().|=rust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags][`BitOrAssign<Self>`]bitor_assign(). rust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags][`BitOrAssign<Self>`]bitor_assign().Flagsrust-analyzer cargo gix-negotiate 0.31.0 Flags#::POPPEDrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]POPPED.; |
| 140 | |
| 141 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().commit.datarust-analyzer cargo gix-revwalk 0.31.0 graph/Commit#data..flagsrust-analyzer cargo gix-negotiate 0.31.0 Metadata#flags..containsrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]contains().(Flagsrust-analyzer cargo gix-negotiate 0.31.0 Flags#::COMMONrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]COMMON.) { |
| 142 | self.non_common_revsrust-analyzer cargo gix-negotiate 0.31.0 skipping/Algorithm#non_common_revs. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().1; |
| 143 | } |
| 144 | let mut to_send = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 145 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().commit.datarust-analyzer cargo gix-revwalk 0.31.0 graph/Commit#data..flagsrust-analyzer cargo gix-negotiate 0.31.0 Metadata#flags..containsrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]contains().(Flagsrust-analyzer cargo gix-negotiate 0.31.0 Flags#::COMMONrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]COMMON.) && commit.datarust-analyzer cargo gix-revwalk 0.31.0 graph/Commit#data..ttlrust-analyzer cargo gix-negotiate 0.31.0 Metadata#ttl. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().0 { |
| 146 | to_send = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(id); |
| 147 | } |
| 148 | |
| 149 | let data = commit.datarust-analyzer cargo gix-revwalk 0.31.0 graph/Commit#data.; |
| 150 | let mut parent_pushed = false; |
| 151 | for parent_id in commit.parentsrust-analyzer cargo gix-revwalk 0.31.0 graph/Commit#parents..clonerust-analyzer cargo smallvec 1.15.1 impl#[`SmallVec<A>`][Clone]clone().() { |
| 152 | parent_pushed rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][`BitOrAssign<Self>`]bitor_assign().|=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][`BitOrAssign<Self>`]bitor_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][`BitOrAssign<Self>`]bitor_assign().match self.push_parentrust-analyzer cargo gix-negotiate 0.31.0 skipping/impl#[Algorithm]push_parent().(data, parent_id, graph) { |
| 153 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(r) => r, |
| 154 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err)), |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().data.flagsrust-analyzer cargo gix-negotiate 0.31.0 Metadata#flags..containsrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]contains().(Flagsrust-analyzer cargo gix-negotiate 0.31.0 Flags#::COMMONrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]COMMON.) && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().parent_pushed { |
| 159 | to_send = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(id); |
| 160 | } |
| 161 | |
| 162 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(to_send) = to_send { |
| 163 | return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(to_send)); |
| 164 | } |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | fn in_common_with_remoterust-analyzer cargo gix-negotiate 0.31.0 skipping/impl#[Algorithm][Negotiator]in_common_with_remote().(&mut self, id: ObjectIdrust-analyzer cargo gix-hash 0.25.0 object_id/ObjectId#, graph: &mut craterust-analyzer cargo gix-negotiate 0.31.0 crate/::Graphrust-analyzer cargo gix-negotiate 0.31.0 Graph#<'_, '_>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<bool, Errorrust-analyzer cargo gix-negotiate 0.31.0 Error#> { |
| 169 | let mut was_seen = false; |
| 170 | let known_to_be_common = graph.getrust-analyzer cargo gix-revwalk 0.31.0 graph/impl#[`Graph<'_, 'cache, T>`]get().(&id).is_some_andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some_and().(|commit| { |
| 171 | was_seen = commit.datarust-analyzer cargo gix-revwalk 0.31.0 graph/Commit#data..flagsrust-analyzer cargo gix-negotiate 0.31.0 Metadata#flags..containsrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]contains().(Flagsrust-analyzer cargo gix-negotiate 0.31.0 Flags#::SEENrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]SEEN.); |
| 172 | commit.datarust-analyzer cargo gix-revwalk 0.31.0 graph/Commit#data..flagsrust-analyzer cargo gix-negotiate 0.31.0 Metadata#flags..containsrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]contains().(Flagsrust-analyzer cargo gix-negotiate 0.31.0 Flags#::COMMONrust-analyzer cargo gix-negotiate 0.31.0 impl#[Flags]COMMON.) |
| 173 | }); |
| 174 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!( |
| 175 | was_seen, |
| 176 | "Cannot receive ACK for commit we didn't send a HAVE for: {id}" |
| 177 | ); |
| 178 | self.mark_commonrust-analyzer cargo gix-negotiate 0.31.0 skipping/impl#[Algorithm]mark_common().(id, graph)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 179 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(known_to_be_common) |
| 180 | } |
| 181 | } |