mirror of
https://github.com/facebook/sapling.git
synced 2024-10-05 22:37:37 +03:00
00db4f8673
Summary: This one slipped through D44263797 and allows for integration tests to be run with Buck2 on macOS. Reviewed By: fanzeyi Differential Revision: D44315942 fbshipit-source-id: d2de0773ba68f13fca9e8d5c067b82653646c757
57 lines
1.7 KiB
C++
57 lines
1.7 KiB
C++
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This software may be used and distributed according to the terms of the
|
|
* GNU General Public License version 2.
|
|
*/
|
|
|
|
#include <folly/init/Init.h>
|
|
#include <folly/logging/Init.h>
|
|
#include <folly/logging/LogConfigParser.h>
|
|
#include <folly/logging/xlog.h>
|
|
#include <folly/portability/GFlags.h>
|
|
|
|
#include "eden/fs/model/Blob.h"
|
|
#include "eden/fs/model/Hash.h"
|
|
#include "eden/fs/store/RocksDbLocalStore.h"
|
|
#include "eden/fs/telemetry/NullStructuredLogger.h"
|
|
#include "eden/fs/utils/FaultInjector.h"
|
|
|
|
DEFINE_string(edenDir, "", "The path to the .eden directory");
|
|
DEFINE_string(blobID, "", "The blob ID");
|
|
|
|
constexpr folly::StringPiece kRocksDBPath{"storage/rocks-db"};
|
|
|
|
using namespace facebook::eden;
|
|
using folly::IOBuf;
|
|
|
|
/*
|
|
* This tool rewrites a specific blob in Eden's local store with empty contents.
|
|
* This is intended for use in integration tests that exercise the behavior
|
|
* with bogus blob contents in the LocalStore.
|
|
*/
|
|
int main(int argc, char* argv[]) {
|
|
folly::init(&argc, &argv);
|
|
|
|
auto loggingConfig = folly::parseLogConfig("eden=DBG2");
|
|
folly::LoggerDB::get().updateConfig(loggingConfig);
|
|
|
|
if (FLAGS_edenDir.empty()) {
|
|
fprintf(stderr, "error: the --edenDir argument is required\n");
|
|
return 1;
|
|
}
|
|
|
|
ObjectId blobID(FLAGS_blobID);
|
|
|
|
auto edenDir = facebook::eden::canonicalPath(FLAGS_edenDir);
|
|
const auto rocksPath = edenDir + RelativePathPiece{kRocksDBPath};
|
|
FaultInjector faultInjector(/*enabled=*/false);
|
|
RocksDbLocalStore localStore(
|
|
rocksPath, std::make_shared<NullStructuredLogger>(), &faultInjector);
|
|
localStore.open();
|
|
Blob blob(blobID, IOBuf());
|
|
localStore.putBlob(blobID, &blob);
|
|
|
|
return 0;
|
|
}
|