aboutsummaryrefslogtreecommitdiff
path: root/src/nix-store
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2005-04-08 12:57:16 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2005-04-08 12:57:16 +0000
commit4271385a73d5e073ddfa7e4a75ab0ae5bef50439 (patch)
treebcf10b9ca82dd5c700cb9f55f0cb9678694f506d /src/nix-store
parent90905634edbbf55447f2eebd84524e556b3f0750 (diff)
* Make `nix-store --query --tree' work on non-derivations (i.e., on
any store path).
Diffstat (limited to 'src/nix-store')
-rw-r--r--src/nix-store/main.cc28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/nix-store/main.cc b/src/nix-store/main.cc
index 6de26dabc..496924677 100644
--- a/src/nix-store/main.cc
+++ b/src/nix-store/main.cc
@@ -233,38 +233,36 @@ static Paths topoSort(const PathSet & paths)
}
-static void printDrvTree(const Path & drvPath,
+static void printTree(const Path & path,
const string & firstPad, const string & tailPad, PathSet & done)
{
- if (done.find(drvPath) != done.end()) {
- cout << format("%1%%2% [...]\n") % firstPad % drvPath;
+ if (done.find(path) != done.end()) {
+ cout << format("%1%%2% [...]\n") % firstPad % path;
return;
}
- done.insert(drvPath);
+ done.insert(path);
- cout << format("%1%%2%\n") % firstPad % drvPath;
-
- Derivation drv = derivationFromPath(drvPath);
+ cout << format("%1%%2%\n") % firstPad % path;
+
+ PathSet references;
+ queryReferences(noTxn, path, references);
+#if 0
for (PathSet::iterator i = drv.inputSrcs.begin();
i != drv.inputSrcs.end(); ++i)
cout << format("%1%%2%\n") % (tailPad + treeConn) % *i;
-
- PathSet inputs;
- for (DerivationInputs::iterator i = drv.inputDrvs.begin();
- i != drv.inputDrvs.end(); ++i)
- inputs.insert(i->first);
+#endif
/* Topologically sort under the relation A < B iff A \in
closure(B). That is, if derivation A is an (possibly indirect)
input of B, then A is printed first. This has the effect of
flattening the tree, preventing deeply nested structures. */
- Paths sorted = topoSort(inputs);
+ Paths sorted = topoSort(references);
reverse(sorted.begin(), sorted.end());
for (Paths::iterator i = sorted.begin(); i != sorted.end(); ++i) {
Paths::iterator j = i; ++j;
- printDrvTree(*i, tailPad + treeConn,
+ printTree(*i, tailPad + treeConn,
j == sorted.end() ? tailPad + treeNull : tailPad + treeLine,
done);
}
@@ -377,7 +375,7 @@ static void opQuery(Strings opFlags, Strings opArgs)
PathSet done;
for (Strings::iterator i = opArgs.begin();
i != opArgs.end(); ++i)
- printDrvTree(fixPath(*i), "", "", done);
+ printTree(fixPath(*i), "", "", done);
break;
}