Factor duplicate importFileContents call in getBlob

Summary:
`HgBackingStore::getBlob` calls `HgImporter::importFileContents` in two different branches. The calls are identical, and have an identical comment explaining the use of `folly::SemiFuture::via`. This duplication makes it annoying to add instrumentation and other changes.

Factor each call into a new `HgBackingStore::getBlobFromHgImporter` function, deduplicating the code.

This diff should not change behavior.

Reviewed By: simpkins

Differential Revision: D15256267

fbshipit-source-id: cad0566e9dab15775ee0d711e452f3e60fa6e645
This commit is contained in:
Matt Glazar 2019-05-27 21:51:16 -07:00 committed by Facebook Github Bot
parent acea2fdd21
commit abc4d31e2d
2 changed files with 8 additions and 8 deletions

View File

@ -775,17 +775,15 @@ Future<unique_ptr<Blob>> HgBackingStore::getBlob(const Hash& id) {
<< "', " << revHash.toString()
<< " from mononoke: " << ex.what()
<< ", fall back to import helper.";
return folly::via(
importThreadPool_.get(),
[id] {
return getThreadLocalImporter().importFileContents(id);
})
// Ensure that the control moves back to the main thread pool
// to process the caller-attached .then routine.
.via(serverThreadPool_);
return getBlobFromHgImporter(id);
});
}
return getBlobFromHgImporter(id);
}
Future<std::unique_ptr<Blob>> HgBackingStore::getBlobFromHgImporter(
const Hash& id) {
return folly::via(
importThreadPool_.get(),
[id] { return getThreadLocalImporter().importFileContents(id); })

View File

@ -152,6 +152,8 @@ class HgBackingStore : public BackingStore {
initializeCurlMononokeBackingStore();
#endif
folly::Future<std::unique_ptr<Blob>> getBlobFromHgImporter(const Hash& id);
folly::Future<std::unique_ptr<Tree>> getTreeForCommitImpl(Hash commitID);
// Import the Tree from Hg and cache it in the LocalStore before returning it.