mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 23:38:50 +03:00
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:
parent
acea2fdd21
commit
abc4d31e2d
@ -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); })
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user