diff --git a/lix/legacy/dotgraph.cc b/lix/legacy/dotgraph.cc index cd7e8e75e..b60bb1cd0 100644 --- a/lix/legacy/dotgraph.cc +++ b/lix/legacy/dotgraph.cc @@ -4,9 +4,7 @@ #include "lix/libutil/result.hh" #include - - -using std::cout; +#include namespace nix { @@ -42,31 +40,31 @@ static std::string makeNode(std::string_view id, std::string_view label, dotQuote(id), dotQuote(label), dotQuote(colour)); } - -kj::Promise> printDotGraph(ref store, StorePathSet && roots) +kj::Promise> printDotGraph(ref store, StorePathSet && roots) try { StorePathSet workList(std::move(roots)); StorePathSet doneSet; + std::stringstream result; - cout << "digraph G {\n"; + result << "digraph G {\n"; while (!workList.empty()) { auto path = std::move(workList.extract(workList.begin()).value()); if (!doneSet.insert(path).second) continue; - cout << makeNode(std::string(path.to_string()), path.name(), "#ff0000"); + result << makeNode(std::string(path.to_string()), path.name(), "#ff0000"); for (auto & p : TRY_AWAIT(store->queryPathInfo(path))->references) { if (p != path) { workList.insert(p); - cout << makeEdge(std::string(p.to_string()), std::string(path.to_string())); + result << makeEdge(std::string(p.to_string()), std::string(path.to_string())); } } } - cout << "}\n"; - co_return result::success(); + result << "}\n"; + co_return result.str(); } catch (...) { co_return result::current_exception(); } diff --git a/lix/legacy/dotgraph.hh b/lix/legacy/dotgraph.hh index 2175ca2d6..49c801b6a 100644 --- a/lix/legacy/dotgraph.hh +++ b/lix/legacy/dotgraph.hh @@ -5,6 +5,5 @@ namespace nix { -kj::Promise> printDotGraph(ref store, StorePathSet && roots); - +kj::Promise> printDotGraph(ref store, StorePathSet && roots); } diff --git a/lix/legacy/nix-store.cc b/lix/legacy/nix-store.cc index b72640814..6672b41bb 100644 --- a/lix/legacy/nix-store.cc +++ b/lix/legacy/nix-store.cc @@ -490,7 +490,7 @@ opQuery(std::shared_ptr store, AsyncIoRoot & aio, Strings opFlags, String { roots.insert(j); } - aio.blockOn(printDotGraph(ref::unsafeFromPtr(store), std::move(roots))); + std::cout << aio.blockOn(printDotGraph(ref::unsafeFromPtr(store), std::move(roots))); break; }