diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nix-store/dotgraph.cc | 50 | ||||
-rw-r--r-- | src/nix-store/main.cc | 28 |
2 files changed, 44 insertions, 34 deletions
diff --git a/src/nix-store/dotgraph.cc b/src/nix-store/dotgraph.cc index 8fead9c0c6b8..fa8d353bc4fc 100644 --- a/src/nix-store/dotgraph.cc +++ b/src/nix-store/dotgraph.cc @@ -2,7 +2,6 @@ #include "build.hh" -#if 0 static string dotQuote(const string & s) { return "\"" + s + "\""; @@ -40,10 +39,8 @@ static string makeNode(const string & id, const string & label, static string symbolicName(const string & path) { string p = baseNameOf(path); - if (isHash(string(p, 0, md5HashSize * 2)) && - p[md5HashSize * 2] == '-') - p = string(p, md5HashSize * 2 + 1); - return p; + int dash = p.find('-'); + return string(p, dash + 1); } @@ -53,12 +50,13 @@ string pathLabel(const Path & nePath, const string & elemPath) } +#if 0 void printClosure(const Path & nePath, const StoreExpr & fs) { PathSet workList(fs.closure.roots); PathSet doneSet; - for (PathSet::iterator i = workList.begin(); i != workList.end(); i++) { + for (PathSet::iterator i = workList.begin(); i != workList.end(); ++i) { cout << makeEdge(pathLabel(nePath, *i), nePath); } @@ -74,7 +72,7 @@ void printClosure(const Path & nePath, const StoreExpr & fs) throw Error(format("bad closure, missing path `%1%'") % path); for (StringSet::const_iterator i = elem->second.refs.begin(); - i != elem->second.refs.end(); i++) + i != elem->second.refs.end(); ++i) { workList.insert(*i); cout << makeEdge(pathLabel(nePath, *i), pathLabel(nePath, path)); @@ -85,6 +83,7 @@ void printClosure(const Path & nePath, const StoreExpr & fs) } } } +#endif void printDotGraph(const PathSet & roots) @@ -95,43 +94,56 @@ void printDotGraph(const PathSet & roots) cout << "digraph G {\n"; while (!workList.empty()) { - Path nePath = *(workList.begin()); - workList.erase(nePath); + Path path = *(workList.begin()); + workList.erase(path); - if (doneSet.find(nePath) == doneSet.end()) { - doneSet.insert(nePath); + if (doneSet.find(path) != doneSet.end()) continue; + doneSet.insert(path); - StoreExpr ne = storeExprFromPath(nePath); + cout << makeNode(path, symbolicName(path), "#ff0000"); + + PathSet references; + queryReferences(noTxn, path, references); + + for (PathSet::iterator i = references.begin(); + i != references.end(); ++i) + { + workList.insert(*i); + cout << makeEdge(*i, path); + } + + +#if 0 + StoreExpr ne = storeExprFromPath(path); string label, colour; if (ne.type == StoreExpr::neDerivation) { for (PathSet::iterator i = ne.derivation.inputs.begin(); - i != ne.derivation.inputs.end(); i++) + i != ne.derivation.inputs.end(); ++i) { workList.insert(*i); - cout << makeEdge(*i, nePath); + cout << makeEdge(*i, path); } label = "derivation"; colour = "#00ff00"; for (StringPairs::iterator i = ne.derivation.env.begin(); - i != ne.derivation.env.end(); i++) + i != ne.derivation.env.end(); ++i) if (i->first == "name") label = i->second; } else if (ne.type == StoreExpr::neClosure) { label = "<closure>"; colour = "#00ffff"; - printClosure(nePath, ne); + printClosure(path, ne); } else abort(); - cout << makeNode(nePath, label, colour); - } + cout << makeNode(path, label, colour); +#endif } cout << "}\n"; } -#endif diff --git a/src/nix-store/main.cc b/src/nix-store/main.cc index 42783e108a2f..ff226f986387 100644 --- a/src/nix-store/main.cc +++ b/src/nix-store/main.cc @@ -67,20 +67,20 @@ static void opRealise(Strings opFlags, Strings opArgs) if (!opFlags.empty()) throw UsageError("unknown flag"); for (Strings::iterator i = opArgs.begin(); - i != opArgs.end(); i++) + i != opArgs.end(); ++i) *i = fixPath(*i); if (opArgs.size() > 1) { PathSet drvPaths; for (Strings::iterator i = opArgs.begin(); - i != opArgs.end(); i++) + i != opArgs.end(); ++i) if (isDerivation(*i)) drvPaths.insert(*i); buildDerivations(drvPaths); } for (Strings::iterator i = opArgs.begin(); - i != opArgs.end(); i++) + i != opArgs.end(); ++i) cout << format("%1%\n") % realisePath(*i); } @@ -91,7 +91,7 @@ static void opAdd(Strings opFlags, Strings opArgs) { if (!opFlags.empty()) throw UsageError("unknown flag"); - for (Strings::iterator i = opArgs.begin(); i != opArgs.end(); i++) + for (Strings::iterator i = opArgs.begin(); i != opArgs.end(); ++i) cout << format("%1%\n") % addToStore(*i); } @@ -145,7 +145,7 @@ static Path maybeUseOutput(const Path & storePath, bool useOutput, bool forceRea static void printPathSet(const PathSet & paths) { for (PathSet::iterator i = paths.begin(); - i != paths.end(); i++) + i != paths.end(); ++i) cout << format("%s\n") % *i; } @@ -263,7 +263,7 @@ static void opQuery(Strings opFlags, Strings opArgs) case qOutputs: { for (Strings::iterator i = opArgs.begin(); - i != opArgs.end(); i++) + i != opArgs.end(); ++i) { *i = fixPath(*i); if (forceRealise) realisePath(*i); @@ -279,7 +279,7 @@ static void opQuery(Strings opFlags, Strings opArgs) case qReferersClosure: { PathSet paths; for (Strings::iterator i = opArgs.begin(); - i != opArgs.end(); i++) + i != opArgs.end(); ++i) { Path path = maybeUseOutput(fixPath(*i), useOutput, forceRealise); if (query == qRequisites) @@ -294,7 +294,7 @@ static void opQuery(Strings opFlags, Strings opArgs) case qDeriver: for (Strings::iterator i = opArgs.begin(); - i != opArgs.end(); i++) + i != opArgs.end(); ++i) { Path deriver = queryDeriver(noTxn, fixPath(*i)); cout << format("%1%\n") % @@ -304,7 +304,7 @@ static void opQuery(Strings opFlags, Strings opArgs) case qBinding: for (Strings::iterator i = opArgs.begin(); - i != opArgs.end(); i++) + i != opArgs.end(); ++i) { *i = fixPath(*i); Derivation drv = derivationFromPath(*i); @@ -318,7 +318,7 @@ static void opQuery(Strings opFlags, Strings opArgs) case qHash: for (Strings::iterator i = opArgs.begin(); - i != opArgs.end(); i++) + i != opArgs.end(); ++i) { Path path = maybeUseOutput(fixPath(*i), useOutput, forceRealise); Hash hash = queryPathHash(path); @@ -330,21 +330,19 @@ static void opQuery(Strings opFlags, Strings opArgs) case qTree: { PathSet done; for (Strings::iterator i = opArgs.begin(); - i != opArgs.end(); i++) + i != opArgs.end(); ++i) printDrvTree(fixPath(*i), "", "", done); break; } -#if 0 case qGraph: { PathSet roots; for (Strings::iterator i = opArgs.begin(); - i != opArgs.end(); i++) - roots.insert(maybeNormalise(*i, normalise, realise)); + i != opArgs.end(); ++i) + roots.insert(maybeUseOutput(fixPath(*i), useOutput, forceRealise)); printDotGraph(roots); break; } -#endif default: abort(); |