mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 08:18:15 +03:00
remove the dead getTreeForManifest
Summary: getTreeForManifest is no longer called, so remove it. Reviewed By: genevievehelsel Differential Revision: D28306796 fbshipit-source-id: e51a32fa7d75c54b2e3525e88c162247b4496560
This commit is contained in:
parent
df340221a0
commit
d45b2711a2
@ -49,10 +49,6 @@ class BackingStore {
|
||||
virtual folly::SemiFuture<std::unique_ptr<Tree>> getTreeForCommit(
|
||||
const Hash& commitID,
|
||||
ObjectFetchContext& context) = 0;
|
||||
virtual folly::SemiFuture<std::unique_ptr<Tree>> getTreeForManifest(
|
||||
const Hash& commitID,
|
||||
const Hash& manifestID,
|
||||
ObjectFetchContext& context) = 0;
|
||||
FOLLY_NODISCARD virtual folly::SemiFuture<folly::Unit> prefetchBlobs(
|
||||
const std::vector<Hash>& /*ids*/,
|
||||
ObjectFetchContext& /*context*/) {
|
||||
|
@ -45,12 +45,5 @@ SemiFuture<unique_ptr<Tree>> EmptyBackingStore::getTreeForCommit(
|
||||
std::domain_error("empty backing store"));
|
||||
}
|
||||
|
||||
SemiFuture<std::unique_ptr<Tree>> EmptyBackingStore::getTreeForManifest(
|
||||
const Hash& /* commitID */,
|
||||
const Hash& /* manifestID */,
|
||||
ObjectFetchContext& /* context */) {
|
||||
return makeSemiFuture<unique_ptr<Tree>>(
|
||||
std::domain_error("empty backing store"));
|
||||
}
|
||||
} // namespace eden
|
||||
} // namespace facebook
|
||||
|
@ -31,10 +31,6 @@ class EmptyBackingStore : public BackingStore {
|
||||
folly::SemiFuture<std::unique_ptr<Tree>> getTreeForCommit(
|
||||
const Hash& commitID,
|
||||
ObjectFetchContext& context) override;
|
||||
folly::SemiFuture<std::unique_ptr<Tree>> getTreeForManifest(
|
||||
const Hash& commitID,
|
||||
const Hash& manifestID,
|
||||
ObjectFetchContext& context) override;
|
||||
};
|
||||
} // namespace eden
|
||||
} // namespace facebook
|
||||
|
@ -49,10 +49,6 @@ class IObjectStore {
|
||||
virtual folly::Future<std::shared_ptr<const Tree>> getTreeForCommit(
|
||||
const Hash& commitID,
|
||||
ObjectFetchContext& context) const = 0;
|
||||
virtual folly::Future<std::shared_ptr<const Tree>> getTreeForManifest(
|
||||
const Hash& commitID,
|
||||
const Hash& manifestID,
|
||||
ObjectFetchContext& context) const = 0;
|
||||
virtual folly::Future<folly::Unit> prefetchBlobs(
|
||||
const std::vector<Hash>& ids,
|
||||
ObjectFetchContext& context) const = 0;
|
||||
|
@ -201,33 +201,6 @@ Future<shared_ptr<const Tree>> ObjectStore::getTreeForCommit(
|
||||
});
|
||||
}
|
||||
|
||||
Future<shared_ptr<const Tree>> ObjectStore::getTreeForManifest(
|
||||
const Hash& commitID,
|
||||
const Hash& manifestID,
|
||||
ObjectFetchContext& context) const {
|
||||
XLOG(DBG3) << "getTreeForManifest(" << commitID << ", " << manifestID << ")";
|
||||
|
||||
return backingStore_->getTreeForManifest(commitID, manifestID, context)
|
||||
.via(executor_)
|
||||
.thenValue([treeCache = treeCache_,
|
||||
commitID,
|
||||
manifestID,
|
||||
localStore = localStore_,
|
||||
edenConfig = edenConfig_](std::shared_ptr<const Tree> tree) {
|
||||
if (!tree) {
|
||||
throw std::domain_error(folly::to<string>(
|
||||
"unable to import commit ",
|
||||
commitID.toString(),
|
||||
" with manifest node ",
|
||||
manifestID.toString()));
|
||||
}
|
||||
|
||||
localStore->putTree(tree.get());
|
||||
treeCache->insert(tree);
|
||||
return tree;
|
||||
});
|
||||
}
|
||||
|
||||
folly::Future<folly::Unit> ObjectStore::prefetchBlobs(
|
||||
const std::vector<Hash>& ids,
|
||||
ObjectFetchContext& fetchContext) const {
|
||||
|
@ -130,11 +130,6 @@ class ObjectStore : public IObjectStore,
|
||||
const Hash& commitID,
|
||||
ObjectFetchContext& context) const override;
|
||||
|
||||
folly::Future<std::shared_ptr<const Tree>> getTreeForManifest(
|
||||
const Hash& commitID,
|
||||
const Hash& manifestID,
|
||||
ObjectFetchContext& context) const override;
|
||||
|
||||
folly::Future<folly::Unit> prefetchBlobs(
|
||||
const std::vector<Hash>& ids,
|
||||
ObjectFetchContext& context) const override;
|
||||
|
@ -192,13 +192,6 @@ SemiFuture<unique_ptr<Tree>> GitBackingStore::getTreeForCommit(
|
||||
});
|
||||
}
|
||||
|
||||
SemiFuture<std::unique_ptr<Tree>> GitBackingStore::getTreeForManifest(
|
||||
const Hash& commitID,
|
||||
const Hash& /* manifestID */,
|
||||
ObjectFetchContext& context) {
|
||||
return getTreeForCommit(commitID, context);
|
||||
}
|
||||
|
||||
git_oid GitBackingStore::hash2Oid(const Hash& hash) {
|
||||
git_oid oid;
|
||||
static_assert(
|
||||
|
@ -53,10 +53,6 @@ class GitBackingStore : public BackingStore {
|
||||
folly::SemiFuture<std::unique_ptr<Tree>> getTreeForCommit(
|
||||
const Hash& commitID,
|
||||
ObjectFetchContext& context) override;
|
||||
folly::SemiFuture<std::unique_ptr<Tree>> getTreeForManifest(
|
||||
const Hash& commitID,
|
||||
const Hash& manifestID,
|
||||
ObjectFetchContext& context) override;
|
||||
|
||||
private:
|
||||
GitBackingStore(GitBackingStore const&) = delete;
|
||||
|
@ -631,17 +631,6 @@ SemiFuture<unique_ptr<Tree>> HgBackingStore::getTreeForCommit(
|
||||
});
|
||||
}
|
||||
|
||||
folly::SemiFuture<unique_ptr<Tree>> HgBackingStore::getTreeForManifest(
|
||||
const Hash& commitID,
|
||||
const Hash& manifestID,
|
||||
bool prefetchMetadata) {
|
||||
// Construct the edenTreeID to pass to localStore lookup
|
||||
auto rootTreeHash =
|
||||
HgProxyHash::prepareToStore(RelativePathPiece{}, manifestID).first;
|
||||
return getTreeForRootTreeImpl(commitID, rootTreeHash, prefetchMetadata)
|
||||
.via(serverThreadPool_);
|
||||
}
|
||||
|
||||
folly::Future<unique_ptr<Tree>> HgBackingStore::getTreeForRootTreeImpl(
|
||||
const Hash& commitID,
|
||||
const Hash& rootTreeHash,
|
||||
|
@ -81,10 +81,6 @@ class HgBackingStore {
|
||||
folly::SemiFuture<std::unique_ptr<Tree>> getTreeForCommit(
|
||||
const Hash& commitID,
|
||||
bool prefetchMetadata);
|
||||
folly::SemiFuture<std::unique_ptr<Tree>> getTreeForManifest(
|
||||
const Hash& commitID,
|
||||
const Hash& manifestID,
|
||||
bool prefetchMetadata);
|
||||
FOLLY_NODISCARD folly::SemiFuture<folly::Unit> prefetchBlobs(
|
||||
std::vector<HgProxyHash> ids,
|
||||
ObjectFetchContext& context);
|
||||
|
@ -335,15 +335,6 @@ folly::SemiFuture<std::unique_ptr<Tree>> HgQueuedBackingStore::getTreeForCommit(
|
||||
return backingStore_->getTreeForCommit(commitID, context.prefetchMetadata());
|
||||
}
|
||||
|
||||
folly::SemiFuture<std::unique_ptr<Tree>>
|
||||
HgQueuedBackingStore::getTreeForManifest(
|
||||
const Hash& commitID,
|
||||
const Hash& manifestID,
|
||||
ObjectFetchContext& context) {
|
||||
return backingStore_->getTreeForManifest(
|
||||
commitID, manifestID, context.prefetchMetadata());
|
||||
}
|
||||
|
||||
folly::SemiFuture<folly::Unit> HgQueuedBackingStore::prefetchBlobs(
|
||||
const std::vector<Hash>& ids,
|
||||
ObjectFetchContext& context) {
|
||||
|
@ -123,10 +123,6 @@ class HgQueuedBackingStore : public BackingStore {
|
||||
folly::SemiFuture<std::unique_ptr<Tree>> getTreeForCommit(
|
||||
const Hash& commitID,
|
||||
ObjectFetchContext& context) override;
|
||||
folly::SemiFuture<std::unique_ptr<Tree>> getTreeForManifest(
|
||||
const Hash& commitID,
|
||||
const Hash& manifestID,
|
||||
ObjectFetchContext& context) override;
|
||||
|
||||
FOLLY_NODISCARD virtual folly::SemiFuture<folly::Unit> prefetchBlobs(
|
||||
const std::vector<Hash>& ids,
|
||||
|
@ -152,18 +152,6 @@ TEST_F(
|
||||
::testing::ElementsAre(PathComponent{"foo"}, PathComponent{"src"}));
|
||||
}
|
||||
|
||||
TEST_F(HgBackingStoreTest, getTreeForManifest) {
|
||||
auto tree1 =
|
||||
objectStore
|
||||
->getTreeForCommit(commit1, ObjectFetchContext::getNullContext())
|
||||
.get(0ms);
|
||||
auto tree2 = objectStore
|
||||
->getTreeForManifest(
|
||||
commit1, manifest1, ObjectFetchContext::getNullContext())
|
||||
.get(0ms);
|
||||
EXPECT_EQ(tree1->getHash(), tree2->getHash());
|
||||
}
|
||||
|
||||
TEST_F(HgBackingStoreTest, skipMetadataPrefetch) {
|
||||
auto metadataImporter = dynamic_cast<TestMetadataImporter*>(
|
||||
&(backingStore->getHgBackingStore().getMetadataImporter()));
|
||||
|
@ -40,12 +40,6 @@ folly::SemiFuture<std::unique_ptr<Tree>> ReCasBackingStore::getTreeForCommit(
|
||||
ObjectFetchContext& /** context **/) {
|
||||
throw std::domain_error("unimplemented");
|
||||
};
|
||||
folly::SemiFuture<std::unique_ptr<Tree>> ReCasBackingStore::getTreeForManifest(
|
||||
const Hash& /** commitID **/,
|
||||
const Hash& /** manifestID **/,
|
||||
ObjectFetchContext& /** context **/) {
|
||||
throw std::domain_error("unimplemented");
|
||||
};
|
||||
|
||||
} // namespace eden
|
||||
} // namespace facebook
|
||||
|
@ -29,10 +29,6 @@ class ReCasBackingStore : public BackingStore {
|
||||
folly::SemiFuture<std::unique_ptr<Tree>> getTreeForCommit(
|
||||
const Hash& commitID,
|
||||
ObjectFetchContext& context) override;
|
||||
folly::SemiFuture<std::unique_ptr<Tree>> getTreeForManifest(
|
||||
const Hash& commitID,
|
||||
const Hash& manifestID,
|
||||
ObjectFetchContext& context) override;
|
||||
|
||||
private:
|
||||
// Forbidden copy constructor and assignment operator
|
||||
|
@ -57,14 +57,3 @@ TEST_F(ReCasBackingStoreTest, getTreeForCommit) {
|
||||
.get(kTestTimeout),
|
||||
std::domain_error);
|
||||
}
|
||||
|
||||
TEST_F(ReCasBackingStoreTest, getTreeForManifest) {
|
||||
auto reCasStore = makeReCasBackingStore();
|
||||
EXPECT_THROW(
|
||||
reCasStore
|
||||
->getTreeForManifest(
|
||||
id, manifest, ObjectFetchContext::getNullContext())
|
||||
.via(&folly::QueuedImmediateExecutor::instance())
|
||||
.get(kTestTimeout),
|
||||
std::domain_error);
|
||||
}
|
||||
|
@ -48,10 +48,12 @@ class FakeBackingStore : public BackingStore {
|
||||
folly::SemiFuture<std::unique_ptr<Tree>> getTreeForCommit(
|
||||
const Hash& commitID,
|
||||
ObjectFetchContext& context) override;
|
||||
|
||||
folly::SemiFuture<std::unique_ptr<Tree>> getTreeForManifest(
|
||||
const Hash& commitID,
|
||||
const Hash& manifestID,
|
||||
ObjectFetchContext& context) override;
|
||||
ObjectFetchContext& context);
|
||||
|
||||
/**
|
||||
* Add a Blob to the backing store
|
||||
*
|
||||
|
@ -79,13 +79,6 @@ Future<shared_ptr<const Tree>> FakeObjectStore::getTreeForCommit(
|
||||
return makeFuture(make_shared<Tree>(iter->second));
|
||||
}
|
||||
|
||||
folly::Future<std::shared_ptr<const Tree>> FakeObjectStore::getTreeForManifest(
|
||||
const Hash& commitID,
|
||||
const Hash& /* manifestID */,
|
||||
ObjectFetchContext&) const {
|
||||
return getTreeForCommit(commitID);
|
||||
}
|
||||
|
||||
folly::Future<folly::Unit> FakeObjectStore::prefetchBlobs(
|
||||
const std::vector<Hash>&,
|
||||
ObjectFetchContext&) const {
|
||||
|
@ -45,11 +45,6 @@ class FakeObjectStore : public IObjectStore {
|
||||
const Hash& commitID,
|
||||
ObjectFetchContext& context =
|
||||
ObjectFetchContext::getNullContext()) const override;
|
||||
folly::Future<std::shared_ptr<const Tree>> getTreeForManifest(
|
||||
const Hash& commitID,
|
||||
const Hash& manifestID,
|
||||
ObjectFetchContext& context =
|
||||
ObjectFetchContext::getNullContext()) const override;
|
||||
folly::Future<folly::Unit> prefetchBlobs(
|
||||
const std::vector<Hash>& ids,
|
||||
ObjectFetchContext& context =
|
||||
|
@ -280,74 +280,6 @@ TEST_F(FakeBackingStoreTest, getTreeForCommit) {
|
||||
"tree .* for commit .* not found");
|
||||
}
|
||||
|
||||
TEST_F(FakeBackingStoreTest, getTreeForManifest) {
|
||||
// Set up one commit with a root tree
|
||||
auto dir1Hash = makeTestHash("abc");
|
||||
auto* dir1 = store_->putTree(dir1Hash, {{"foo", store_->putBlob("foo\n")}});
|
||||
auto hash1 = makeTestHash("1");
|
||||
auto* commit1 = store_->putCommit(hash1, dir1);
|
||||
// Set up a second commit, but don't actually add the tree object for this one
|
||||
auto hash2 = makeTestHash("2");
|
||||
auto hash3 = makeTestHash("3");
|
||||
store_->putCommit(hash2, hash3);
|
||||
|
||||
auto future1 = store_->getTreeForManifest(
|
||||
hash1, dir1Hash, ObjectFetchContext::getNullContext());
|
||||
// Since we are not looking up the commit hash, but since the tree exists, we
|
||||
// are waiting on the tree to be triggered
|
||||
EXPECT_FALSE(future1.isReady());
|
||||
|
||||
auto future2 = store_->getTreeForManifest(
|
||||
hash2, hash3, ObjectFetchContext::getNullContext());
|
||||
// Since we are not looking up the commit hash, and since the tree does not
|
||||
// exist, we are not waiting on the tree to be triggered to resolve this.
|
||||
EXPECT_TRUE(future2.isReady());
|
||||
// This should cause future2 to fail since the tree does not actually exist.
|
||||
EXPECT_THROW_RE(
|
||||
std::move(future2).get(),
|
||||
std::domain_error,
|
||||
"tree .* for commit .* not found");
|
||||
|
||||
// Trigger the tree, the first future should be ready.
|
||||
dir1->trigger();
|
||||
ASSERT_TRUE(future1.isReady());
|
||||
EXPECT_EQ(dir1Hash, std::move(future1).get()->getHash());
|
||||
|
||||
// Get another future for commit1
|
||||
auto future3 = store_->getTreeForManifest(
|
||||
hash1, dir1Hash, ObjectFetchContext::getNullContext());
|
||||
EXPECT_FALSE(future3.isReady());
|
||||
// Triggering the directory now should have an effect since we are not waiting
|
||||
// to look up the manifest id using the commit hash and are only waiting on
|
||||
// the directory
|
||||
dir1->trigger();
|
||||
EXPECT_TRUE(future3.isReady());
|
||||
EXPECT_EQ(dir1Hash, std::move(future3).get()->getHash());
|
||||
|
||||
// Try triggering errors
|
||||
auto future4 = store_->getTreeForManifest(
|
||||
hash1, dir1Hash, ObjectFetchContext::getNullContext());
|
||||
EXPECT_FALSE(future4.isReady());
|
||||
commit1->triggerError(std::runtime_error("bad luck"));
|
||||
EXPECT_FALSE(future4.isReady());
|
||||
dir1->trigger();
|
||||
EXPECT_TRUE(future4.isReady());
|
||||
// Since getTreeForManifest does not depend on the commit to get the tree, and
|
||||
// since the tree is already in the store, an error being triggered with the
|
||||
// commit will not cause getTreeForManifest to fail
|
||||
EXPECT_EQ(dir1Hash, std::move(future4).get()->getHash());
|
||||
|
||||
auto future5 = store_->getTreeForManifest(
|
||||
hash1, dir1Hash, ObjectFetchContext::getNullContext());
|
||||
EXPECT_FALSE(future5.isReady());
|
||||
commit1->trigger();
|
||||
EXPECT_FALSE(future5.isReady());
|
||||
dir1->triggerError(std::runtime_error("PC Load Letter"));
|
||||
ASSERT_TRUE(future5.isReady());
|
||||
EXPECT_THROW_RE(
|
||||
std::move(future5).get(), std::runtime_error, "PC Load Letter");
|
||||
}
|
||||
|
||||
TEST_F(FakeBackingStoreTest, maybePutBlob) {
|
||||
auto foo1 = store_->maybePutBlob("foo\n");
|
||||
EXPECT_TRUE(foo1.second);
|
||||
|
Loading…
Reference in New Issue
Block a user