Migrate to field_ref Thrift API

Summary:
We are unifying C++ APIs for accessing optional and unqualified fields:
https://fb.workplace.com/groups/1730279463893632/permalink/2541675446087359/.

This diff migrates code from accessing data members generated from unqualified
Thrift fields directly to the `field_ref` API, i.e. replacing

```
thrift_obj.field
```

with

```
*thrift_obj.field_ref()
```

The `_ref` suffixes will be removed in the future once data members are private
and names can be reclaimed.

The output of this codemod has been reviewed in D20039637.

The new API is documented in
https://our.intern.facebook.com/intern/wiki/Thrift/FieldAccess/.

drop-conflicts

Reviewed By: yfeldblum

Differential Revision: D22631599

fbshipit-source-id: 9bfcaeb636f34a32fd871c7cd6a2db4a7ace30bf
This commit is contained in:
Victor Zverovich 2020-07-21 11:21:48 -07:00 committed by Facebook GitHub Bot
parent dd4fcd7aee
commit e3f4a56f6b
23 changed files with 479 additions and 425 deletions

View File

@ -141,9 +141,9 @@ EdenConfigData EdenConfig::toThriftConfigData() const {
const auto& sectionKey = sectionEntry.first;
for (const auto& keyEntry : sectionEntry.second) {
auto keyName = folly::to<string>(sectionKey, ":", keyEntry.first);
auto& configValue = result.values[keyName];
configValue.parsedValue = keyEntry.second->getStringValue();
configValue.source = keyEntry.second->getSource();
auto& configValue = result.values_ref()[keyName];
*configValue.parsedValue_ref() = keyEntry.second->getStringValue();
*configValue.source_ref() = keyEntry.second->getSource();
}
}
return result;

View File

@ -86,8 +86,8 @@ void CheckoutContext::addConflict(ConflictType type, RelativePathPiece path) {
<< "attempted to add error using addConflict(): " << path;
CheckoutConflict conflict;
conflict.path = path.value().str();
conflict.type = type;
*conflict.path_ref() = path.value().str();
*conflict.type_ref() = type;
conflicts_.wlock()->push_back(std::move(conflict));
}
@ -124,9 +124,9 @@ void CheckoutContext::addError(
auto path = parentPath.value() + name;
CheckoutConflict conflict;
conflict.path = path.value();
conflict.type = ConflictType::ERROR;
conflict.message = folly::exceptionStr(ew).toStdString();
*conflict.path_ref() = path.value();
*conflict.type_ref() = ConflictType::ERROR;
*conflict.message_ref() = folly::exceptionStr(ew).toStdString();
conflicts_.wlock()->push_back(std::move(conflict));
}
} // namespace eden

View File

@ -134,31 +134,33 @@ void InodeMap::initializeFromTakeover(
insertLoadedInode(data, root_.get());
DCHECK_EQ(1, data->numTreeInodes_);
DCHECK_EQ(0, data->numFileInodes_);
for (const auto& entry : takeover.unloadedInodes) {
if (entry.numFuseReferences < 0) {
for (const auto& entry : *takeover.unloadedInodes_ref()) {
if (*entry.numFuseReferences_ref() < 0) {
auto message = folly::to<std::string>(
"inode number ",
entry.inodeNumber,
*entry.inodeNumber_ref(),
" has a negative numFuseReferences number");
XLOG(ERR) << message;
throw std::runtime_error(message);
}
auto unloadedEntry = UnloadedInode(
InodeNumber::fromThrift(entry.parentInode),
PathComponentPiece{entry.name},
entry.isUnlinked,
entry.mode,
entry.hash.empty() ? std::nullopt
: std::optional<Hash>{hashFromThrift(entry.hash)},
folly::to<uint32_t>(entry.numFuseReferences));
InodeNumber::fromThrift(*entry.parentInode_ref()),
PathComponentPiece{*entry.name_ref()},
*entry.isUnlinked_ref(),
*entry.mode_ref(),
entry.hash_ref()->empty()
? std::nullopt
: std::optional<Hash>{hashFromThrift(*entry.hash_ref())},
folly::to<uint32_t>(*entry.numFuseReferences_ref()));
auto result = data->unloadedInodes_.emplace(
InodeNumber::fromThrift(entry.inodeNumber), std::move(unloadedEntry));
InodeNumber::fromThrift(*entry.inodeNumber_ref()),
std::move(unloadedEntry));
if (!result.second) {
auto message = folly::to<std::string>(
"failed to emplace inode number ",
entry.inodeNumber,
*entry.inodeNumber_ref(),
"; is it already present in the InodeMap?");
XLOG(ERR) << message;
throw std::runtime_error(message);
@ -614,22 +616,22 @@ Future<SerializedInodeMap> InodeMap::shutdown(bool doTakeover) {
}
SerializedInodeMap result;
result.unloadedInodes.reserve(data->unloadedInodes_.size());
result.unloadedInodes_ref()->reserve(data->unloadedInodes_.size());
for (const auto& [inodeNumber, entry] : data->unloadedInodes_) {
SerializedInodeMapEntry serializedEntry;
XLOG(DBG5) << " serializing unloaded inode " << inodeNumber
<< " parent=" << entry.parent.get() << " name=" << entry.name;
serializedEntry.inodeNumber = inodeNumber.get();
serializedEntry.parentInode = entry.parent.get();
serializedEntry.name = entry.name.stringPiece().str();
serializedEntry.isUnlinked = entry.isUnlinked;
serializedEntry.numFuseReferences = entry.numFuseReferences;
serializedEntry.hash = thriftHash(entry.hash);
serializedEntry.mode = entry.mode;
*serializedEntry.inodeNumber_ref() = inodeNumber.get();
*serializedEntry.parentInode_ref() = entry.parent.get();
*serializedEntry.name_ref() = entry.name.stringPiece().str();
*serializedEntry.isUnlinked_ref() = entry.isUnlinked;
*serializedEntry.numFuseReferences_ref() = entry.numFuseReferences;
*serializedEntry.hash_ref() = thriftHash(entry.hash);
*serializedEntry.mode_ref() = entry.mode;
result.unloadedInodes.emplace_back(std::move(serializedEntry));
result.unloadedInodes_ref()->emplace_back(std::move(serializedEntry));
}
return result;

View File

@ -210,15 +210,15 @@ optional<DirContents> Overlay::loadOverlayDir(InodeNumber inodeNumber) {
bool shouldMigrateToNewFormat = false;
DirContents result;
for (auto& iter : dir.entries) {
for (auto& iter : *dir.entries_ref()) {
const auto& name = iter.first;
const auto& value = iter.second;
bool isMaterialized =
!value.hash_ref() || value.hash_ref().value_unchecked().empty();
InodeNumber ino;
if (value.inodeNumber) {
ino = InodeNumber::fromThrift(value.inodeNumber);
if (*value.inodeNumber_ref()) {
ino = InodeNumber::fromThrift(*value.inodeNumber_ref());
} else {
ino = allocateInodeNumber();
shouldMigrateToNewFormat = true;
@ -267,8 +267,8 @@ void Overlay::saveOverlayDir(InodeNumber inodeNumber, const DirContents& dir) {
// a tree, serialize that tree into the overlay, then restart Eden. Since
// writing mode bits into the InodeMetadataTable only occurs when the inode
// is loaded, the initial mode bits must persist until the first load.
oent.mode = ent.getInitialMode();
oent.inodeNumber = ent.getInodeNumber().get();
*oent.mode_ref() = ent.getInitialMode();
*oent.inodeNumber_ref() = ent.getInodeNumber().get();
bool isMaterialized = ent.isMaterialized();
if (!isMaterialized) {
auto entHash = ent.getHash();
@ -278,7 +278,7 @@ void Overlay::saveOverlayDir(InodeNumber inodeNumber, const DirContents& dir) {
bytes.size()};
}
odir.entries.emplace(
odir.entries_ref()->emplace(
std::make_pair(entName.stringPiece().str(), std::move(oent)));
}
@ -479,16 +479,16 @@ void Overlay::handleGCRequest(GCRequest& request) {
};
auto processDir = [&](const overlay::OverlayDir& dir) {
for (const auto& entry : dir.entries) {
for (const auto& entry : *dir.entries_ref()) {
const auto& value = entry.second;
if (!value.inodeNumber) {
if (!(*value.inodeNumber_ref())) {
// Legacy-only. All new Overlay trees have inode numbers for all
// children.
continue;
}
auto ino = InodeNumber::fromThrift(value.inodeNumber);
auto ino = InodeNumber::fromThrift(*value.inodeNumber_ref());
if (S_ISDIR(value.mode)) {
if (S_ISDIR(*value.mode_ref())) {
queue.push(ino);
} else {
// No need to recurse, but delete any file at this inode. Note that,

View File

@ -3410,20 +3410,20 @@ size_t TreeInode::unloadChildrenLastAccessedBefore(const timespec& cutoff) {
void TreeInode::getDebugStatus(vector<TreeInodeDebugInfo>& results) const {
TreeInodeDebugInfo info;
info.inodeNumber = getNodeId().get();
info.refcount = debugGetFuseRefcount();
*info.inodeNumber_ref() = getNodeId().get();
*info.refcount_ref() = debugGetFuseRefcount();
auto myPath = getPath();
if (myPath.has_value()) {
info.path = myPath.value().stringPiece().str();
*info.path_ref() = myPath.value().stringPiece().str();
}
vector<std::pair<PathComponent, InodePtr>> childInodes;
{
auto contents = contents_.rlock();
info.materialized = contents->isMaterialized();
info.treeHash = thriftHash(contents->treeHash);
*info.materialized_ref() = contents->isMaterialized();
*info.treeHash_ref() = thriftHash(contents->treeHash);
for (const auto& entry : contents->entries) {
if (entry.second.getInode()) {
@ -3436,16 +3436,16 @@ void TreeInode::getDebugStatus(vector<TreeInodeDebugInfo>& results) const {
// We can store data about unloaded entries immediately, since we have
// the authoritative data ourself, and don't need to ask a separate
// InodeBase object.
info.entries.emplace_back();
auto& infoEntry = info.entries.back();
info.entries_ref()->emplace_back();
auto& infoEntry = info.entries_ref()->back();
auto& inodeEntry = entry.second;
infoEntry.name = entry.first.stringPiece().str();
infoEntry.inodeNumber = inodeEntry.getInodeNumber().get();
infoEntry.mode = inodeEntry.getInitialMode();
infoEntry.loaded = false;
infoEntry.materialized = inodeEntry.isMaterialized();
if (!infoEntry.materialized) {
infoEntry.hash = thriftHash(inodeEntry.getHash());
*infoEntry.name_ref() = entry.first.stringPiece().str();
*infoEntry.inodeNumber_ref() = inodeEntry.getInodeNumber().get();
*infoEntry.mode_ref() = inodeEntry.getInitialMode();
*infoEntry.loaded_ref() = false;
*infoEntry.materialized_ref() = inodeEntry.isMaterialized();
if (!(*infoEntry.materialized_ref())) {
*infoEntry.hash_ref() = thriftHash(inodeEntry.getHash());
}
}
}
@ -3453,11 +3453,11 @@ void TreeInode::getDebugStatus(vector<TreeInodeDebugInfo>& results) const {
std::vector<folly::Future<std::pair<size_t, uint64_t>>> futures;
for (const auto& childData : childInodes) {
info.entries.emplace_back();
auto& infoEntry = info.entries.back();
infoEntry.name = childData.first.stringPiece().str();
infoEntry.inodeNumber = childData.second->getNodeId().get();
infoEntry.loaded = true;
info.entries_ref()->emplace_back();
auto& infoEntry = info.entries_ref()->back();
*infoEntry.name_ref() = childData.first.stringPiece().str();
*infoEntry.inodeNumber_ref() = childData.second->getNodeId().get();
*infoEntry.loaded_ref() = true;
auto childTree = childData.second.asTreePtrOrNull();
if (childTree) {
@ -3465,30 +3465,31 @@ void TreeInode::getDebugStatus(vector<TreeInodeDebugInfo>& results) const {
// and grab the materialization and status info now.
{
auto childContents = childTree->contents_.rlock();
infoEntry.materialized = !childContents->treeHash.has_value();
infoEntry.hash = thriftHash(childContents->treeHash);
*infoEntry.materialized_ref() = !childContents->treeHash.has_value();
*infoEntry.hash_ref() = thriftHash(childContents->treeHash);
// TODO: We don't currently store mode data for TreeInodes. We should.
infoEntry.mode = (S_IFDIR | 0755);
*infoEntry.mode_ref() = (S_IFDIR | 0755);
}
} else {
auto childFile = childData.second.asFilePtr();
infoEntry.mode = childFile->getMode();
*infoEntry.mode_ref() = childFile->getMode();
auto blobHash = childFile->getBlobHash();
infoEntry.materialized = !blobHash.has_value();
infoEntry.hash = thriftHash(blobHash);
futures.push_back(childFile->stat(ObjectFetchContext::getNullContext())
.thenValue([i = info.entries.size() - 1](auto st) {
auto fileSize = st.st_size;
return std::make_pair(i, fileSize);
}));
*infoEntry.materialized_ref() = !blobHash.has_value();
*infoEntry.hash_ref() = thriftHash(blobHash);
futures.push_back(
childFile->stat(ObjectFetchContext::getNullContext())
.thenValue([i = info.entries_ref()->size() - 1](auto st) {
auto fileSize = st.st_size;
return std::make_pair(i, fileSize);
}));
}
}
auto fileSizeMappings = folly::collectAllUnsafe(futures).get();
for (const auto& future : fileSizeMappings) {
auto [i, fileSize] = future.value();
auto& infoEntry = info.entries[i];
auto& infoEntry = info.entries_ref()[i];
// We must use set_size here because size is
// optional and if it is set directly then it will
// not get serialized correctly.

View File

@ -335,15 +335,15 @@ class OverlayChecker::MissingMaterializedInode : public OverlayChecker::Error {
: parent_(parentDirInode), childName_(childName), childInfo_(childInfo) {}
string getMessage(OverlayChecker* checker) const override {
auto fileTypeStr = S_ISDIR(childInfo_.mode)
auto fileTypeStr = S_ISDIR(*childInfo_.mode_ref())
? "directory"
: (S_ISLNK(childInfo_.mode) ? "symlink" : "file");
: (S_ISLNK(*childInfo_.mode_ref()) ? "symlink" : "file");
auto path = checker->computePath(parent_, childName_);
return folly::to<string>(
"missing overlay file for materialized ",
fileTypeStr,
" inode ",
childInfo_.inodeNumber,
*childInfo_.inodeNumber_ref(),
" (",
path.toString(),
")");
@ -351,18 +351,19 @@ class OverlayChecker::MissingMaterializedInode : public OverlayChecker::Error {
bool repair(RepairState& repair) const override {
// Create replacement data for this inode in the overlay
XDCHECK_NE(childInfo_.inodeNumber, 0);
InodeNumber childInodeNumber(childInfo_.inodeNumber);
repair.createInodeReplacement(childInodeNumber, childInfo_.mode);
XDCHECK_NE(*childInfo_.inodeNumber_ref(), 0);
InodeNumber childInodeNumber(*childInfo_.inodeNumber_ref());
repair.createInodeReplacement(childInodeNumber, *childInfo_.mode_ref());
// Add an entry in the OverlayChecker's inodes_ set.
// In case the parent directory was part of an orphaned subtree the
// OrphanInode code will look for this child in the inodes_ map.
auto type = S_ISDIR(childInfo_.mode) ? InodeType::Dir : InodeType::File;
auto type =
S_ISDIR(*childInfo_.mode_ref()) ? InodeType::Dir : InodeType::File;
auto [iter, inserted] = repair.checker()->inodes_.try_emplace(
childInodeNumber, childInodeNumber, type);
XDCHECK(inserted);
iter->second.addParent(parent_, childInfo_.mode);
iter->second.addParent(parent_, *childInfo_.mode_ref());
return true;
}
@ -433,8 +434,8 @@ class OverlayChecker::OrphanInode : public OverlayChecker::Error {
}
auto* const checker = repair.checker();
for (const auto& childEntry : children.entries) {
auto childRawInode = childEntry.second.inodeNumber;
for (const auto& childEntry : *children.entries_ref()) {
auto childRawInode = *childEntry.second.inodeNumber_ref();
if (childRawInode == 0) {
// If this child does not have an inode number allocated it cannot
// be materialized.
@ -473,7 +474,8 @@ class OverlayChecker::OrphanInode : public OverlayChecker::Error {
switch (info->type) {
case InodeType::File:
archiveOrphanFile(repair, info->number, archivePath, dirEntry.mode);
archiveOrphanFile(
repair, info->number, archivePath, *dirEntry.mode_ref());
return;
case InodeType::Dir:
archiveOrphanDir(repair, info->number, archivePath, info->children);
@ -833,8 +835,8 @@ PathComponent OverlayChecker::findChildName(
// error, which is hopefully rare. Therefore we avoid doing as much work as
// possible during linkInodeChildren(), at the cost of doing extra work here
// if we do actually need to compute paths.
for (const auto& entry : parentInfo.children.entries) {
if (static_cast<uint64_t>(entry.second.inodeNumber) == child.get()) {
for (const auto& entry : *parentInfo.children.entries_ref()) {
if (static_cast<uint64_t>(*entry.second.inodeNumber_ref()) == child.get()) {
return PathComponent(entry.first);
}
}
@ -1006,8 +1008,8 @@ overlay::OverlayDir OverlayChecker::loadDirectoryChildren(folly::File& file) {
void OverlayChecker::linkInodeChildren() {
for (const auto& [parentInodeNumber, parent] : inodes_) {
for (const auto& [childName, child] : parent.children.entries) {
auto childRawInode = child.inodeNumber;
for (const auto& [childName, child] : *parent.children.entries_ref()) {
auto childRawInode = *child.inodeNumber_ref();
if (childRawInode == 0) {
// Older versions of edenfs would leave the inode number set to 0
// if the child inode has never been loaded. The child can't be
@ -1032,7 +1034,7 @@ void OverlayChecker::linkInodeChildren() {
parentInodeNumber, childName, child);
}
} else {
childInfo->addParent(parentInodeNumber, child.mode);
childInfo->addParent(parentInodeNumber, *child.mode_ref());
// TODO: It would be nice to also check for mismatch between
// childInfo->type and child.mode

View File

@ -157,7 +157,7 @@ class TestDir {
mode_t mode,
uint64_t number = 0) {
auto insertResult =
contents_.entries.emplace(name, overlay::OverlayEntry{});
contents_.entries_ref()->emplace(name, overlay::OverlayEntry{});
if (!insertResult.second) {
throw std::runtime_error(
folly::to<string>("an entry named \"", name, "\" already exists"));
@ -167,8 +167,8 @@ class TestDir {
number = overlay_->allocateInodeNumber().get();
}
auto& entry = insertResult.first->second;
entry.mode = mode;
entry.inodeNumber = static_cast<int64_t>(number);
*entry.mode_ref() = mode;
*entry.inodeNumber_ref() = static_cast<int64_t>(number);
if (hash) {
auto hashBytes = hash->getBytes();
entry.hash_ref() = std::string{
@ -488,7 +488,7 @@ TEST(Fsck, testTruncatedDirData) {
// Make sure the overlay now has a valid empty directory where src/ was
auto newDirContents = overlay->fs().loadOverlayDir(layout.src.number());
ASSERT_TRUE(newDirContents.has_value());
EXPECT_EQ(0, newDirContents->entries.size());
EXPECT_EQ(0, newDirContents->entries_ref()->size());
// No inodes from the orphaned subtree should be present in the
// overlay any more.
@ -574,7 +574,7 @@ TEST(Fsck, testMissingDirData) {
// Make sure the overlay now has a valid empty directory where src/ was
auto newDirContents = overlay->fs().loadOverlayDir(layout.src.number());
ASSERT_TRUE(newDirContents.has_value());
EXPECT_EQ(0, newDirContents->entries.size());
EXPECT_EQ(0, newDirContents->entries_ref()->size());
// No inodes from the orphaned subtree should be present in the
// overlay any more.

View File

@ -224,9 +224,9 @@ void loadInodes(
CheckoutConflict
makeConflict(ConflictType type, StringPiece path, StringPiece message = "") {
CheckoutConflict conflict;
conflict.type = type;
conflict.path = path.str();
conflict.message = message.str();
*conflict.type_ref() = type;
*conflict.path_ref() = path.str();
*conflict.message_ref() = message.str();
return conflict;
}
} // unnamed namespace
@ -574,8 +574,8 @@ void testModifyConflict(
auto result = std::move(checkoutResult).get();
ASSERT_EQ(1, result.conflicts.size());
EXPECT_EQ(path, result.conflicts[0].path);
EXPECT_EQ(ConflictType::MODIFIED_MODIFIED, result.conflicts[0].type);
EXPECT_EQ(path, *result.conflicts[0].path_ref());
EXPECT_EQ(ConflictType::MODIFIED_MODIFIED, *result.conflicts[0].type_ref());
const auto currentParent =
testMount.getEdenMount()->getParentCommits().parent1();
@ -1269,23 +1269,23 @@ TEST(Checkout, conflict_when_directory_containing_modified_file_is_removed) {
{
auto& conflict = result.conflicts[0];
EXPECT_EQ("d1/sub/one.txt", conflict.path);
EXPECT_EQ(ConflictType::MODIFIED_REMOVED, conflict.type);
EXPECT_EQ("", conflict.message);
EXPECT_EQ("d1/sub/one.txt", *conflict.path_ref());
EXPECT_EQ(ConflictType::MODIFIED_REMOVED, *conflict.type_ref());
EXPECT_EQ("", *conflict.message_ref());
}
{
auto& conflict = result.conflicts[1];
EXPECT_EQ("d1/sub", conflict.path);
EXPECT_EQ(ConflictType::DIRECTORY_NOT_EMPTY, conflict.type);
EXPECT_EQ("", conflict.message);
EXPECT_EQ("d1/sub", *conflict.path_ref());
EXPECT_EQ(ConflictType::DIRECTORY_NOT_EMPTY, *conflict.type_ref());
EXPECT_EQ("", *conflict.message_ref());
}
{
auto& conflict = result.conflicts[2];
EXPECT_EQ("d1", conflict.path);
EXPECT_EQ(ConflictType::DIRECTORY_NOT_EMPTY, conflict.type);
EXPECT_EQ("", conflict.message);
EXPECT_EQ("d1", *conflict.path_ref());
EXPECT_EQ(ConflictType::DIRECTORY_NOT_EMPTY, *conflict.type_ref());
EXPECT_EQ("", *conflict.message_ref());
}
}

View File

@ -111,7 +111,7 @@ class DiffTest {
void checkNoChanges() {
auto result = diff();
EXPECT_THAT(result.entries, UnorderedElementsAre());
EXPECT_THAT(*result.entries_ref(), UnorderedElementsAre());
}
void testResetFileModified(bool loadInodes);
@ -171,7 +171,7 @@ TEST(DiffTest, fileModified) {
auto result = test.diff();
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/1.txt", ScmFileStatus::MODIFIED)));
}
@ -183,7 +183,7 @@ TEST(DiffTest, fileModeChanged) {
auto result = test.diff();
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/2.txt", ScmFileStatus::MODIFIED)));
}
@ -196,7 +196,7 @@ TEST(DiffTest, fileRemoved) {
auto result = test.diff();
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/1.txt", ScmFileStatus::REMOVED)));
}
@ -207,7 +207,7 @@ TEST(DiffTest, fileAdded) {
auto result = test.diff();
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/new.txt", ScmFileStatus::ADDED)));
}
@ -222,7 +222,7 @@ TEST(DiffTest, directoryRemoved) {
auto result = test.diff();
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/a/b/c/4.txt", ScmFileStatus::REMOVED),
std::make_pair("src/a/b/3.txt", ScmFileStatus::REMOVED)));
@ -239,7 +239,7 @@ TEST(DiffTest, directoryAdded) {
auto result = test.diff();
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/new/file.txt", ScmFileStatus::ADDED),
std::make_pair("src/new/subdir/foo.txt", ScmFileStatus::ADDED),
@ -257,7 +257,7 @@ TEST(DiffTest, dirReplacedWithFile) {
auto result = test.diff();
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/a/b", ScmFileStatus::ADDED),
std::make_pair("src/a/b/3.txt", ScmFileStatus::REMOVED),
@ -276,7 +276,7 @@ TEST(DiffTest, fileReplacedWithDir) {
auto result = test.diff();
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/2.txt/file.txt", ScmFileStatus::ADDED),
std::make_pair("src/2.txt/subdir/foo.txt", ScmFileStatus::ADDED),
@ -329,7 +329,7 @@ TEST(DiffTest, pathOrdering) {
// Perform the diff
auto result = test.diff();
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("one/aaa.txt", ScmFileStatus::ADDED),
std::make_pair("one/mmm.txt", ScmFileStatus::ADDED),
@ -359,7 +359,7 @@ void testResetFileModified(bool loadInodes) {
auto result = t.resetCommitAndDiff(b2, loadInodes);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/1.txt", ScmFileStatus::MODIFIED)));
}
@ -380,7 +380,7 @@ void testResetFileModeChanged(bool loadInodes) {
auto result = t.resetCommitAndDiff(b2, loadInodes);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/1.txt", ScmFileStatus::MODIFIED)));
}
@ -403,7 +403,7 @@ void testResetFileRemoved(bool loadInodes) {
auto result = t.resetCommitAndDiff(b2, loadInodes);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/notpresent.txt", ScmFileStatus::REMOVED)));
}
@ -425,7 +425,7 @@ void testResetFileAdded(bool loadInodes) {
auto result = t.resetCommitAndDiff(b2, loadInodes);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(std::make_pair("src/1.txt", ScmFileStatus::ADDED)));
}
@ -450,7 +450,7 @@ void testResetDirectoryRemoved(bool loadInodes) {
auto result = t.resetCommitAndDiff(b2, loadInodes);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/extradir/foo.txt", ScmFileStatus::REMOVED),
std::make_pair("src/extradir/bar.txt", ScmFileStatus::REMOVED),
@ -478,7 +478,7 @@ void testResetDirectoryAdded(bool loadInodes) {
auto result = t.resetCommitAndDiff(b2, loadInodes);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/a/b/3.txt", ScmFileStatus::ADDED),
std::make_pair("src/a/b/c/4.txt", ScmFileStatus::ADDED)));
@ -506,7 +506,7 @@ void testResetReplaceDirWithFile(bool loadInodes) {
auto result = t.resetCommitAndDiff(b2, loadInodes);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/2.txt", ScmFileStatus::ADDED),
std::make_pair("src/2.txt/foo.txt", ScmFileStatus::REMOVED),
@ -535,7 +535,7 @@ void testResetReplaceFileWithDir(bool loadInodes) {
auto result = t.resetCommitAndDiff(b2, loadInodes);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/a/b/3.txt", ScmFileStatus::ADDED),
std::make_pair("src/a/b/c/4.txt", ScmFileStatus::ADDED),
@ -574,12 +574,12 @@ TEST(DiffTest, ignoreToplevelOnly) {
auto result = test.diff();
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(std::make_pair("src/1.txt", ScmFileStatus::ADDED)));
result = test.diff(true);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/1.txt", ScmFileStatus::ADDED),
std::make_pair("1.txt", ScmFileStatus::IGNORED),
@ -621,7 +621,7 @@ TEST(DiffTest, ignoredFileInMountAndInTree) {
auto result = test.diff();
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/1.txt", ScmFileStatus::ADDED),
std::make_pair(
@ -629,7 +629,7 @@ TEST(DiffTest, ignoredFileInMountAndInTree) {
result = test.diff(true);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/1.txt", ScmFileStatus::ADDED),
std::make_pair("src/foo/abc/xyz/ignore.txt", ScmFileStatus::MODIFIED),
@ -670,7 +670,7 @@ TEST(DiffTest, ignoredFileNotInMountButInTree) {
auto result = test.diff();
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/1.txt", ScmFileStatus::ADDED),
std::make_pair(
@ -678,7 +678,7 @@ TEST(DiffTest, ignoredFileNotInMountButInTree) {
result = test.diff(true);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/1.txt", ScmFileStatus::ADDED),
std::make_pair("src/foo/abc/xyz/ignore.txt", ScmFileStatus::REMOVED),
@ -709,28 +709,28 @@ TEST(DiffTest, ignoreSystemLevelAndUser) {
auto result =
test.diff(true /* listIgnored */, "skip_global.txt\n", "skip_user.txt\n");
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("skip_global.txt", ScmFileStatus::IGNORED),
std::make_pair("skip_user.txt", ScmFileStatus::IGNORED)));
result = test.diff(true /* listIgnored */, "", "skip_user.txt\n");
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("skip_global.txt", ScmFileStatus::ADDED),
std::make_pair("skip_user.txt", ScmFileStatus::IGNORED)));
result = test.diff(true /* listIgnored */, "skip_global.txt\n", "");
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("skip_global.txt", ScmFileStatus::IGNORED),
std::make_pair("skip_user.txt", ScmFileStatus::ADDED)));
result = test.diff(true /* listIgnored */, "", "");
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("skip_global.txt", ScmFileStatus::ADDED),
std::make_pair("skip_user.txt", ScmFileStatus::ADDED)));
@ -759,7 +759,7 @@ TEST(DiffTest, ignoreSymlink) {
auto result = test.diff();
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair(".gitignore", ScmFileStatus::ADDED),
std::make_pair("a/.gitignore", ScmFileStatus::ADDED),
@ -769,7 +769,7 @@ TEST(DiffTest, ignoreSymlink) {
result = test.diff(true);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair(".gitignore", ScmFileStatus::ADDED),
std::make_pair("a/.gitignore", ScmFileStatus::ADDED),
@ -817,7 +817,7 @@ TEST(DiffTest, ignoreInSubdirectories) {
auto result = test.diff();
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("abc/test.log", ScmFileStatus::ADDED),
std::make_pair("abc/def/test", ScmFileStatus::ADDED),
@ -830,7 +830,7 @@ TEST(DiffTest, ignoreInSubdirectories) {
result = test.diff(true);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAreArray(
{std::make_pair("abc/test.log", ScmFileStatus::ADDED),
std::make_pair("abc/def/test", ScmFileStatus::ADDED),
@ -893,7 +893,7 @@ TEST(DiffTest, ignoreInSubdirectoriesInMountAndInTree) {
auto result = test.diff();
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("abc/test.log", ScmFileStatus::ADDED),
std::make_pair("abc/def/test", ScmFileStatus::ADDED),
@ -907,7 +907,7 @@ TEST(DiffTest, ignoreInSubdirectoriesInMountAndInTree) {
result = test.diff(true);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAreArray(
{std::make_pair("abc/test.log", ScmFileStatus::ADDED),
std::make_pair("abc/def/test", ScmFileStatus::ADDED),
@ -970,7 +970,7 @@ TEST(DiffTest, ignoreInSubdirectoriesNotInMountButInTree) {
auto result = test.diff();
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("abc/test.log", ScmFileStatus::ADDED),
std::make_pair("abc/def/test", ScmFileStatus::ADDED),
@ -984,7 +984,7 @@ TEST(DiffTest, ignoreInSubdirectoriesNotInMountButInTree) {
result = test.diff(true);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAreArray(
{std::make_pair("abc/test.log", ScmFileStatus::ADDED),
std::make_pair("abc/def/test", ScmFileStatus::ADDED),
@ -1029,7 +1029,7 @@ TEST(DiffTest, explicitlyTracked) {
auto result = test.diff();
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("other.txt", ScmFileStatus::ADDED),
std::make_pair("junk/x/foo.txt", ScmFileStatus::REMOVED),
@ -1037,7 +1037,7 @@ TEST(DiffTest, explicitlyTracked) {
result = test.diff(true);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("other.txt", ScmFileStatus::ADDED),
std::make_pair("docs/1.txt", ScmFileStatus::IGNORED),
@ -1060,7 +1060,7 @@ TEST(DiffTest, ignoreFileModified) {
auto result = test.diff(true);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("a/bar.txt", ScmFileStatus::ADDED),
std::make_pair("a/test.txt", ScmFileStatus::ADDED),
@ -1071,7 +1071,7 @@ TEST(DiffTest, ignoreFileModified) {
result = test.diff(true);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("a/test.txt", ScmFileStatus::ADDED),
std::make_pair("a/foo.txt", ScmFileStatus::ADDED),
@ -1083,7 +1083,7 @@ TEST(DiffTest, ignoreFileModified) {
result = test.diff(true);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair(".gitignore", ScmFileStatus::ADDED),
std::make_pair("a/foo.txt", ScmFileStatus::ADDED),
@ -1104,11 +1104,11 @@ TEST(DiffTest, ignoreFileIsDirectory) {
test.getMount().addFile("a/b/1.txt", "new\n");
auto result = test.diff();
EXPECT_THAT(result.entries, UnorderedElementsAre());
EXPECT_THAT(*result.entries_ref(), UnorderedElementsAre());
result = test.diff(true);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("a/b/1.txt", ScmFileStatus::IGNORED)));
}
@ -1124,7 +1124,7 @@ TEST(DiffTest, emptyIgnoreFile) {
auto result = test.diff();
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/subdir/new.txt", ScmFileStatus::ADDED)));
}
@ -1138,11 +1138,11 @@ TEST(DiffTest, ignoredFilePatternCarriageReturn) {
test.getMount().addFile("src/Icon\r", "");
auto result = test.diff();
EXPECT_THAT(result.entries, UnorderedElementsAre());
EXPECT_THAT(*result.entries_ref(), UnorderedElementsAre());
result = test.diff(true);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/Icon\r", ScmFileStatus::IGNORED)));
}
@ -1156,11 +1156,11 @@ TEST(DiffTest, ignoredFileDoubleCarriageReturn) {
test.getMount().addFile("src/Icon\r", "");
auto result = test.diff();
EXPECT_THAT(result.entries, UnorderedElementsAre());
EXPECT_THAT(*result.entries_ref(), UnorderedElementsAre());
result = test.diff(true);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/Icon\r", ScmFileStatus::IGNORED)));
}
@ -1175,7 +1175,7 @@ TEST(DiffTest, ignoredFileSingleCarriageReturn) {
auto result = test.diff();
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(std::make_pair("src/Icon\r", ScmFileStatus::ADDED)));
}
@ -1200,7 +1200,7 @@ TEST(DiffTest, ignoreHidden) {
auto result = test.diff(true);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("a/c/1.txt", ScmFileStatus::MODIFIED)));
}
@ -1224,7 +1224,7 @@ TEST(DiffTest, directoryToFileWithGitIgnore) {
auto result = test.diff();
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("a/b/c.txt", ScmFileStatus::REMOVED),
std::make_pair("a/b/d.txt", ScmFileStatus::REMOVED),
@ -1233,7 +1233,7 @@ TEST(DiffTest, directoryToFileWithGitIgnore) {
result = test.diff(true);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("a/b/c.txt", ScmFileStatus::REMOVED),
std::make_pair("a/b/d.txt", ScmFileStatus::REMOVED),
@ -1267,7 +1267,7 @@ TEST(DiffTest, addIgnoredDirectory) {
auto result = test.diff(true, systemIgnore);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("a/b/r", ScmFileStatus::REMOVED),
std::make_pair("a/b/r/e.txt", ScmFileStatus::IGNORED),
@ -1294,7 +1294,7 @@ TEST(DiffTest, nestedGitIgnoreFiles) {
auto systemIgnore = "a/b/r/*\n!a/b/r/.gitignore\n";
auto result = test.diff(true, systemIgnore);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("a/b/r", ScmFileStatus::REMOVED),
std::make_pair("a/b/r/.gitignore", ScmFileStatus::ADDED),
@ -1326,7 +1326,7 @@ TEST(DiffTest, diff_trees_with_tracked_ignored_file_modified) {
auto result = test.diff();
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/bar/e.txt", ScmFileStatus::ADDED),
std::make_pair("src/bar/d.txt", ScmFileStatus::REMOVED),
@ -1334,7 +1334,7 @@ TEST(DiffTest, diff_trees_with_tracked_ignored_file_modified) {
result = test.diff(true);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/bar/e.txt", ScmFileStatus::ADDED),
std::make_pair("src/bar/d.txt", ScmFileStatus::REMOVED),
@ -1365,7 +1365,7 @@ TEST(DiffTest, tree_file_matches_new_ignore_rule_modified_locally) {
auto result = test.diff();
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/foo/.gitignore", ScmFileStatus::ADDED),
std::make_pair("src/bar/e.txt", ScmFileStatus::ADDED),
@ -1374,7 +1374,7 @@ TEST(DiffTest, tree_file_matches_new_ignore_rule_modified_locally) {
result = test.diff(true);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/foo/.gitignore", ScmFileStatus::ADDED),
std::make_pair("src/bar/e.txt", ScmFileStatus::ADDED),
@ -1534,7 +1534,7 @@ TEST(DiffTest, fileNotReady) {
auto result = std::move(diffFuture).get(10ms);
EXPECT_THAT(
result->entries,
*result->entries_ref(),
UnorderedElementsAre(
std::make_pair("src/r.txt", ScmFileStatus::MODIFIED),
std::make_pair("src/s.txt", ScmFileStatus::MODIFIED),
@ -1621,7 +1621,7 @@ TEST_F(DiffTestNonMateralized, diff_modified_trees_top_level_not_materialized) {
auto result = diff(commitHash2);
EXPECT_THAT(
result->entries,
*result->entries_ref(),
UnorderedElementsAre(
std::make_pair("root/src/r.txt", ScmFileStatus::MODIFIED),
std::make_pair("root/src/s.txt", ScmFileStatus::MODIFIED),
@ -1660,7 +1660,7 @@ TEST_F(
auto result = diff(commitHash2);
EXPECT_THAT(
result->entries,
*result->entries_ref(),
UnorderedElementsAre(
std::make_pair("root/src/test/t.txt", ScmFileStatus::IGNORED),
std::make_pair("root/src/r.txt", ScmFileStatus::MODIFIED),
@ -1699,7 +1699,7 @@ TEST_F(DiffTestNonMateralized, diff_modified_trees_low_level_not_materialized) {
auto result = diff(commitHash2);
EXPECT_THAT(
result->entries,
*result->entries_ref(),
UnorderedElementsAre(
std::make_pair("root/doc/src/r.txt", ScmFileStatus::MODIFIED),
std::make_pair("root/doc/src/s.txt", ScmFileStatus::MODIFIED),
@ -1744,7 +1744,7 @@ TEST_F(
auto result = diff(commitHash2);
EXPECT_THAT(
result->entries,
*result->entries_ref(),
UnorderedElementsAre(
std::make_pair("root/doc/src/test/t.txt", ScmFileStatus::IGNORED),
std::make_pair("root/doc/src/r.txt", ScmFileStatus::MODIFIED),
@ -1780,7 +1780,7 @@ TEST_F(DiffTestNonMateralized, diff_added_tree_top_level_not_materialized) {
auto result = diff(commitHash2);
EXPECT_THAT(
result->entries,
*result->entries_ref(),
UnorderedElementsAre(
std::make_pair("root/src/r.txt", ScmFileStatus::ADDED),
std::make_pair("root/src/s.txt", ScmFileStatus::ADDED),
@ -1820,7 +1820,7 @@ TEST_F(
auto result = diff(commitHash2);
EXPECT_THAT(
result->entries,
*result->entries_ref(),
UnorderedElementsAre(
std::make_pair("root/src/foo/r.txt", ScmFileStatus::IGNORED),
std::make_pair("root/src/r.txt", ScmFileStatus::ADDED),
@ -1856,7 +1856,7 @@ TEST_F(DiffTestNonMateralized, diff_removed_tree_top_level_not_materialized) {
auto result = diff(commitHash2);
EXPECT_THAT(
result->entries,
*result->entries_ref(),
UnorderedElementsAre(
std::make_pair("root/another/r.txt", ScmFileStatus::REMOVED),
std::make_pair("root/another/s.txt", ScmFileStatus::REMOVED),
@ -1895,7 +1895,7 @@ TEST_F(
auto result = diff(commitHash2);
EXPECT_THAT(
result->entries,
*result->entries_ref(),
UnorderedElementsAre(
std::make_pair("root/another/r.txt", ScmFileStatus::REMOVED),
std::make_pair("root/another/s.txt", ScmFileStatus::REMOVED),
@ -1936,7 +1936,7 @@ TEST_F(DiffTestNonMateralized, diff_removed_tree_low_level_not_materialized) {
auto result = diff(commitHash2);
EXPECT_THAT(
result->entries,
*result->entries_ref(),
UnorderedElementsAre(
std::make_pair("root/doc/another/r.txt", ScmFileStatus::REMOVED),
std::make_pair("root/doc/another/s.txt", ScmFileStatus::REMOVED),

View File

@ -459,9 +459,10 @@ std::vector<DebugJournalDelta> Journal::getDebugRawJournalInfo(
auto& changeInfo = entry.second;
DebugPathChangeInfo debugChangeInfo;
debugChangeInfo.existedBefore = changeInfo.existedBefore;
debugChangeInfo.existedAfter = changeInfo.existedAfter;
delta.changedPaths.emplace(path.stringPiece().str(), debugChangeInfo);
*debugChangeInfo.existedBefore_ref() = changeInfo.existedBefore;
*debugChangeInfo.existedAfter_ref() = changeInfo.existedAfter;
delta.changedPaths_ref()->emplace(
path.stringPiece().str(), debugChangeInfo);
}
result.push_back(delta);
@ -483,7 +484,7 @@ std::vector<DebugJournalDelta> Journal::getDebugRawJournalInfo(
currentHash = current.fromHash;
for (auto& path : current.uncleanPaths) {
delta.uncleanPaths.emplace(path.stringPiece().str());
delta.uncleanPaths_ref()->emplace(path.stringPiece().str());
}
result.push_back(delta);

View File

@ -194,25 +194,29 @@ TEST(Journal, debugRawJournalInfoRemoveCreateUpdate) {
ASSERT_EQ(3, debugDeltas.size());
// Debug Raw Journal Info returns info from newest->latest
EXPECT_TRUE(debugDeltas[0].changedPaths["test.txt"].existedBefore);
EXPECT_TRUE(debugDeltas[0].changedPaths["test.txt"].existedAfter);
EXPECT_EQ(debugDeltas[0].fromPosition.mountGeneration, mountGen);
EXPECT_EQ(debugDeltas[0].fromPosition.sequenceNumber, 3);
EXPECT_FALSE(debugDeltas[1].changedPaths["test.txt"].existedBefore);
EXPECT_TRUE(debugDeltas[1].changedPaths["test.txt"].existedAfter);
EXPECT_EQ(debugDeltas[1].fromPosition.mountGeneration, mountGen);
EXPECT_EQ(debugDeltas[1].fromPosition.sequenceNumber, 2);
EXPECT_TRUE(debugDeltas[2].changedPaths["test.txt"].existedBefore);
EXPECT_FALSE(debugDeltas[2].changedPaths["test.txt"].existedAfter);
EXPECT_EQ(debugDeltas[2].fromPosition.mountGeneration, mountGen);
EXPECT_EQ(debugDeltas[2].fromPosition.sequenceNumber, 1);
EXPECT_TRUE(*debugDeltas[0].changedPaths["test.txt"].existedBefore_ref());
EXPECT_TRUE(*debugDeltas[0].changedPaths["test.txt"].existedAfter_ref());
EXPECT_EQ(
*debugDeltas[0].fromPosition_ref()->mountGeneration_ref(), mountGen);
EXPECT_EQ(*debugDeltas[0].fromPosition_ref()->sequenceNumber_ref(), 3);
EXPECT_FALSE(*debugDeltas[1].changedPaths["test.txt"].existedBefore_ref());
EXPECT_TRUE(*debugDeltas[1].changedPaths["test.txt"].existedAfter_ref());
EXPECT_EQ(
*debugDeltas[1].fromPosition_ref()->mountGeneration_ref(), mountGen);
EXPECT_EQ(*debugDeltas[1].fromPosition_ref()->sequenceNumber_ref(), 2);
EXPECT_TRUE(*debugDeltas[2].changedPaths["test.txt"].existedBefore_ref());
EXPECT_FALSE(*debugDeltas[2].changedPaths["test.txt"].existedAfter_ref());
EXPECT_EQ(
*debugDeltas[2].fromPosition_ref()->mountGeneration_ref(), mountGen);
EXPECT_EQ(*debugDeltas[2].fromPosition_ref()->sequenceNumber_ref(), 1);
debugDeltas = journal.getDebugRawJournalInfo(0, 1, mountGen);
ASSERT_EQ(1, debugDeltas.size());
EXPECT_TRUE(debugDeltas[0].changedPaths["test.txt"].existedBefore);
EXPECT_TRUE(debugDeltas[0].changedPaths["test.txt"].existedAfter);
EXPECT_EQ(debugDeltas[0].fromPosition.mountGeneration, mountGen);
EXPECT_EQ(debugDeltas[0].fromPosition.sequenceNumber, 3);
EXPECT_TRUE(*debugDeltas[0].changedPaths["test.txt"].existedBefore_ref());
EXPECT_TRUE(*debugDeltas[0].changedPaths["test.txt"].existedAfter_ref());
EXPECT_EQ(
*debugDeltas[0].fromPosition_ref()->mountGeneration_ref(), mountGen);
EXPECT_EQ(*debugDeltas[0].fromPosition_ref()->sequenceNumber_ref(), 3);
debugDeltas = journal.getDebugRawJournalInfo(0, 0, mountGen);
ASSERT_EQ(0, debugDeltas.size());
@ -238,22 +242,34 @@ TEST(Journal, debugRawJournalInfoHashUpdates) {
ASSERT_EQ(3, debugDeltas.size());
// Debug Raw Journal Info returns info from newest->latest
EXPECT_TRUE(debugDeltas[0].changedPaths.empty());
EXPECT_EQ(debugDeltas[0].fromPosition.mountGeneration, mountGen);
EXPECT_EQ(debugDeltas[0].fromPosition.sequenceNumber, 3);
EXPECT_EQ(debugDeltas[0].fromPosition.snapshotHash, thriftHash(hash1));
EXPECT_EQ(debugDeltas[0].toPosition.snapshotHash, thriftHash(hash2));
EXPECT_FALSE(debugDeltas[1].changedPaths["test.txt"].existedBefore);
EXPECT_TRUE(debugDeltas[1].changedPaths["test.txt"].existedAfter);
EXPECT_EQ(debugDeltas[1].fromPosition.mountGeneration, mountGen);
EXPECT_EQ(debugDeltas[1].fromPosition.sequenceNumber, 2);
EXPECT_EQ(debugDeltas[1].fromPosition.snapshotHash, thriftHash(hash1));
EXPECT_EQ(debugDeltas[1].toPosition.snapshotHash, thriftHash(hash1));
EXPECT_TRUE(debugDeltas[2].changedPaths.empty());
EXPECT_EQ(debugDeltas[2].fromPosition.mountGeneration, mountGen);
EXPECT_EQ(debugDeltas[2].fromPosition.sequenceNumber, 1);
EXPECT_EQ(debugDeltas[2].fromPosition.snapshotHash, thriftHash(hash0));
EXPECT_EQ(debugDeltas[2].toPosition.snapshotHash, thriftHash(hash1));
EXPECT_TRUE(debugDeltas[0].changedPaths_ref()->empty());
EXPECT_EQ(
*debugDeltas[0].fromPosition_ref()->mountGeneration_ref(), mountGen);
EXPECT_EQ(*debugDeltas[0].fromPosition_ref()->sequenceNumber_ref(), 3);
EXPECT_EQ(
*debugDeltas[0].fromPosition_ref()->snapshotHash_ref(),
thriftHash(hash1));
EXPECT_EQ(
*debugDeltas[0].toPosition_ref()->snapshotHash_ref(), thriftHash(hash2));
EXPECT_FALSE(*debugDeltas[1].changedPaths["test.txt"].existedBefore_ref());
EXPECT_TRUE(*debugDeltas[1].changedPaths["test.txt"].existedAfter_ref());
EXPECT_EQ(
*debugDeltas[1].fromPosition_ref()->mountGeneration_ref(), mountGen);
EXPECT_EQ(*debugDeltas[1].fromPosition_ref()->sequenceNumber_ref(), 2);
EXPECT_EQ(
*debugDeltas[1].fromPosition_ref()->snapshotHash_ref(),
thriftHash(hash1));
EXPECT_EQ(
*debugDeltas[1].toPosition_ref()->snapshotHash_ref(), thriftHash(hash1));
EXPECT_TRUE(debugDeltas[2].changedPaths_ref()->empty());
EXPECT_EQ(
*debugDeltas[2].fromPosition_ref()->mountGeneration_ref(), mountGen);
EXPECT_EQ(*debugDeltas[2].fromPosition_ref()->sequenceNumber_ref(), 1);
EXPECT_EQ(
*debugDeltas[2].fromPosition_ref()->snapshotHash_ref(),
thriftHash(hash0));
EXPECT_EQ(
*debugDeltas[2].toPosition_ref()->snapshotHash_ref(), thriftHash(hash1));
}
TEST(Journal, destruction_does_not_overflow_stack_on_long_chain) {

View File

@ -991,13 +991,13 @@ std::vector<Future<Unit>> EdenServer::prepareMounts(
for (const auto& client : dirs.items()) {
auto mountFuture = makeFutureWith([&] {
MountInfo mountInfo;
mountInfo.mountPoint = client.first.c_str();
*mountInfo.mountPoint_ref() = client.first.c_str();
auto edenClientPath =
edenDir_.getCheckoutStateDir(client.second.asString());
mountInfo.edenClientPath = edenClientPath.stringPiece().str();
*mountInfo.edenClientPath_ref() = edenClientPath.stringPiece().str();
auto initialConfig = CheckoutConfig::loadFromClientDirectory(
AbsolutePathPiece{mountInfo.mountPoint},
AbsolutePathPiece{mountInfo.edenClientPath});
AbsolutePathPiece{*mountInfo.mountPoint_ref()},
AbsolutePathPiece{*mountInfo.edenClientPath_ref()});
auto progressIndex = progressManager_->wlock()->registerEntry(
client.first.asString(), initialConfig->getOverlayPath().c_str());

View File

@ -279,11 +279,12 @@ EdenServiceHandler::EdenServiceHandler(
apache::thrift::metadata::ThriftServiceMetadataResponse metadataResponse;
getProcessor()->getServiceMetadata(metadataResponse);
auto& edenService = metadataResponse.metadata.services.at("eden.EdenService");
for (auto& function : edenService.functions) {
auto& edenService =
metadataResponse.metadata_ref()->services_ref()->at("eden.EdenService");
for (auto& function : *edenService.functions_ref()) {
HistConfig hc;
for (auto& [name, customHistConfig] : customMethodConfigs) {
if (function.name == name) {
if (*function.name_ref() == name) {
hc = customHistConfig;
break;
}
@ -292,7 +293,7 @@ EdenServiceHandler::EdenServiceHandler(
// parent services too.
static constexpr StringPiece prefix = "EdenService.";
exportThriftFuncHist(
folly::to<std::string>(prefix, function.name),
folly::to<std::string>(prefix, *function.name_ref()),
facebook::fb303::PROCESS,
folly::small_vector<int>({50, 90, 99}), // percentiles to record
hc.bucketSize,
@ -331,10 +332,10 @@ void EdenServiceHandler::mount(std::unique_ptr<MountArgument> argument) {
auto helper = INSTRUMENT_THRIFT_CALL(INFO, argument->get_mountPoint());
try {
auto initialConfig = CheckoutConfig::loadFromClientDirectory(
AbsolutePathPiece{argument->mountPoint},
AbsolutePathPiece{argument->edenClientPath});
AbsolutePathPiece{*argument->mountPoint_ref()},
AbsolutePathPiece{*argument->edenClientPath_ref()});
server_->mount(std::move(initialConfig), argument->readOnly).get();
server_->mount(std::move(initialConfig), *argument->readOnly_ref()).get();
} catch (const EdenError& ex) {
XLOG(ERR) << "Error: " << ex.what();
throw;
@ -359,9 +360,10 @@ void EdenServiceHandler::listMounts(std::vector<MountInfo>& results) {
auto helper = INSTRUMENT_THRIFT_CALL(DBG3);
for (const auto& edenMount : server_->getAllMountPoints()) {
MountInfo info;
info.mountPoint = edenMount->getPath().value();
info.edenClientPath = edenMount->getConfig()->getClientDirectory().value();
info.state = edenMount->getState();
*info.mountPoint_ref() = edenMount->getPath().value();
*info.edenClientPath_ref() =
edenMount->getConfig()->getClientDirectory().value();
*info.state_ref() = edenMount->getState();
results.push_back(info);
}
}
@ -386,10 +388,10 @@ void EdenServiceHandler::checkOutRevision(
void EdenServiceHandler::resetParentCommits(
std::unique_ptr<std::string> mountPoint,
std::unique_ptr<WorkingDirectoryParents> parents) {
auto helper =
INSTRUMENT_THRIFT_CALL(DBG1, *mountPoint, logHash(parents->parent1));
auto helper = INSTRUMENT_THRIFT_CALL(
DBG1, *mountPoint, logHash(*parents->parent1_ref()));
ParentCommits edenParents;
edenParents.parent1() = hashFromThrift(parents->parent1);
edenParents.parent1() = hashFromThrift(*parents->parent1_ref());
if (parents->parent2_ref()) {
edenParents.parent2() =
hashFromThrift(parents->parent2_ref().value_unchecked());
@ -496,13 +498,13 @@ void EdenServiceHandler::getCurrentJournalPosition(
auto edenMount = server_->getMount(*mountPoint);
auto latest = edenMount->getJournal().getLatest();
out.mountGeneration = edenMount->getMountGeneration();
*out.mountGeneration_ref() = edenMount->getMountGeneration();
if (latest) {
out.sequenceNumber = latest->sequenceID;
out.snapshotHash = thriftHash(latest->toHash);
*out.sequenceNumber_ref() = latest->sequenceID;
*out.snapshotHash_ref() = thriftHash(latest->toHash);
} else {
out.sequenceNumber = 0;
out.snapshotHash = thriftHash(kZeroHash);
*out.sequenceNumber_ref() = 0;
*out.snapshotHash_ref() = thriftHash(kZeroHash);
}
}
@ -574,13 +576,13 @@ EdenServiceHandler::subscribeStreamTemporary(
auto latest = journal.getLatest();
if (latest) {
pos.sequenceNumber = latest->sequenceID;
pos.snapshotHash = StringPiece(latest->toHash.getBytes()).str();
*pos.sequenceNumber_ref() = latest->sequenceID;
*pos.snapshotHash_ref() = StringPiece(latest->toHash.getBytes()).str();
} else {
pos.sequenceNumber = 0;
pos.snapshotHash = StringPiece(kZeroHash.getBytes()).str();
*pos.sequenceNumber_ref() = 0;
*pos.snapshotHash_ref() = StringPiece(kZeroHash.getBytes()).str();
}
pos.mountGeneration = mount->getMountGeneration();
*pos.mountGeneration_ref() = mount->getMountGeneration();
stream->publisher.next(pos);
}
};
@ -600,7 +602,7 @@ void EdenServiceHandler::getFilesChangedSince(
auto helper = INSTRUMENT_THRIFT_CALL(DBG3, *mountPoint);
auto edenMount = server_->getMount(*mountPoint);
if (fromPosition->mountGeneration !=
if (*fromPosition->mountGeneration_ref() !=
static_cast<ssize_t>(edenMount->getMountGeneration())) {
throw newEdenError(
ERANGE,
@ -613,15 +615,17 @@ void EdenServiceHandler::getFilesChangedSince(
// The +1 is because the core merge stops at the item prior to
// its limitSequence parameter and we want the changes *since*
// the provided sequence number.
auto summed =
edenMount->getJournal().accumulateRange(fromPosition->sequenceNumber + 1);
auto summed = edenMount->getJournal().accumulateRange(
*fromPosition->sequenceNumber_ref() + 1);
// We set the default toPosition to be where we where if summed is null
out.toPosition.sequenceNumber = fromPosition->sequenceNumber;
out.toPosition.snapshotHash = fromPosition->snapshotHash;
out.toPosition.mountGeneration = edenMount->getMountGeneration();
*out.toPosition_ref()->sequenceNumber_ref() =
*fromPosition->sequenceNumber_ref();
*out.toPosition_ref()->snapshotHash_ref() = *fromPosition->snapshotHash_ref();
*out.toPosition_ref()->mountGeneration_ref() =
edenMount->getMountGeneration();
out.fromPosition = out.toPosition;
*out.fromPosition_ref() = *out.toPosition_ref();
if (summed) {
if (summed->isTruncated) {
@ -630,26 +634,28 @@ void EdenServiceHandler::getFilesChangedSince(
EdenErrorType::JOURNAL_TRUNCATED,
"Journal entry range has been truncated.");
}
out.toPosition.sequenceNumber = summed->toSequence;
out.toPosition.snapshotHash = thriftHash(summed->toHash);
out.toPosition.mountGeneration = edenMount->getMountGeneration();
*out.toPosition_ref()->sequenceNumber_ref() = summed->toSequence;
*out.toPosition_ref()->snapshotHash_ref() = thriftHash(summed->toHash);
*out.toPosition_ref()->mountGeneration_ref() =
edenMount->getMountGeneration();
out.fromPosition.sequenceNumber = summed->fromSequence;
out.fromPosition.snapshotHash = thriftHash(summed->fromHash);
out.fromPosition.mountGeneration = out.toPosition.mountGeneration;
*out.fromPosition_ref()->sequenceNumber_ref() = summed->fromSequence;
*out.fromPosition_ref()->snapshotHash_ref() = thriftHash(summed->fromHash);
*out.fromPosition_ref()->mountGeneration_ref() =
*out.toPosition_ref()->mountGeneration_ref();
for (const auto& entry : summed->changedFilesInOverlay) {
auto& path = entry.first;
auto& changeInfo = entry.second;
if (changeInfo.isNew()) {
out.createdPaths.emplace_back(path.stringPiece().str());
out.createdPaths_ref()->emplace_back(path.stringPiece().str());
} else {
out.changedPaths.emplace_back(path.stringPiece().str());
out.changedPaths_ref()->emplace_back(path.stringPiece().str());
}
}
for (auto& path : summed->uncleanPaths) {
out.uncleanPaths.emplace_back(path.stringPiece().str());
out.uncleanPaths_ref()->emplace_back(path.stringPiece().str());
}
}
}
@ -693,8 +699,8 @@ void EdenServiceHandler::flushJournal(std::unique_ptr<PathString> mountPoint) {
void EdenServiceHandler::debugGetRawJournal(
DebugGetRawJournalResponse& out,
std::unique_ptr<DebugGetRawJournalParams> params) {
auto helper = INSTRUMENT_THRIFT_CALL(DBG3, params->mountPoint);
auto edenMount = server_->getMount(params->mountPoint);
auto helper = INSTRUMENT_THRIFT_CALL(DBG3, *params->mountPoint_ref());
auto edenMount = server_->getMount(*params->mountPoint_ref());
auto mountGeneration = static_cast<ssize_t>(edenMount->getMountGeneration());
std::optional<size_t> limitopt = std::nullopt;
@ -702,8 +708,8 @@ void EdenServiceHandler::debugGetRawJournal(
limitopt = static_cast<size_t>(*limit);
}
out.allDeltas = edenMount->getJournal().getDebugRawJournalInfo(
params->fromSequenceNumber, limitopt, mountGeneration);
*out.allDeltas_ref() = edenMount->getJournal().getDebugRawJournalInfo(
*params->fromSequenceNumber_ref(), limitopt, mountGeneration);
}
folly::SemiFuture<std::unique_ptr<std::vector<EntryInformationOrError>>>
@ -762,11 +768,12 @@ EdenServiceHandler::semifuture_getFileInformation(
->stat(ObjectFetchContext::getNullContext())
.thenValue([](struct stat st) {
FileInformation info;
info.size = st.st_size;
*info.size_ref() = st.st_size;
auto ts = stMtime(st);
info.mtime.seconds = ts.tv_sec;
info.mtime.nanoSeconds = ts.tv_nsec;
info.mode = st.st_mode;
*info.mtime_ref()->seconds_ref() = ts.tv_sec;
*info.mtime_ref()->nanoSeconds_ref() =
ts.tv_nsec;
*info.mode_ref() = st.st_mode;
FileInformationOrError result;
result.set_info(info);
@ -829,26 +836,26 @@ folly::Future<std::unique_ptr<Glob>> EdenServiceHandler::future_globFiles(
std::unique_ptr<GlobParams> params) {
auto helper = INSTRUMENT_THRIFT_CALL(
DBG3,
params->mountPoint,
toLogArg(params->globs),
params->includeDotfiles);
auto edenMount = server_->getMount(params->mountPoint);
*params->mountPoint_ref(),
toLogArg(*params->globs_ref()),
*params->includeDotfiles_ref());
auto edenMount = server_->getMount(*params->mountPoint_ref());
auto rootInode = edenMount->getRootInode();
// TODO: Track and report object fetches required for this glob.
auto& context = ObjectFetchContext::getNullContext();
// Compile the list of globs into a tree
auto globRoot = std::make_shared<GlobNode>(params->includeDotfiles);
auto globRoot = std::make_shared<GlobNode>(*params->includeDotfiles_ref());
try {
for (auto& globString : params->globs) {
for (auto& globString : *params->globs_ref()) {
globRoot->parse(globString);
}
} catch (const std::system_error& exc) {
throw newEdenError(exc);
}
auto fileBlobsToPrefetch = params->prefetchFiles
auto fileBlobsToPrefetch = *params->prefetchFiles_ref()
? std::make_shared<folly::Synchronized<std::vector<Hash>>>()
: nullptr;
@ -862,9 +869,9 @@ folly::Future<std::unique_ptr<Glob>> EdenServiceHandler::future_globFiles(
rootInode,
fileBlobsToPrefetch)
.thenValue([edenMount,
wantDtype = params->wantDtype,
wantDtype = *params->wantDtype_ref(),
fileBlobsToPrefetch,
suppressFileList = params->suppressFileList](
suppressFileList = *params->suppressFileList_ref()](
std::vector<GlobNode::GlobResult>&& results) {
auto out = std::make_unique<Glob>();
@ -873,11 +880,12 @@ folly::Future<std::unique_ptr<Glob>> EdenServiceHandler::future_globFiles(
for (auto& entry : results) {
auto ret = seenPaths.insert(entry.name);
if (ret.second) {
out->matchingFiles.emplace_back(
out->matchingFiles_ref()->emplace_back(
entry.name.stringPiece().toString());
if (wantDtype) {
out->dtypes.emplace_back(static_cast<OsDtype>(entry.dtype));
out->dtypes_ref()->emplace_back(
static_cast<OsDtype>(entry.dtype));
}
}
}
@ -936,7 +944,7 @@ void EdenServiceHandler::getManifestEntry(
auto filename = RelativePathPiece{*relativePath};
auto mode = isInManifestAsFile(mount.get(), filename);
if (mode.has_value()) {
out.mode = mode.value();
*out.mode_ref() = mode.value();
} else {
NoValueForKeyError error;
error.key_ref() = *relativePath;
@ -982,22 +990,22 @@ void EdenServiceHandler::async_tm_getScmStatusV2(
auto helper = INSTRUMENT_THRIFT_CALL_WITH_FUNCTION_NAME(
DBG2,
func,
params->mountPoint,
folly::to<string>("commitHash=", logHash(params->commit)),
folly::to<string>("listIgnored=", params->listIgnored));
*params->mountPoint_ref(),
folly::to<string>("commitHash=", logHash(*params->commit_ref())),
folly::to<string>("listIgnored=", *params->listIgnored_ref()));
auto mount = server_->getMount(params->mountPoint);
auto hash = hashFromThrift(params->commit);
auto mount = server_->getMount(*params->mountPoint_ref());
auto hash = hashFromThrift(*params->commit_ref());
const auto& enforceParents = server_->getServerState()
->getReloadableConfig()
.getEdenConfig()
->enforceParents.getValue();
return helper.wrapFuture(
mount->diff(hash, params->listIgnored, enforceParents, request)
mount->diff(hash, *params->listIgnored_ref(), enforceParents, request)
.thenValue([this, mount](std::unique_ptr<ScmStatus>&& status) {
auto result = std::make_unique<GetScmStatusResult>();
result->status = std::move(*status);
result->version = server_->getVersion();
*result->status_ref() = std::move(*status);
*result->version_ref() = server_->getVersion();
return result;
}));
})
@ -1085,9 +1093,9 @@ void EdenServiceHandler::debugGetScmTree(
for (const auto& entry : tree->getTreeEntries()) {
entries.emplace_back();
auto& out = entries.back();
out.name = entry.getName().stringPiece().str();
out.mode = modeFromTreeEntryType(entry.getType());
out.id = thriftHash(entry.getHash());
*out.name_ref() = entry.getName().stringPiece().str();
*out.mode_ref() = modeFromTreeEntryType(entry.getType());
*out.id_ref() = thriftHash(entry.getHash());
}
}
@ -1149,8 +1157,8 @@ void EdenServiceHandler::debugGetScmBlobMetadata(
"no blob metadata found for id ",
id.toString());
}
result.size = metadata->size;
result.contentsSha1 = thriftHash(metadata->sha1);
*result.size_ref() = metadata->size;
*result.contentsSha1_ref() = thriftHash(metadata->sha1);
}
void EdenServiceHandler::debugInodeStatus(
@ -1181,13 +1189,13 @@ void EdenServiceHandler::debugOutstandingFuseCalls(
// Conversion is done here to avoid building a dependency between
// FuseChannel and thrift
fuseCall.len = call.len;
fuseCall.opcode = call.opcode;
fuseCall.unique = call.unique;
fuseCall.nodeid = call.nodeid;
fuseCall.uid = call.uid;
fuseCall.gid = call.gid;
fuseCall.pid = call.pid;
*fuseCall.len_ref() = call.len;
*fuseCall.opcode_ref() = call.opcode;
*fuseCall.unique_ref() = call.unique;
*fuseCall.nodeid_ref() = call.nodeid;
*fuseCall.uid_ref() = call.uid;
*fuseCall.gid_ref() = call.gid;
*fuseCall.pid_ref() = call.pid;
outstandingCalls.push_back(fuseCall);
}
@ -1206,10 +1214,10 @@ void EdenServiceHandler::debugGetInodePath(
auto relativePath = inodeMap->getPathForInode(inodeNum);
// Check if the inode is loaded
info.loaded = inodeMap->lookupLoadedInode(inodeNum) != nullptr;
*info.loaded_ref() = inodeMap->lookupLoadedInode(inodeNum) != nullptr;
// If getPathForInode returned none then the inode is unlinked
info.linked = relativePath != std::nullopt;
info.path = relativePath ? relativePath->stringPiece().str() : "";
*info.linked_ref() = relativePath != std::nullopt;
*info.path_ref() = relativePath ? relativePath->stringPiece().str() : "";
}
void EdenServiceHandler::getAccessCounts(
@ -1218,7 +1226,7 @@ void EdenServiceHandler::getAccessCounts(
#ifndef _WIN32
auto helper = INSTRUMENT_THRIFT_CALL(DBG3);
result.cmdsByPid =
*result.cmdsByPid_ref() =
server_->getServerState()->getProcessNameCache()->getAllProcessNames();
auto seconds = std::chrono::seconds{duration};
@ -1229,13 +1237,13 @@ void EdenServiceHandler::getAccessCounts(
auto& pidFetches = mount->getObjectStore()->getPidFetches();
MountAccesses& ma = result.accessesByMount[mountStr];
MountAccesses& ma = result.accessesByMount_ref()[mountStr];
for (auto& [pid, accessCounts] : pal.getAccessCounts(seconds)) {
ma.accessCountsByPid[pid] = accessCounts;
ma.accessCountsByPid_ref()[pid] = accessCounts;
}
for (auto& [pid, fetchCount] : *pidFetches.rlock()) {
ma.fetchCountsByPid[pid] = fetchCount;
ma.fetchCountsByPid_ref()[pid] = fetchCount;
}
}
#else
@ -1268,8 +1276,8 @@ int64_t EdenServiceHandler::unloadInodeForPath(
TreeInodePtr inode = inodeFromUserPath(*edenMount, *path).asTreePtr();
auto cutoff = std::chrono::system_clock::now() -
std::chrono::seconds(age->seconds) -
std::chrono::nanoseconds(age->nanoSeconds);
std::chrono::seconds(*age->seconds_ref()) -
std::chrono::nanoseconds(*age->nanoSeconds_ref());
auto cutoff_ts = folly::to<timespec>(cutoff);
return inode->unloadChildrenLastAccessedBefore(cutoff_ts);
#else
@ -1285,54 +1293,58 @@ void EdenServiceHandler::getStatInfo(InternalStats& result) {
// Set LoadedInde Count and unloaded Inode count for the mountPoint.
MountInodeInfo mountInodeInfo;
auto counts = inodeMap->getInodeCounts();
mountInodeInfo.unloadedInodeCount = counts.unloadedInodeCount;
mountInodeInfo.loadedFileCount = counts.fileCount;
mountInodeInfo.loadedTreeCount = counts.treeCount;
*mountInodeInfo.unloadedInodeCount_ref() = counts.unloadedInodeCount;
*mountInodeInfo.loadedFileCount_ref() = counts.fileCount;
*mountInodeInfo.loadedTreeCount_ref() = counts.treeCount;
JournalInfo journalThrift;
if (auto journalStats = mount->getJournal().getStats()) {
journalThrift.entryCount = journalStats->entryCount;
journalThrift.durationSeconds = journalStats->getDurationInSeconds();
*journalThrift.entryCount_ref() = journalStats->entryCount;
*journalThrift.durationSeconds_ref() =
journalStats->getDurationInSeconds();
} else {
journalThrift.entryCount = 0;
journalThrift.durationSeconds = 0;
*journalThrift.entryCount_ref() = 0;
*journalThrift.durationSeconds_ref() = 0;
}
journalThrift.memoryUsage = mount->getJournal().estimateMemoryUsage();
result.mountPointJournalInfo[mount->getPath().stringPiece().str()] =
*journalThrift.memoryUsage_ref() =
mount->getJournal().estimateMemoryUsage();
result.mountPointJournalInfo_ref()[mount->getPath().stringPiece().str()] =
journalThrift;
result.mountPointInfo[mount->getPath().stringPiece().str()] =
result.mountPointInfo_ref()[mount->getPath().stringPiece().str()] =
mountInodeInfo;
}
// Get the counters and set number of inodes unloaded by periodic unload job.
result.counters = fb303::ServiceData::get()->getCounters();
result.periodicUnloadCount =
result.counters[kPeriodicUnloadCounterKey.toString()];
*result.counters_ref() = fb303::ServiceData::get()->getCounters();
*result.periodicUnloadCount_ref() =
result.counters_ref()[kPeriodicUnloadCounterKey.toString()];
auto privateDirtyBytes = facebook::eden::proc_util::calculatePrivateBytes();
if (privateDirtyBytes) {
result.privateBytes = privateDirtyBytes.value();
*result.privateBytes_ref() = privateDirtyBytes.value();
}
auto memoryStats = facebook::eden::proc_util::readMemoryStats();
if (memoryStats) {
result.vmRSSBytes = memoryStats->resident;
*result.vmRSSBytes_ref() = memoryStats->resident;
}
// Note: this will be removed in a subsequent commit.
// We now report periodically via ServiceData
std::string smaps;
if (folly::readFile("/proc/self/smaps", smaps)) {
result.smaps = std::move(smaps);
*result.smaps_ref() = std::move(smaps);
}
const auto blobCacheStats = server_->getBlobCache()->getStats();
result.blobCacheStats.entryCount = blobCacheStats.blobCount;
result.blobCacheStats.totalSizeInBytes = blobCacheStats.totalSizeInBytes;
result.blobCacheStats.hitCount = blobCacheStats.hitCount;
result.blobCacheStats.missCount = blobCacheStats.missCount;
result.blobCacheStats.evictionCount = blobCacheStats.evictionCount;
result.blobCacheStats.dropCount = blobCacheStats.dropCount;
*result.blobCacheStats_ref()->entryCount_ref() = blobCacheStats.blobCount;
*result.blobCacheStats_ref()->totalSizeInBytes_ref() =
blobCacheStats.totalSizeInBytes;
*result.blobCacheStats_ref()->hitCount_ref() = blobCacheStats.hitCount;
*result.blobCacheStats_ref()->missCount_ref() = blobCacheStats.missCount;
*result.blobCacheStats_ref()->evictionCount_ref() =
blobCacheStats.evictionCount;
*result.blobCacheStats_ref()->dropCount_ref() = blobCacheStats.dropCount;
}
void EdenServiceHandler::flushStatsNow() {
@ -1428,38 +1440,51 @@ std::optional<folly::exception_wrapper> getFaultError(
void EdenServiceHandler::injectFault(unique_ptr<FaultDefinition> fault) {
auto& injector = server_->getServerState()->getFaultInjector();
if (fault->block) {
injector.injectBlock(fault->keyClass, fault->keyValueRegex, fault->count);
if (*fault->block_ref()) {
injector.injectBlock(
*fault->keyClass_ref(),
*fault->keyValueRegex_ref(),
*fault->count_ref());
return;
}
auto error = getFaultError(fault->errorType_ref(), fault->errorMessage_ref());
std::chrono::milliseconds delay(fault->delayMilliseconds);
std::chrono::milliseconds delay(*fault->delayMilliseconds_ref());
if (error.has_value()) {
if (delay.count() > 0) {
injector.injectDelayedError(
fault->keyClass,
fault->keyValueRegex,
*fault->keyClass_ref(),
*fault->keyValueRegex_ref(),
delay,
error.value(),
fault->count);
*fault->count_ref());
} else {
injector.injectError(
fault->keyClass, fault->keyValueRegex, error.value(), fault->count);
*fault->keyClass_ref(),
*fault->keyValueRegex_ref(),
error.value(),
*fault->count_ref());
}
} else {
if (delay.count() > 0) {
injector.injectDelay(
fault->keyClass, fault->keyValueRegex, delay, fault->count);
*fault->keyClass_ref(),
*fault->keyValueRegex_ref(),
delay,
*fault->count_ref());
} else {
injector.injectNoop(fault->keyClass, fault->keyValueRegex, fault->count);
injector.injectNoop(
*fault->keyClass_ref(),
*fault->keyValueRegex_ref(),
*fault->count_ref());
}
}
}
bool EdenServiceHandler::removeFault(unique_ptr<RemoveFaultArg> fault) {
auto& injector = server_->getServerState()->getFaultInjector();
return injector.removeFault(fault->keyClass, fault->keyValueRegex);
return injector.removeFault(
*fault->keyClass_ref(), *fault->keyValueRegex_ref());
}
int64_t EdenServiceHandler::unblockFault(unique_ptr<UnblockFaultArg> info) {
@ -1495,8 +1520,8 @@ void EdenServiceHandler::reloadConfig() {
}
void EdenServiceHandler::getDaemonInfo(DaemonInfo& result) {
result.pid = getpid();
result.commandLine = originalCommandLine_;
*result.pid_ref() = getpid();
*result.commandLine_ref() = originalCommandLine_;
result.status_ref() = getStatus();
#ifndef _WIN32
@ -1520,7 +1545,7 @@ void EdenServiceHandler::getConfig(
EdenConfigData& result,
unique_ptr<GetConfigParams> params) {
auto state = server_->getServerState();
auto config = state->getEdenConfig(params->reload);
auto config = state->getEdenConfig(*params->reload_ref());
result = config->toThriftConfigData();
}

View File

@ -46,8 +46,9 @@ std::ostream& operator<<(std::ostream& os, ConflictType conflictType) {
}
std::ostream& operator<<(std::ostream& os, const CheckoutConflict& conflict) {
os << "CheckoutConflict(type=" << conflict.type << ", path=\""
<< conflict.path << "\", message=\"" << conflict.message << "\")";
os << "CheckoutConflict(type=" << *conflict.type_ref() << ", path=\""
<< *conflict.path_ref() << "\", message=\"" << *conflict.message_ref()
<< "\")";
return os;
}

View File

@ -17,22 +17,22 @@
namespace facebook {
namespace eden {
void ScmStatusDiffCallback::ignoredFile(RelativePathPiece path) {
data_.wlock()->entries.emplace(
data_.wlock()->entries_ref()->emplace(
path.stringPiece().str(), ScmFileStatus::IGNORED);
}
void ScmStatusDiffCallback::addedFile(RelativePathPiece path) {
data_.wlock()->entries.emplace(
data_.wlock()->entries_ref()->emplace(
path.stringPiece().str(), ScmFileStatus::ADDED);
}
void ScmStatusDiffCallback::removedFile(RelativePathPiece path) {
data_.wlock()->entries.emplace(
data_.wlock()->entries_ref()->emplace(
path.stringPiece().str(), ScmFileStatus::REMOVED);
}
void ScmStatusDiffCallback::modifiedFile(RelativePathPiece path) {
data_.wlock()->entries.emplace(
data_.wlock()->entries_ref()->emplace(
path.stringPiece().str(), ScmFileStatus::MODIFIED);
}
@ -41,7 +41,7 @@ void ScmStatusDiffCallback::diffError(
const folly::exception_wrapper& ew) {
XLOG(WARNING) << "error computing status data for " << path << ": "
<< folly::exceptionStr(ew);
data_.wlock()->errors.emplace(
data_.wlock()->errors_ref()->emplace(
path.stringPiece().str(), folly::exceptionStr(ew).toStdString());
}

View File

@ -136,8 +136,8 @@ TEST_F(DiffTest, sameCommit) {
backingStore_->putCommit("1", builder)->setReady();
auto result = diffCommits("1", "1").get(100ms);
EXPECT_THAT(result->errors, UnorderedElementsAre());
EXPECT_THAT(result->entries, UnorderedElementsAre());
EXPECT_THAT(*result->errors_ref(), UnorderedElementsAre());
EXPECT_THAT(*result->entries_ref(), UnorderedElementsAre());
}
TEST_F(DiffTest, basicDiff) {
@ -162,9 +162,9 @@ TEST_F(DiffTest, basicDiff) {
backingStore_->putCommit("2", builder2)->setReady();
auto result = diffCommits("1", "2").get(100ms);
EXPECT_THAT(result->errors, UnorderedElementsAre());
EXPECT_THAT(*result->errors_ref(), UnorderedElementsAre());
EXPECT_THAT(
result->entries,
*result->entries_ref(),
UnorderedElementsAre(
Pair("src/main.c", ScmFileStatus::MODIFIED),
Pair("src/test/test2.c", ScmFileStatus::ADDED),
@ -190,17 +190,17 @@ TEST_F(DiffTest, directoryOrdering) {
backingStore_->putCommit("2", builder2)->setReady();
auto result = diffCommits("1", "2").get(100ms);
EXPECT_THAT(result->errors, UnorderedElementsAre());
EXPECT_THAT(*result->errors_ref(), UnorderedElementsAre());
EXPECT_THAT(
result->entries,
*result->entries_ref(),
UnorderedElementsAre(
Pair("src/foo/aaa.txt", ScmFileStatus::ADDED),
Pair("src/foo/zzz.txt", ScmFileStatus::ADDED)));
auto result2 = diffCommits("2", "1").get(100ms);
EXPECT_THAT(result2->errors, UnorderedElementsAre());
EXPECT_THAT(*result2->errors_ref(), UnorderedElementsAre());
EXPECT_THAT(
result2->entries,
*result2->entries_ref(),
UnorderedElementsAre(
Pair("src/foo/aaa.txt", ScmFileStatus::REMOVED),
Pair("src/foo/zzz.txt", ScmFileStatus::REMOVED)));
@ -222,15 +222,15 @@ TEST_F(DiffTest, modeChange) {
backingStore_->putCommit("2", builder2)->setReady();
auto result = diffCommits("1", "2").get(100ms);
EXPECT_THAT(result->errors, UnorderedElementsAre());
EXPECT_THAT(*result->errors_ref(), UnorderedElementsAre());
EXPECT_THAT(
result->entries,
*result->entries_ref(),
UnorderedElementsAre(Pair("some_file", ScmFileStatus::MODIFIED)));
auto result2 = diffCommits("2", "1").get(100ms);
EXPECT_THAT(result2->errors, UnorderedElementsAre());
EXPECT_THAT(*result2->errors_ref(), UnorderedElementsAre());
EXPECT_THAT(
result2->entries,
*result2->entries_ref(),
UnorderedElementsAre(Pair("some_file", ScmFileStatus::MODIFIED)));
}
#endif // !_WIN32
@ -254,9 +254,9 @@ TEST_F(DiffTest, newDirectory) {
backingStore_->putCommit("2", builder2)->setReady();
auto result = diffCommits("1", "2").get(100ms);
EXPECT_THAT(result->errors, UnorderedElementsAre());
EXPECT_THAT(*result->errors_ref(), UnorderedElementsAre());
EXPECT_THAT(
result->entries,
*result->entries_ref(),
UnorderedElementsAre(
Pair("src/foo/a/b/c.txt", ScmFileStatus::ADDED),
Pair("src/foo/a/b/d.txt", ScmFileStatus::ADDED),
@ -266,9 +266,9 @@ TEST_F(DiffTest, newDirectory) {
Pair("src/foo/z/y/w.txt", ScmFileStatus::ADDED)));
auto result2 = diffCommits("2", "1").get(100ms);
EXPECT_THAT(result2->errors, UnorderedElementsAre());
EXPECT_THAT(*result2->errors_ref(), UnorderedElementsAre());
EXPECT_THAT(
result2->entries,
*result2->entries_ref(),
UnorderedElementsAre(
Pair("src/foo/a/b/c.txt", ScmFileStatus::REMOVED),
Pair("src/foo/a/b/d.txt", ScmFileStatus::REMOVED),
@ -299,9 +299,9 @@ TEST_F(DiffTest, fileToDirectory) {
backingStore_->putCommit("2", builder2)->setReady();
auto result = diffCommits("1", "2").get(100ms);
EXPECT_THAT(result->errors, UnorderedElementsAre());
EXPECT_THAT(*result->errors_ref(), UnorderedElementsAre());
EXPECT_THAT(
result->entries,
*result->entries_ref(),
UnorderedElementsAre(
Pair("src/foo/a", ScmFileStatus::REMOVED),
Pair("src/foo/a/b/c.txt", ScmFileStatus::ADDED),
@ -312,9 +312,9 @@ TEST_F(DiffTest, fileToDirectory) {
Pair("src/foo/z/y/w.txt", ScmFileStatus::ADDED)));
auto result2 = diffCommits("2", "1").get(100ms);
EXPECT_THAT(result2->errors, UnorderedElementsAre());
EXPECT_THAT(*result2->errors_ref(), UnorderedElementsAre());
EXPECT_THAT(
result2->entries,
*result2->entries_ref(),
UnorderedElementsAre(
Pair("src/foo/a", ScmFileStatus::ADDED),
Pair("src/foo/a/b/c.txt", ScmFileStatus::REMOVED),
@ -401,12 +401,12 @@ TEST_F(DiffTest, blockedFutures) {
EXPECT_TRUE(resultFuture.isReady());
auto result = std::move(resultFuture).get();
EXPECT_THAT(result->errors, UnorderedElementsAre());
EXPECT_THAT(*result->errors_ref(), UnorderedElementsAre());
// TODO: T66590035
#ifndef _WIN32
EXPECT_THAT(
result->entries,
*result->entries_ref(),
UnorderedElementsAre(
Pair("src/main.c", ScmFileStatus::MODIFIED),
Pair("src/test/test2.c", ScmFileStatus::ADDED),
@ -471,12 +471,12 @@ TEST_F(DiffTest, loadTreeError) {
auto result = std::move(resultFuture).get();
EXPECT_THAT(
result->errors,
*result->errors_ref(),
UnorderedElementsAre(Pair(
"x/y/z",
folly::exceptionStr(std::runtime_error("oh noes")).c_str())));
EXPECT_THAT(
result->entries,
*result->entries_ref(),
UnorderedElementsAre(Pair("a/b/3.txt", ScmFileStatus::MODIFIED)));
}
@ -501,9 +501,9 @@ TEST_F(DiffTest, nonignored_added_modified_and_removed_files) {
auto result = diffCommitsWithGitIgnore(
builder.getRoot()->get().getHash(), builder2.getRoot()->get().getHash());
EXPECT_THAT(result.errors, UnorderedElementsAre());
EXPECT_THAT(*result.errors_ref(), UnorderedElementsAre());
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
Pair("src/bar/e.txt", ScmFileStatus::ADDED),
Pair("src/bar/d.txt", ScmFileStatus::REMOVED),
@ -531,9 +531,9 @@ TEST_F(DiffTest, nonignored_added_files) {
auto result = diffCommitsWithGitIgnore(
builder.getRoot()->get().getHash(), builder2.getRoot()->get().getHash());
EXPECT_THAT(result.errors, UnorderedElementsAre());
EXPECT_THAT(*result.errors_ref(), UnorderedElementsAre());
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
Pair("src/bar/foo/e.txt", ScmFileStatus::ADDED),
Pair("src/bar/foo/f.txt", ScmFileStatus::ADDED)));
@ -555,9 +555,9 @@ TEST_F(DiffTest, nonignored_added_files) {
return callback->extractStatus();
})
.get(100ms);
EXPECT_THAT(result2.errors, UnorderedElementsAre());
EXPECT_THAT(*result2.errors_ref(), UnorderedElementsAre());
EXPECT_THAT(
result2.entries,
*result2.entries_ref(),
UnorderedElementsAre(
Pair("src/bar/foo/e.txt", ScmFileStatus::ADDED),
Pair("src/bar/foo/f.txt", ScmFileStatus::ADDED)));
@ -585,9 +585,9 @@ TEST_F(DiffTest, nonignored_removed_files) {
auto result = diffCommitsWithGitIgnore(
builder.getRoot()->get().getHash(), builder2.getRoot()->get().getHash());
EXPECT_THAT(result.errors, UnorderedElementsAre());
EXPECT_THAT(*result.errors_ref(), UnorderedElementsAre());
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
Pair("src/bar/foo/e.txt", ScmFileStatus::REMOVED),
Pair("src/bar/foo/f.txt", ScmFileStatus::REMOVED)));
@ -607,9 +607,9 @@ TEST_F(DiffTest, nonignored_removed_files) {
return callback->extractStatus();
})
.get(100ms);
EXPECT_THAT(result2.errors, UnorderedElementsAre());
EXPECT_THAT(*result2.errors_ref(), UnorderedElementsAre());
EXPECT_THAT(
result2.entries,
*result2.entries_ref(),
UnorderedElementsAre(
Pair("src/bar/foo/e.txt", ScmFileStatus::REMOVED),
Pair("src/bar/foo/f.txt", ScmFileStatus::REMOVED)));
@ -645,9 +645,9 @@ TEST_F(DiffTest, diff_trees_with_tracked_ignored_file_modified) {
builder.getRoot()->get().getHash(),
builder2.getRoot()->get().getHash(),
gitIgnoreContents);
EXPECT_THAT(result.errors, UnorderedElementsAre());
EXPECT_THAT(*result.errors_ref(), UnorderedElementsAre());
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
Pair("src/bar/e.txt", ScmFileStatus::ADDED),
Pair("src/bar/d.txt", ScmFileStatus::REMOVED),
@ -681,9 +681,9 @@ TEST_F(DiffTest, ignored_added_modified_and_removed_files) {
builder.getRoot()->get().getHash(),
builder2.getRoot()->get().getHash(),
gitIgnoreContents);
EXPECT_THAT(result.errors, UnorderedElementsAre());
EXPECT_THAT(*result.errors_ref(), UnorderedElementsAre());
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
Pair("src/foo/.gitignore", ScmFileStatus::ADDED),
Pair("src/bar/e.txt", ScmFileStatus::ADDED),
@ -715,9 +715,9 @@ TEST_F(DiffTest, ignored_added_files) {
builder.getRoot()->get().getHash(),
builder2.getRoot()->get().getHash(),
gitIgnoreContents);
EXPECT_THAT(result.errors, UnorderedElementsAre());
EXPECT_THAT(*result.errors_ref(), UnorderedElementsAre());
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
Pair("src/bar/foo/e.txt", ScmFileStatus::IGNORED),
Pair("src/bar/foo/f.txt", ScmFileStatus::ADDED)));
@ -729,9 +729,9 @@ TEST_F(DiffTest, ignored_added_files) {
"",
"",
false);
EXPECT_THAT(result2.errors, UnorderedElementsAre());
EXPECT_THAT(*result2.errors_ref(), UnorderedElementsAre());
EXPECT_THAT(
result2.entries,
*result2.entries_ref(),
UnorderedElementsAre(Pair("src/bar/foo/f.txt", ScmFileStatus::ADDED)));
}
@ -764,9 +764,9 @@ TEST_F(DiffTest, ignored_removed_files) {
builder.getRoot()->get().getHash(),
builder2.getRoot()->get().getHash(),
gitIgnoreContents);
EXPECT_THAT(result.errors, UnorderedElementsAre());
EXPECT_THAT(*result.errors_ref(), UnorderedElementsAre());
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
Pair("src/bar/foo/e.txt", ScmFileStatus::REMOVED),
Pair("src/bar/foo/f.txt", ScmFileStatus::REMOVED)));
@ -801,9 +801,9 @@ TEST_F(DiffTest, ignoreToplevelOnly) {
builder2.getRoot()->get().getHash(),
gitIgnoreContents);
EXPECT_THAT(result.errors, UnorderedElementsAre());
EXPECT_THAT(*result.errors_ref(), UnorderedElementsAre());
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/1.txt", ScmFileStatus::ADDED),
std::make_pair("1.txt", ScmFileStatus::IGNORED),
@ -849,7 +849,7 @@ TEST_F(DiffTest, ignored_file_local_and_in_tree) {
builder2.getRoot()->get().getHash(),
gitIgnoreContents);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/1.txt", ScmFileStatus::ADDED),
std::make_pair("src/foo/abc/xyz/ignore.txt", ScmFileStatus::MODIFIED),
@ -896,7 +896,7 @@ TEST_F(DiffTest, ignored_file_not_local_but_is_in_tree) {
builder2.getRoot()->get().getHash(),
gitIgnoreContents);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("src/1.txt", ScmFileStatus::ADDED),
std::make_pair("src/foo/abc/xyz/ignore.txt", ScmFileStatus::REMOVED),
@ -933,7 +933,7 @@ TEST_F(DiffTest, ignoreSystemLevelAndUser) {
"skip_global.txt\n",
"skip_user.txt\n");
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("skip_global.txt", ScmFileStatus::IGNORED),
std::make_pair("skip_user.txt", ScmFileStatus::IGNORED)));
@ -965,7 +965,7 @@ TEST_F(DiffTest, ignoreUserLevel) {
"",
"skip_user.txt\n");
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("skip_global.txt", ScmFileStatus::ADDED),
std::make_pair("skip_user.txt", ScmFileStatus::IGNORED)));
@ -997,7 +997,7 @@ TEST_F(DiffTest, ignoreSystemLevel) {
"skip_global.txt\n",
"");
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("skip_global.txt", ScmFileStatus::IGNORED),
std::make_pair("skip_user.txt", ScmFileStatus::ADDED)));
@ -1032,7 +1032,7 @@ TEST_F(DiffTest, directory_to_file_with_directory_ignored) {
builder2.getRoot()->get().getHash(),
gitIgnoreContents);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("a/b/c.txt", ScmFileStatus::REMOVED),
std::make_pair("a/b/d.txt", ScmFileStatus::REMOVED),
@ -1069,7 +1069,7 @@ TEST_F(DiffTest, directory_to_file_with_file_ignored) {
builder2.getRoot()->get().getHash(),
gitIgnoreContents);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("a/b/c.txt", ScmFileStatus::REMOVED),
std::make_pair("a/b/d.txt", ScmFileStatus::REMOVED),
@ -1106,7 +1106,7 @@ TEST_F(DiffTest, file_to_directory_with_gitignore) {
builder2.getRoot()->get().getHash(),
gitIgnoreContents);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("a/b/d", ScmFileStatus::REMOVED),
std::make_pair("a/b/d/e.txt", ScmFileStatus::ADDED),
@ -1150,7 +1150,7 @@ TEST_F(DiffTest, addIgnoredDirectory) {
systemIgnore);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("a/b/r", ScmFileStatus::REMOVED),
std::make_pair("a/b/r/e.txt", ScmFileStatus::IGNORED),
@ -1189,7 +1189,7 @@ TEST_F(DiffTest, nestedGitIgnoreFiles) {
gitIgnoreContents,
systemIgnore);
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(
std::make_pair("a/b/r", ScmFileStatus::REMOVED),
std::make_pair("a/b/r/e.txt", ScmFileStatus::ADDED),
@ -1221,6 +1221,6 @@ TEST_F(DiffTest, hiddenFolder) {
builder2.getRoot()->get().getHash(),
"");
EXPECT_THAT(
result.entries,
*result.entries_ref(),
UnorderedElementsAre(std::make_pair("a/c.txt", ScmFileStatus::ADDED)));
}

View File

@ -46,7 +46,7 @@ TakeoverData takeoverMounts(
// whether we're capable of handshaking successfully
TakeoverVersionQuery query;
query.versions = supportedVersions;
*query.versions_ref() = supportedVersions;
return socket.send(
CompactSerializer::serialize<folly::IOBufQueue>(query).move());

View File

@ -294,11 +294,13 @@ IOBuf TakeoverData::serializeVersion3() {
for (const auto& mount : mountPoints) {
SerializedMountInfo serializedMount;
serializedMount.mountPath = mount.mountPath.stringPiece().str();
serializedMount.stateDirectory = mount.stateDirectory.stringPiece().str();
*serializedMount.mountPath_ref() = mount.mountPath.stringPiece().str();
*serializedMount.stateDirectory_ref() =
mount.stateDirectory.stringPiece().str();
for (const auto& bindMount : mount.bindMounts) {
serializedMount.bindMountPaths.push_back(bindMount.stringPiece().str());
serializedMount.bindMountPaths_ref()->push_back(
bindMount.stringPiece().str());
}
// Stuffing the fuse connection information in as a binary
@ -306,10 +308,10 @@ IOBuf TakeoverData::serializeVersion3() {
// machine must match the current system for a graceful
// takeover, and it saves us from re-encoding an operating
// system specific struct into a thrift file.
serializedMount.connInfo = std::string{
*serializedMount.connInfo_ref() = std::string{
reinterpret_cast<const char*>(&mount.connInfo), sizeof(mount.connInfo)};
serializedMount.inodeMap = mount.inodeMap;
*serializedMount.inodeMap_ref() = mount.inodeMap;
serializedMounts.emplace_back(std::move(serializedMount));
}
@ -349,20 +351,20 @@ TakeoverData TakeoverData::deserializeVersion3(IOBuf* buf) {
TakeoverData data;
for (auto& serializedMount : serialized.mutable_mounts()) {
const auto* connInfo = reinterpret_cast<const fuse_init_out*>(
serializedMount.connInfo.data());
serializedMount.connInfo_ref()->data());
std::vector<AbsolutePath> bindMounts;
for (const auto& path : serializedMount.bindMountPaths) {
for (const auto& path : *serializedMount.bindMountPaths_ref()) {
bindMounts.emplace_back(AbsolutePathPiece{path});
}
data.mountPoints.emplace_back(
AbsolutePath{serializedMount.mountPath},
AbsolutePath{serializedMount.stateDirectory},
AbsolutePath{*serializedMount.mountPath_ref()},
AbsolutePath{*serializedMount.stateDirectory_ref()},
std::move(bindMounts),
folly::File{},
*connInfo,
std::move(serializedMount.inodeMap));
std::move(*serializedMount.inodeMap_ref()));
}
return data;
}

View File

@ -124,10 +124,10 @@ Future<Unit> TakeoverServer::ConnHandler::start() noexcept {
CompactSerializer::deserialize<TakeoverVersionQuery>(&msg->data);
auto supported =
TakeoverData::computeCompatibleVersion(query.versions);
TakeoverData::computeCompatibleVersion(*query.versions_ref());
if (!supported.has_value()) {
auto clientVersionList = folly::join(", ", query.versions);
auto clientVersionList = folly::join(", ", *query.versions_ref());
auto serverVersionList =
folly::join(", ", kSupportedTakeoverVersions);

View File

@ -340,7 +340,7 @@ void TestMount::remountGracefully() {
"remountGracefully()";
XLOG(DBG1) << "number of unloaded inodes transferred on graceful remount: "
<< takeoverData.unloadedInodes.size();
<< takeoverData.unloadedInodes_ref()->size();
// Create a new EdenMount object.
edenMount_ = EdenMount::create(

View File

@ -226,14 +226,18 @@ std::unordered_map<pid_t, AccessCounts> ProcessAccessLog::getAccessCounts(
// Transfer to a Thrift map
std::unordered_map<pid_t, AccessCounts> accessCountsByPid;
for (auto& [pid, accessCounts] : bucket.accessCountsByPid) {
accessCountsByPid[pid].fuseReads = accessCounts[AccessType::FuseRead];
accessCountsByPid[pid].fuseWrites = accessCounts[AccessType::FuseWrite];
accessCountsByPid[pid].fuseTotal = accessCounts[AccessType::FuseRead] +
*accessCountsByPid[pid].fuseReads_ref() =
accessCounts[AccessType::FuseRead];
*accessCountsByPid[pid].fuseWrites_ref() =
accessCounts[AccessType::FuseWrite];
*accessCountsByPid[pid].fuseTotal_ref() =
accessCounts[AccessType::FuseRead] +
accessCounts[AccessType::FuseWrite] +
accessCounts[AccessType::FuseOther];
accessCountsByPid[pid].fuseBackingStoreImports =
*accessCountsByPid[pid].fuseBackingStoreImports_ref() =
accessCounts[AccessType::FuseBackingStoreImport];
accessCountsByPid[pid].fuseDurationNs = accessCounts.duration.count();
*accessCountsByPid[pid].fuseDurationNs_ref() =
accessCounts.duration.count();
}
return accessCountsByPid;
}

View File

@ -44,10 +44,10 @@ TEST(ProcessAccessLog, accessIncrementsAccessCount) {
log.recordAccess(pid, ProcessAccessLog::AccessType::FuseBackingStoreImport);
auto ac = AccessCounts{};
ac.fuseTotal = 3;
ac.fuseReads = 1;
ac.fuseWrites = 1;
ac.fuseBackingStoreImports = 1;
*ac.fuseTotal_ref() = 3;
*ac.fuseReads_ref() = 1;
*ac.fuseWrites_ref() = 1;
*ac.fuseBackingStoreImports_ref() = 1;
EXPECT_THAT(log.getAccessCounts(10s), Contains(std::pair{pid, ac}));
}

View File

@ -212,8 +212,8 @@ class FakeEdenServiceHandler : virtual public StreamingEdenServiceSvIf {
}
void getDaemonInfo(DaemonInfo& result) override {
result.pid = server_->getPid();
result.commandLine = server_->getCommandLine();
*result.pid_ref() = server_->getPid();
*result.commandLine_ref() = server_->getCommandLine();
}
void listMounts(std::vector<MountInfo>& /* results */) override {}