mirror of
https://github.com/facebook/sapling.git
synced 2024-10-08 07:49:11 +03:00
e6135bbf0a
Summary: The `ObjectFetchContext::Origin::FromBackingStore` is widely interpreted as meaning that a network fetch was performed, but for some backing stores, this isn't true. The Mercurial backing store for instance can either read data from its on-disk cache, or from the network. Since both have very different characteristics we shouldn't bundle them in the same enum value. Since the backing store knows how data was obtained, let's have the backing store return how it was obtained to enable the ObjectStore to properly record this information. The `FromBackingStore` is also renamed to make it clearer what its purpose is. Reviewed By: zhengchaol Differential Revision: D31118906 fbshipit-source-id: ee42a0c9d221f870742de07c0df7c732bc79d880
56 lines
1.5 KiB
C++
56 lines
1.5 KiB
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This software may be used and distributed according to the terms of the
|
|
* GNU General Public License version 2.
|
|
*/
|
|
|
|
#include "eden/fs/store/EmptyBackingStore.h"
|
|
|
|
#include <folly/futures/Future.h>
|
|
#include "eden/fs/model/Blob.h"
|
|
#include "eden/fs/model/Hash.h"
|
|
#include "eden/fs/model/Tree.h"
|
|
#include "eden/fs/store/ObjectFetchContext.h"
|
|
|
|
using folly::makeSemiFuture;
|
|
using folly::SemiFuture;
|
|
using std::unique_ptr;
|
|
|
|
namespace facebook::eden {
|
|
|
|
EmptyBackingStore::EmptyBackingStore() {}
|
|
|
|
EmptyBackingStore::~EmptyBackingStore() {}
|
|
|
|
RootId EmptyBackingStore::parseRootId(folly::StringPiece /*rootId*/) {
|
|
throw std::domain_error("empty backing store");
|
|
}
|
|
|
|
std::string EmptyBackingStore::renderRootId(const RootId& /*rootId*/) {
|
|
throw std::domain_error("empty backing store");
|
|
}
|
|
|
|
SemiFuture<unique_ptr<Tree>> EmptyBackingStore::getRootTree(
|
|
const RootId& /* rootId */,
|
|
ObjectFetchContext& /* context */) {
|
|
return makeSemiFuture<unique_ptr<Tree>>(
|
|
std::domain_error("empty backing store"));
|
|
}
|
|
|
|
SemiFuture<BackingStore::GetTreeRes> EmptyBackingStore::getTree(
|
|
const Hash& /* id */,
|
|
ObjectFetchContext& /* context */) {
|
|
return makeSemiFuture<BackingStore::GetTreeRes>(
|
|
std::domain_error("empty backing store"));
|
|
}
|
|
|
|
SemiFuture<BackingStore::GetBlobRes> EmptyBackingStore::getBlob(
|
|
const Hash& /* id */,
|
|
ObjectFetchContext& /* context */) {
|
|
return makeSemiFuture<BackingStore::GetBlobRes>(
|
|
std::domain_error("empty backing store"));
|
|
}
|
|
|
|
} // namespace facebook::eden
|