require treemanifest support

Summary: We intend to break support for flatmanifest hg, so require that treemanifest is available in the build.

Reviewed By: wez

Differential Revision: D15057150

fbshipit-source-id: 449399cfb9d018f3b722598091eead1bd5d7c77d
This commit is contained in:
Chad Austin 2019-05-02 12:27:27 -07:00 committed by Facebook Github Bot
parent 8ec4c11d3e
commit 2267e75bda
9 changed files with 8 additions and 70 deletions

View File

@ -67,8 +67,6 @@ find_package(cpptoml REQUIRED)
find_package(CURL)
set(EDEN_HAVE_CURL ${CURL_FOUND})
# We currently do not have treemanifest support in the opensource build
set(EDEN_HAVE_HG_TREEMANIFEST OFF)
set(EDEN_WIN_NO_RUST_DATAPACK ON)
set(EDEN_WIN_NOMONONOKE ON)

View File

@ -52,6 +52,6 @@ if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/fb-mercurial)
${OPENSSL_INCLUDE_DIR}
${LZ4_INCLUDE_DIR}
)
set(EDEN_HAVE_HG_TREEMANIFEST ON)
else()
message(FATAL_ERROR "fb-mercurial treemanifest support not found")
endif()

View File

@ -12,7 +12,6 @@
#define EDEN_VERSION "${PACKAGE_VERSION}"
#cmakedefine01 EDEN_HAVE_HG_TREEMANIFEST
#cmakedefine EDEN_HAVE_ROCKSDB
#cmakedefine EDEN_HAVE_SELINUX
#cmakedefine EDEN_HAVE_SQLITE3

View File

@ -5,11 +5,9 @@ add_library(
${STORE_HG_SRCS}
)
if (EDEN_HAVE_HG_TREEMANIFEST)
list(APPEND EDEN_STORE_HG_OPTIONAL_DEPS datapack)
list(APPEND EDEN_STORE_HG_OPTIONAL_DEPS eden_store_mononoke)
list(APPEND EDEN_STORE_HG_OPTIONAL_DEPS eden_config)
endif()
list(APPEND EDEN_STORE_HG_OPTIONAL_DEPS datapack)
list(APPEND EDEN_STORE_HG_OPTIONAL_DEPS eden_store_mononoke)
list(APPEND EDEN_STORE_HG_OPTIONAL_DEPS eden_config)
target_link_libraries(
eden_store_hg

View File

@ -36,13 +36,11 @@
#include "eden/fs/utils/ServiceAddress.h"
#include "eden/fs/utils/UnboundedQueueExecutor.h"
#if EDEN_HAVE_HG_TREEMANIFEST
#include "edenscm/hgext/extlib/cstore/uniondatapackstore.h" // @manual=//scm/hg:datapack
#include "edenscm/hgext/extlib/ctreemanifest/treemanifest.h" // @manual=//scm/hg:datapack
#ifndef EDEN_WIN_NO_RUST_DATAPACK
#include "scm/hg/lib/configparser/ConfigParser.h"
#endif
#endif // EDEN_HAVE_HG_TREEMANIFEST
#ifndef EDEN_WIN_NOMONONOKE
#include "eden/fs/store/mononoke/MononokeHttpBackingStore.h"
@ -77,14 +75,6 @@ DEFINE_bool(
"Set this parameter to \"no\" to disable fetching missing treemanifest "
"trees from the remote mercurial server. This is generally only useful "
"for testing/debugging purposes");
DEFINE_bool(
use_hg_tree_manifest,
// treemanifest imports are disabled by default for now.
// We currently cannot access treemanifest data for pending transactions
// when mercurial invokes dirstate.setparents(), and this breaks
// many workflows.
true,
"Import mercurial trees using treemanifest in supported repositories.");
DEFINE_int32(
mononoke_timeout,
2000, // msec
@ -153,7 +143,6 @@ class HgImporterTestExecutor : public folly::InlineExecutor {
}
};
#if EDEN_HAVE_HG_TREEMANIFEST
// A helper function to avoid repeating noisy casts/conversions when
// loading data from a UnionDatapackStore instance.
ConstantStringRef unionStoreGet(
@ -227,7 +216,6 @@ std::unique_ptr<Blob> getBlobFromDataPackUnion(
return nullptr;
}
#endif
#endif
} // namespace
HgBackingStore::HgBackingStore(
@ -260,7 +248,6 @@ HgBackingStore::HgBackingStore(
stats))),
config_(config),
serverThreadPool_(serverThreadPool) {
#if EDEN_HAVE_HG_TREEMANIFEST
#ifndef EDEN_WIN_NO_RUST_DATAPACK
initializeDatapackImport(repository);
#endif
@ -269,7 +256,6 @@ HgBackingStore::HgBackingStore(
const auto& options = importer.getOptions();
initializeTreeManifestImport(options, repository);
repoName_ = options.repoName;
#endif // EDEN_HAVE_HG_TREEMANIFEST
}
/**
@ -350,13 +336,6 @@ void HgBackingStore::initializeDatapackImport(AbsolutePathPiece repository) {
void HgBackingStore::initializeTreeManifestImport(
const ImporterOptions& options,
AbsolutePathPiece repoPath) {
#if EDEN_HAVE_HG_TREEMANIFEST
if (!FLAGS_use_hg_tree_manifest) {
XLOG(DBG2) << "treemanifest import disabled via command line flags "
"for repository "
<< repoPath;
return;
}
if (options.treeManifestPackPaths.empty()) {
XLOG(DBG2) << "treemanifest import not supported in repository "
<< repoPath;
@ -377,7 +356,6 @@ void HgBackingStore::initializeTreeManifestImport(
unionStore_ = std::make_unique<folly::Synchronized<UnionDatapackStore>>(
folly::in_place, storePtrs);
XLOG(DBG2) << "treemanifest import enabled in repository " << repoPath;
#endif // EDEN_HAVE_HG_TREEMANIFEST
}
std::unique_ptr<ServiceAddress> HgBackingStore::getMononokeServiceAddress() {
@ -432,7 +410,7 @@ HgBackingStore::initializeThriftMononokeBackingStore() {
}
#endif
#if defined(EDEN_HAVE_CURL) && EDEN_HAVE_HG_TREEMANIFEST
#if defined(EDEN_HAVE_CURL)
std::unique_ptr<MononokeCurlBackingStore>
HgBackingStore::initializeCurlMononokeBackingStore() {
auto edenConfig = config_->getEdenConfig();
@ -454,7 +432,6 @@ HgBackingStore::initializeCurlMononokeBackingStore() {
#endif
std::unique_ptr<BackingStore> HgBackingStore::initializeMononoke() {
#if EDEN_HAVE_HG_TREEMANIFEST
const auto& connectionType =
config_->getEdenConfig()->getMononokeConnectionType();
#ifndef EDEN_WIN_NOMONONOKE
@ -477,12 +454,10 @@ std::unique_ptr<BackingStore> HgBackingStore::initializeMononoke() {
#elif defined(EDEN_HAVE_CURL) // EDEN_WIN_NOMONONOKE
return initializeCurlMononokeBackingStore();
#endif // EDEN_WIN_NOMONONOKE
#endif // EDEN_HAVE_HG_TREEMANIFEST
return nullptr;
}
Future<unique_ptr<Tree>> HgBackingStore::getTree(const Hash& id) {
#if EDEN_HAVE_HG_TREEMANIFEST
HgProxyHash pathInfo(localStore_, id, "importTree");
std::shared_ptr<LocalStore::WriteBatch> writeBatch(localStore_->beginWrite());
folly::stop_watch<std::chrono::milliseconds> watch;
@ -499,16 +474,8 @@ Future<unique_ptr<Tree>> HgBackingStore::getTree(const Hash& id) {
watch.elapsed().count());
return tree;
});
#else
return Future<unique_ptr<Tree>>(folly::make_exception_wrapper<
std::domain_error>(folly::to<std::string>(
"requested to import subtree ",
id.toString(),
" but flatmanifest import should have already imported all subtrees")));
#endif
}
#if EDEN_HAVE_HG_TREEMANIFEST
Future<unique_ptr<Tree>> HgBackingStore::importTreeImpl(
const Hash& manifestNode,
const Hash& edenTreeID,
@ -766,14 +733,12 @@ folly::Future<Hash> HgBackingStore::importTreeManifest(const Hash& commitId) {
});
});
}
#endif // EDEN_HAVE_HG_TREEMANIFEST
Future<unique_ptr<Blob>> HgBackingStore::getBlob(const Hash& id) {
// Look up the mercurial path and file revision hash,
// which we need to import the data from mercurial
HgProxyHash hgInfo(localStore_, id, "importFileContents");
#if EDEN_HAVE_HG_TREEMANIFEST
#ifndef EDEN_WIN_NO_RUST_DATAPACK
if (useDatapackGetBlob_ && dataPackStore_) {
auto content =
@ -821,7 +786,6 @@ Future<unique_ptr<Blob>> HgBackingStore::getBlob(const Hash& id) {
.via(serverThreadPool_);
});
}
#endif // EDEN_HAVE_HG_TREEMANIFEST
return folly::via(
importThreadPool_.get(),
@ -884,12 +848,10 @@ folly::Future<unique_ptr<Tree>> HgBackingStore::getTreeForCommitImpl(
}
folly::Future<Hash> HgBackingStore::importManifest(Hash commitId) {
#if EDEN_HAVE_HG_TREEMANIFEST
if (unionStore_) {
auto hash = importTreeManifest(commitId);
return hash;
}
#endif // EDEN_HAVE_HG_TREEMANIFEST
return importFlatManifest(commitId);
}

View File

@ -25,12 +25,10 @@
#include <memory>
#include <optional>
#if EDEN_HAVE_HG_TREEMANIFEST
/* forward declare support classes from mercurial */
class ConstantStringRef;
class DatapackStore;
class UnionDatapackStore;
#endif // EDEN_HAVE_HG_TREEMANIFEST
namespace facebook {
namespace eden {
@ -80,13 +78,11 @@ class HgBackingStore : public BackingStore {
FOLLY_NODISCARD folly::Future<folly::Unit> prefetchBlobs(
const std::vector<Hash>& ids) const override;
#if EDEN_HAVE_HG_TREEMANIFEST
/**
* Import the manifest for the specified revision using mercurial
* treemanifest data.
*/
folly::Future<Hash> importTreeManifest(const Hash& commitId);
#endif // EDEN_HAVE_HG_TREEMANIFEST
private:
// Forbidden copy constructor and assignment operator
@ -145,7 +141,7 @@ class HgBackingStore : public BackingStore {
initializeThriftMononokeBackingStore();
#endif
#if defined(EDEN_HAVE_CURL) && EDEN_HAVE_HG_TREEMANIFEST
#if defined(EDEN_HAVE_CURL)
/**
* Create an instance of MononokeCurlBackingStore with values from config_
* (Curl based Mononoke client)
@ -161,7 +157,6 @@ class HgBackingStore : public BackingStore {
// Import the Tree from Hg and cache it in the LocalStore before returning it.
folly::Future<std::unique_ptr<Tree>> importTreeForCommit(Hash commitID);
#if EDEN_HAVE_HG_TREEMANIFEST
void initializeDatapackImport(AbsolutePathPiece repository);
folly::Future<std::unique_ptr<Tree>> importTreeImpl(
const Hash& manifestNode,
@ -184,7 +179,6 @@ class HgBackingStore : public BackingStore {
const Hash& edenTreeID,
RelativePathPiece path,
LocalStore::WriteBatch* writeBatch);
#endif
folly::Future<Hash> importManifest(Hash commitId);
@ -201,7 +195,7 @@ class HgBackingStore : public BackingStore {
// deadlock) or throw an exception when full (which would incorrectly fail the
// load).
folly::Executor* serverThreadPool_;
#if EDEN_HAVE_HG_TREEMANIFEST
// These DatapackStore objects are never referenced once UnionDatapackStore
// is allocated. They are here solely so their lifetime persists while the
// UnionDatapackStore is alive.
@ -214,7 +208,6 @@ class HgBackingStore : public BackingStore {
#ifndef EDEN_WIN_NO_RUST_DATAPACK
std::optional<folly::Synchronized<DataPackUnion>> dataPackStore_;
#endif
#endif // EDEN_HAVE_HG_TREEMANIFEST
};
} // namespace eden
} // namespace facebook

View File

@ -47,10 +47,8 @@
#include "eden/fs/utils/PathFuncs.h"
#include "eden/fs/utils/TimeUtil.h"
#if EDEN_HAVE_HG_TREEMANIFEST
// Needed for MissingKeyError
#include "edenscm/hgext/extlib/cstore/uniondatapackstore.h" // @manual=//scm/hg:datapack
#endif // EDEN_HAVE_HG_TREEMANIFEST
using folly::ByteRange;
using folly::Endian;

View File

@ -29,11 +29,9 @@ class Cursor;
}
} // namespace folly
#if EDEN_HAVE_HG_TREEMANIFEST
/* forward declare support classes from mercurial */
class DatapackStore;
class UnionDatapackStore;
#endif // EDEN_HAVE_HG_TREEMANIFEST
namespace facebook {
namespace eden {

View File

@ -123,7 +123,6 @@ void importTreeRecursive(
}
}
#if EDEN_HAVE_HG_TREEMANIFEST
int importTree(
LocalStore* store,
AbsolutePathPiece repoPath,
@ -163,7 +162,6 @@ int importTree(
return EX_OK;
}
#endif // EDEN_HAVE_HG_TREEMANIFEST
} // namespace
int main(int argc, char* argv[]) {
@ -208,14 +206,8 @@ int main(int argc, char* argv[]) {
auto rootHash = importer.importFlatManifest(revName);
printf("Imported root tree: %s\n", rootHash.toString().c_str());
} else if (FLAGS_import_type == "tree") {
#if EDEN_HAVE_HG_TREEMANIFEST
RelativePath path{FLAGS_subdir};
returnCode = importTree(&store, repoPath, revName, path, stats);
#else // !EDEN_HAVE_HG_TREEMANIFEST
fprintf(
stderr, "error: treemanifest import is not supported by this build\n");
return EX_UNAVAILABLE;
#endif // EDEN_HAVE_HG_TREEMANIFEST
} else {
fprintf(
stderr,