diff --git a/eden/fs/model/Hash.h b/eden/fs/model/Hash.h index 6a13697194..f87f0c3a15 100644 --- a/eden/fs/model/Hash.h +++ b/eden/fs/model/Hash.h @@ -156,5 +156,13 @@ struct hash { return hash.getHashCode(); } }; - } // namespace std + +template <> +struct fmt::formatter : formatter { + template + auto format(const facebook::eden::Hash20& h, Context& ctx) const { + // TODO: Avoid allocation here. + return formatter::format(h.toString(), ctx); + } +}; diff --git a/eden/fs/model/test/HashTest.cpp b/eden/fs/model/test/HashTest.cpp index 5547232daf..28186df9ea 100644 --- a/eden/fs/model/test/HashTest.cpp +++ b/eden/fs/model/test/HashTest.cpp @@ -219,3 +219,10 @@ TEST(Hash20, getHashCode) { // using 64 bits of data to contribute to the hash code. EXPECT_EQ(folly::Endian::big(0xfaceb00cdeadbeef), testHash.getHashCode()); } + +TEST(Hash20, formatting) { + Hash20 h("0123456789abcdeffedcba987654321076543210"); + EXPECT_EQ( + "0123456789abcdeffedcba987654321076543210", folly::to(h)); + EXPECT_EQ("0123456789abcdeffedcba987654321076543210", fmt::to_string(h)); +} diff --git a/eden/fs/store/hg/HgImporter.cpp b/eden/fs/store/hg/HgImporter.cpp index 1d6582508c..0aa25fbd1d 100644 --- a/eden/fs/store/hg/HgImporter.cpp +++ b/eden/fs/store/hg/HgImporter.cpp @@ -22,9 +22,7 @@ #include #include #include -#ifndef _WIN32 #include -#endif #include