mononoke: do not generate hgchangesets unnecessarily in FilenodesOnlyPublicMapping

Summary:
fetch_root_filenode is called by FilenodesOnlyPublicMapping to figure out if
filenodes were already derived. Previously it first derived hg changeset and
then fetched looked up root manifest in db. However if hg changeset is not
derived then filenodes couldn't possible be derived either and we can return an
answer faster.

This is useful in the next diff where I change walker

Reviewed By: ahornby

Differential Revision: D20068819

fbshipit-source-id: 17f066c437e0b1f7bbeb8f6e247eadc9afe94f90
This commit is contained in:
Stanislau Hlebik 2020-02-25 08:05:14 -08:00 committed by Facebook Github Bot
parent f8fcbc9723
commit 3418318883

View File

@ -360,6 +360,17 @@ async fn fetch_root_filenode(
cs_id: ChangesetId,
repo: &BlobRepo,
) -> Result<Option<RootFilenodeInfo>, Error> {
// If hg changeset is not generated, then root filenode can't possible be generated
// Check it and return None if hg changeset is not generated
let maybe_hg_cs_id = repo
.get_bonsai_hg_mapping()
.get_hg_from_bonsai(ctx.clone(), repo.get_repoid(), cs_id.clone())
.compat()
.await?;
if maybe_hg_cs_id.is_none() {
return Ok(None);
}
let mf_id = fetch_root_manifest_id(ctx, &cs_id, repo).await?;
// Special case null manifest id if we run into it