diff --git a/eden/fs/store/hg/HgBackingStore.cpp b/eden/fs/store/hg/HgBackingStore.cpp index 3b22475061..4f15ae2151 100644 --- a/eden/fs/store/hg/HgBackingStore.cpp +++ b/eden/fs/store/hg/HgBackingStore.cpp @@ -22,6 +22,7 @@ #include "eden/fs/model/Hash.h" #include "eden/fs/model/Tree.h" #include "eden/fs/store/LocalStore.h" +#include "eden/fs/store/SerializedBlobMetadata.h" #include "eden/fs/store/StoreResult.h" #include "eden/fs/store/hg/HgImportPyError.h" #include "eden/fs/store/hg/HgImporter.h" @@ -397,6 +398,17 @@ Future> HgBackingStore::importTreeImpl( entries.emplace_back( proxyHash, entryName.stringPiece(), entry.getType()); + + if (entry.getContentSha1() && entry.getSize()) { + BlobMetadata metadata{*entry.getContentSha1(), *entry.getSize()}; + + SerializedBlobMetadata metadataBytes(metadata); + auto hashSlice = proxyHash.getBytes(); + writeBatch->put( + KeySpace::BlobMetaDataFamily, + hashSlice, + metadataBytes.slice()); + } } auto tree = make_unique(std::move(entries), edenTreeID); diff --git a/eden/fs/store/mononoke/MononokeBackingStore.cpp b/eden/fs/store/mononoke/MononokeBackingStore.cpp index 6d588c9771..f54221a4bf 100644 --- a/eden/fs/store/mononoke/MononokeBackingStore.cpp +++ b/eden/fs/store/mononoke/MononokeBackingStore.cpp @@ -169,6 +169,7 @@ std::unique_ptr convertBufToTree( } std::vector entries; + entries.reserve(parsed.size()); for (auto i = parsed.begin(); i != parsed.end(); ++i) { auto name = i->at("name").asString(); auto hash = Hash(i->at("hash").asString()); @@ -186,7 +187,19 @@ std::unique_ptr convertBufToTree( throw std::runtime_error(folly::to( "unknown file type from mononoke: ", str_type)); } - entries.push_back(TreeEntry(hash, name, file_type)); + + auto contentSha1 = i->get_ptr("content_sha1"); + auto size = i->get_ptr("size"); + if (contentSha1 && !contentSha1->isNull() && size && !size->isNull()) { + entries.emplace_back( + hash, + name, + file_type, + static_cast(size->asInt()), + Hash(contentSha1->asString())); + } else { + entries.emplace_back(hash, name, file_type); + } } return std::make_unique(std::move(entries), id); }