From 592e6961469bc625f4701fa25fb4f7740bdecfea Mon Sep 17 00:00:00 2001 From: Mateusz Kwapich Date: Mon, 15 Jun 2020 02:53:40 -0700 Subject: [PATCH] remove one of ancestry check implementations Summary: I'm not sure why but D14405696 added this `is_ancestor` method with a duplicate ancestry check implementation which: * has different behaviour when `ancestor == descendant` * doesn't log to ODS Let's just settle on using one implementation now. Reviewed By: StanislavGlebik Differential Revision: D21937312 fbshipit-source-id: 0f4e2390cb0b984f92cd4fe645d9313fa4bba70e --- .../reachabilityindex/skiplist/src/lib.rs | 36 +++---------------- 1 file changed, 5 insertions(+), 31 deletions(-) diff --git a/eden/mononoke/reachabilityindex/skiplist/src/lib.rs b/eden/mononoke/reachabilityindex/skiplist/src/lib.rs index 17d146a7ba..db05e82309 100644 --- a/eden/mononoke/reachabilityindex/skiplist/src/lib.rs +++ b/eden/mononoke/reachabilityindex/skiplist/src/lib.rs @@ -679,37 +679,11 @@ impl LeastCommonAncestorsHint for SkiplistIndex { ancestor: ChangesetId, descendant: ChangesetId, ) -> BoxFuture { - let anc_with_gen = changeset_fetcher - .get_generation_number(ctx.clone(), ancestor) - .map(move |gen| (ancestor, gen)); - let desc_with_gen = changeset_fetcher - .get_generation_number(ctx.clone(), descendant) - .map(move |gen| (descendant, gen)); - - anc_with_gen - .join(desc_with_gen) - .and_then({ - let this = self.clone(); - move |(anc, desc)| { - if anc.1 >= desc.1 { - Ok(false).into_future().boxify() - } else { - let mut frontier = NodeFrontier::default(); - frontier.insert(desc); - this.lca_hint(ctx.clone(), changeset_fetcher, frontier, anc.1) - .map(move |res| { - // If "ancestor" is an ancestor of "descendant" lca_hint will return - // a node frontier that contains "ancestor". - match res.get_all_changesets_for_gen_num(anc.1) { - Some(generation_set) if generation_set.contains(&anc.0) => true, - _ => false, - } - }) - .boxify() - } - } - }) - .boxify() + if ancestor == descendant { + Ok(false).into_future().boxify() + } else { + self.query_reachability(ctx, changeset_fetcher, descendant, ancestor) + } } }