Skip to content

Commit

Permalink
mononoke_api: gate using commit graph alternative to hash_to_location…
Browse files Browse the repository at this point in the history
… behind a JK

Summary: Gate using commit graph based location_to_hash behind a JK to enable rolling it out.

Reviewed By: markbt

Differential Revision: D52153234

fbshipit-source-id: ca73498fc18a151aac66c19778a7d5661b2f4935
  • Loading branch information
YousefSalama authored and facebook-github-bot committed Dec 14, 2023
1 parent 796887d commit d90dc55
Showing 1 changed file with 39 additions and 11 deletions.
50 changes: 39 additions & 11 deletions eden/mononoke/mononoke_api/src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1713,17 +1713,45 @@ impl RepoContext {
cs_ids: Vec<ChangesetId>,
) -> Result<HashMap<ChangesetId, Result<Location<ChangesetId>, MononokeError>>, MononokeError>
{
let segmented_changelog = self.repo.segmented_changelog();
let result = segmented_changelog
.many_changeset_ids_to_locations(&self.ctx, master_heads, cs_ids)
.await
.map(|ok| {
ok.into_iter()
.map(|(k, v)| (k, v.map_err(Into::into)))
.collect::<HashMap<ChangesetId, Result<_, MononokeError>>>()
})
.map_err(MononokeError::from)?;
Ok(result)
let use_commit_graph = justknobs::eval(
"scm/mononoke:commit_graph_hash_to_location",
None,
Some(self.name()),
)
.unwrap_or_default();

match use_commit_graph {
true => Ok(self
.repo()
.commit_graph()
.changeset_ids_to_locations(self.ctx(), master_heads, cs_ids)
.await
.map(|ok| {
ok.into_iter()
.map(|(k, v)| {
(
k,
Ok(Location {
descendant: v.cs_id,
distance: v.distance,
}),
)
})
.collect::<HashMap<ChangesetId, Result<_, MononokeError>>>()
})
.map_err(MononokeError::from)?),
false => Ok(self
.repo()
.segmented_changelog()
.many_changeset_ids_to_locations(&self.ctx, master_heads, cs_ids)
.await
.map(|ok| {
ok.into_iter()
.map(|(k, v)| (k, v.map_err(Into::into)))
.collect::<HashMap<ChangesetId, Result<_, MononokeError>>>()
})
.map_err(MononokeError::from)?),
}
}

pub async fn segmented_changelog_clone_data(
Expand Down

0 comments on commit d90dc55

Please sign in to comment.