mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 03:56:01 +01:00
Clean up nix why-depends store accessor usage, and put back store dir in output
With this change, the store-wide `getFSAccessor` has only one usage left
--- the evaluator. If we get rid of that (as is planned), we can then
remove that method altogether, simplifying `Store`. Hurray!
I removed the store dir by mistake from the pretty-printed (for humans)
output in eb643d034f. That change was not
supposed to change output.
This commit is contained in:
parent
9f26c20ebd
commit
d26dee20b2
1 changed files with 7 additions and 12 deletions
|
|
@ -108,8 +108,6 @@ struct CmdWhyDepends : SourceExprCommand, MixOperateOnOptions
|
||||||
auto dependencyPath = *optDependencyPath;
|
auto dependencyPath = *optDependencyPath;
|
||||||
auto dependencyPathHash = dependencyPath.hashPart();
|
auto dependencyPathHash = dependencyPath.hashPart();
|
||||||
|
|
||||||
auto accessor = store->getFSAccessor();
|
|
||||||
|
|
||||||
auto const inf = std::numeric_limits<size_t>::max();
|
auto const inf = std::numeric_limits<size_t>::max();
|
||||||
|
|
||||||
struct Node
|
struct Node
|
||||||
|
|
@ -172,8 +170,6 @@ struct CmdWhyDepends : SourceExprCommand, MixOperateOnOptions
|
||||||
{};
|
{};
|
||||||
|
|
||||||
printNode = [&](Node & node, const std::string & firstPad, const std::string & tailPad) {
|
printNode = [&](Node & node, const std::string & firstPad, const std::string & tailPad) {
|
||||||
CanonPath pathS(node.path.to_string());
|
|
||||||
|
|
||||||
assert(node.dist != inf);
|
assert(node.dist != inf);
|
||||||
if (precise) {
|
if (precise) {
|
||||||
logger->cout(
|
logger->cout(
|
||||||
|
|
@ -181,7 +177,7 @@ struct CmdWhyDepends : SourceExprCommand, MixOperateOnOptions
|
||||||
firstPad,
|
firstPad,
|
||||||
node.visited ? "\e[38;5;244m" : "",
|
node.visited ? "\e[38;5;244m" : "",
|
||||||
firstPad != "" ? "→ " : "",
|
firstPad != "" ? "→ " : "",
|
||||||
pathS.abs());
|
store->printStorePath(node.path));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.path == dependencyPath && !all && packagePath != dependencyPath)
|
if (node.path == dependencyPath && !all && packagePath != dependencyPath)
|
||||||
|
|
@ -211,13 +207,13 @@ struct CmdWhyDepends : SourceExprCommand, MixOperateOnOptions
|
||||||
contain the reference. */
|
contain the reference. */
|
||||||
std::map<std::string, Strings> hits;
|
std::map<std::string, Strings> hits;
|
||||||
|
|
||||||
std::function<void(const CanonPath &)> visitPath;
|
auto accessor = store->getFSAccessor(node.path);
|
||||||
|
|
||||||
visitPath = [&](const CanonPath & p) {
|
auto visitPath = [&](this auto && recur, const CanonPath & p) -> void {
|
||||||
auto st = accessor->maybeLstat(p);
|
auto st = accessor->maybeLstat(p);
|
||||||
assert(st);
|
assert(st);
|
||||||
|
|
||||||
auto p2 = p == pathS ? "/" : p.abs().substr(pathS.abs().size() + 1);
|
auto p2 = p.isRoot() ? p.abs() : p.rel();
|
||||||
|
|
||||||
auto getColour = [&](const std::string & hash) {
|
auto getColour = [&](const std::string & hash) {
|
||||||
return hash == dependencyPathHash ? ANSI_GREEN : ANSI_BLUE;
|
return hash == dependencyPathHash ? ANSI_GREEN : ANSI_BLUE;
|
||||||
|
|
@ -226,7 +222,7 @@ struct CmdWhyDepends : SourceExprCommand, MixOperateOnOptions
|
||||||
if (st->type == SourceAccessor::Type::tDirectory) {
|
if (st->type == SourceAccessor::Type::tDirectory) {
|
||||||
auto names = accessor->readDirectory(p);
|
auto names = accessor->readDirectory(p);
|
||||||
for (auto & [name, type] : names)
|
for (auto & [name, type] : names)
|
||||||
visitPath(p / name);
|
recur(p / name);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (st->type == SourceAccessor::Type::tRegular) {
|
else if (st->type == SourceAccessor::Type::tRegular) {
|
||||||
|
|
@ -264,7 +260,7 @@ struct CmdWhyDepends : SourceExprCommand, MixOperateOnOptions
|
||||||
// FIXME: should use scanForReferences().
|
// FIXME: should use scanForReferences().
|
||||||
|
|
||||||
if (precise)
|
if (precise)
|
||||||
visitPath(pathS);
|
visitPath(CanonPath::root);
|
||||||
|
|
||||||
for (auto & ref : refs) {
|
for (auto & ref : refs) {
|
||||||
std::string hash(ref.second->path.hashPart());
|
std::string hash(ref.second->path.hashPart());
|
||||||
|
|
@ -280,13 +276,12 @@ struct CmdWhyDepends : SourceExprCommand, MixOperateOnOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!precise) {
|
if (!precise) {
|
||||||
auto pathS = store->printStorePath(ref.second->path);
|
|
||||||
logger->cout(
|
logger->cout(
|
||||||
"%s%s%s%s" ANSI_NORMAL,
|
"%s%s%s%s" ANSI_NORMAL,
|
||||||
firstPad,
|
firstPad,
|
||||||
ref.second->visited ? "\e[38;5;244m" : "",
|
ref.second->visited ? "\e[38;5;244m" : "",
|
||||||
last ? treeLast : treeConn,
|
last ? treeLast : treeConn,
|
||||||
pathS);
|
store->printStorePath(ref.second->path));
|
||||||
node.visited = true;
|
node.visited = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue