1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-26 04:00:59 +01:00

Before editting get-drvs.hh: DrvInfo

This commit is contained in:
Wouter den Breejen 2007-06-21 13:26:58 +00:00
parent 235c91dd7f
commit a4fda31ad5
12 changed files with 164 additions and 52 deletions

View file

@ -760,7 +760,7 @@ static Expr prim_toFile(EvalState & state, const ATermVector & args)
string contents = evalString(state, args[1], context); string contents = evalString(state, args[1], context);
PathSet refs; PathSet refs;
PathSet stateRefs; //TODO TODO TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PathSet stateRefs; //refs refers to the file references, there are no state references in this case.
for (PathSet::iterator i = context.begin(); i != context.end(); ++i) { for (PathSet::iterator i = context.begin(); i != context.end(); ++i) {
if (isDerivation(*i)) if (isDerivation(*i))

View file

@ -1687,8 +1687,6 @@ void DerivationGoal::computeClosure()
/* For this output path, find the references to other paths contained in it. */ /* For this output path, find the references to other paths contained in it. */
PathSet references = scanForReferences(path, allPaths); PathSet references = scanForReferences(path, allPaths);
/* For debugging, print out the referenced and unreferenced /* For debugging, print out the referenced and unreferenced
paths. */ paths. */
for (PathSet::iterator i = inputPaths.begin(); for (PathSet::iterator i = inputPaths.begin();
@ -1703,7 +1701,6 @@ void DerivationGoal::computeClosure()
allReferences[path] = references; allReferences[path] = references;
/* If the derivation specifies an `allowedReferences' /* If the derivation specifies an `allowedReferences'
attribute (containing a list of paths that the output may attribute (containing a list of paths that the output may
refer to), check that all references are in that list. !!! refer to), check that all references are in that list. !!!
@ -1746,15 +1743,18 @@ void DerivationGoal::computeClosure()
} }
/* /*
* TODO COMMENT * We first register alls paths as valid, and only scan for component references.
* * Now that those paths are registered as valid, we're able to call queryDeriversStatePath
*
* *
* We already scanned for Component references in Component paths
* Now we scan in Component paths for state references
* *
* If state is enabled for the path we:
* scan for and state references and component references in the state path
*/ */
for (DerivationOutputs::iterator i = drv.outputs.begin(); //TODO we scan for each output, be then we do multiple scans inside for the state path .....
i != drv.outputs.end(); ++i) for (DerivationOutputs::iterator i = drv.outputs.begin(); i != drv.outputs.end(); ++i)
{ {
Path path = i->second.path; Path path = i->second.path;
@ -1766,23 +1766,32 @@ void DerivationGoal::computeClosure()
for (PathSet::const_iterator i = allPaths.begin(); i != allPaths.end(); i++){ for (PathSet::const_iterator i = allPaths.begin(); i != allPaths.end(); i++){
Path componentPath = *i; Path componentPath = *i;
//printMsg(lvlError, format("COMP: %1%") % (*i));
if(isStateComponentTxn(txn, componentPath)){ if(isStateComponentTxn(txn, componentPath)){
printMsg(lvlError, format("COMP-STATE: %1%") % (*i)); //printMsg(lvlError, format("Scanning for state path: %1%") % (*i));
PathSet stateRefs = queryDeriversStatePath(txn, componentPath ,"*",getCallingUserName()); PathSet stateRefs = queryDeriversStatePath(txn, componentPath ,"*",getCallingUserName());
allStatePaths = mergePathSets(stateRefs, allStatePaths); allStatePaths = mergePathSets(stateRefs, allStatePaths);
} }
} }
PathSet stateReferences = scanForStateReferences(path, allStatePaths);
//We scan for state references in the component path
PathSet all_state_references = scanForStateReferences(path, allStatePaths);
//If state is enabled: Seaches for state and component references in the state path
if(isStateDrvTxn(txn, drv)){
Path statePath = drv.stateOutputs.find("state")->second.statepath;
PathSet state_references = scanForReferences(statePath, allPaths);
PathSet state_stateReferences = scanForStateReferences(statePath, allStatePaths);
all_state_references = mergePathSets(all_state_references, mergePathSets(state_references, state_stateReferences));
}
for (PathSet::const_iterator i = allStatePaths.begin(); i != allStatePaths.end(); i++){ for (PathSet::const_iterator i = allStatePaths.begin(); i != allStatePaths.end(); i++){
debug(format("all possible StatePaths: %1%") % (*i)); debug(format("all possible StatePaths: %1%") % (*i));
} }
for (PathSet::const_iterator i = stateReferences.begin(); i != stateReferences.end(); i++){ for (PathSet::const_iterator i = all_state_references.begin(); i != all_state_references.end(); i++){
debug(format("state References scanned: %1%") % (*i)); debug(format("state References scanned: %1%") % (*i));
} }
allStateReferences[path] = stateReferences; allStateReferences[path] = all_state_references;
} }
for (DerivationOutputs::iterator i = drv.outputs.begin(); for (DerivationOutputs::iterator i = drv.outputs.begin();

View file

@ -21,14 +21,13 @@ Path writeDerivation(const Derivation & drv, const string & name)
{ {
PathSet references; PathSet references;
references.insert(drv.inputSrcs.begin(), drv.inputSrcs.end()); references.insert(drv.inputSrcs.begin(), drv.inputSrcs.end());
for (DerivationInputs::const_iterator i = drv.inputDrvs.begin(); for (DerivationInputs::const_iterator i = drv.inputDrvs.begin(); i != drv.inputDrvs.end(); ++i)
i != drv.inputDrvs.end(); ++i)
references.insert(i->first); references.insert(i->first);
/* Note that the outputs of a derivation are *not* references /* Note that the outputs of a derivation are *not* references
(that can be missing (of course) and should not necessarily be (that can be missing (of course) and should not necessarily be
held during a garbage collection). */ held during a garbage collection). */
//TODO TODO TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //We only need to hash over inputSrcs and inputDrvs (I think ...)
PathSet stateReferences; PathSet stateReferences;
string suffix = name + drvExtension; string suffix = name + drvExtension;

View file

@ -44,7 +44,7 @@ static TableId dbValidPaths = 0;
paths. */ paths. */
static TableId dbReferences = 0; static TableId dbReferences = 0;
/* dbReferences :: Path -> [Path] /* dbStateReferences :: Path -> [Path]
This table lists the outgoing file system state references for each This table lists the outgoing file system state references for each
output path that has been built by a Nix derivation. These are output path that has been built by a Nix derivation. These are
@ -60,6 +60,13 @@ static TableId dbStateReferences = 0;
referrer. */ referrer. */
static TableId dbReferrers = 0; static TableId dbReferrers = 0;
/* dbStateReferrers :: Path -> Path
This table is just the reverse mapping of dbStateReferences. This table
can have duplicate keys, each corresponding value denoting a single
referrer. */
static TableId dbStateReferrers = 0;
/* dbSubstitutes :: Path -> [[Path]] /* dbSubstitutes :: Path -> [[Path]]
Each pair $(p, subs)$ tells Nix that it can use any of the Each pair $(p, subs)$ tells Nix that it can use any of the
@ -159,12 +166,13 @@ LocalStore::LocalStore(bool reserveSpace)
} }
dbValidPaths = nixDB.openTable("validpaths"); dbValidPaths = nixDB.openTable("validpaths");
dbReferences = nixDB.openTable("references"); dbReferences = nixDB.openTable("references");
dbReferrers = nixDB.openTable("referrers", true); /* must be sorted */ //TODO ADD STATE REFERERS? dbReferrers = nixDB.openTable("referrers", true); /* must be sorted */
dbSubstitutes = nixDB.openTable("substitutes"); dbSubstitutes = nixDB.openTable("substitutes");
dbDerivers = nixDB.openTable("derivers"); dbDerivers = nixDB.openTable("derivers");
dbStateInfo = nixDB.openTable("stateinfo"); dbStateInfo = nixDB.openTable("stateinfo");
dbStateCounters = nixDB.openTable("statecounters"); dbStateCounters = nixDB.openTable("statecounters");
dbStateReferences = nixDB.openTable("references_state"); dbStateReferences = nixDB.openTable("references_state");
dbStateReferrers = nixDB.openTable("referrers_state", true); /* must be sorted */
int curSchema = 0; int curSchema = 0;
Path schemaFN = nixDBPath + "/schema"; Path schemaFN = nixDBPath + "/schema";
@ -344,6 +352,16 @@ static PathSet getReferrers(const Transaction & txn, const Path & storePath)
return referrers; return referrers;
} }
static PathSet getStateReferrers(const Transaction & txn, const Path & storePath) //TODO this is just a copy of getReferrers, maybe make the function more generic?
{
PathSet referrers;
Strings keys;
nixDB.enumTable(txn, dbStateReferrers, keys, storePath + string(1, (char) 0));
for (Strings::iterator i = keys.begin(); i != keys.end(); ++i)
referrers.insert(stripPrefix(storePath, *i));
return referrers;
}
void setReferences(const Transaction & txn, const Path & storePath, void setReferences(const Transaction & txn, const Path & storePath,
const PathSet & references, const PathSet & stateReferences) const PathSet & references, const PathSet & stateReferences)
{ {
@ -369,20 +387,25 @@ void setReferences(const Transaction & txn, const Path & storePath,
nixDB.setStrings(txn, dbStateReferences, storePath, nixDB.setStrings(txn, dbStateReferences, storePath,
Paths(stateReferences.begin(), stateReferences.end())); Paths(stateReferences.begin(), stateReferences.end()));
//TODO THESE 2 ALSO FOR STATEREFS
/* Update the referrers mappings of all new referenced paths. */ /* Update the referrers mappings of all new referenced paths. */
for (PathSet::const_iterator i = references.begin(); for (PathSet::const_iterator i = references.begin(); i != references.end(); ++i)
i != references.end(); ++i)
if (oldReferences2.find(*i) == oldReferences2.end()) if (oldReferences2.find(*i) == oldReferences2.end())
nixDB.setString(txn, dbReferrers, addPrefix(*i, storePath), ""); nixDB.setString(txn, dbReferrers, addPrefix(*i, storePath), "");
/* Remove referrer mappings from paths that are no longer /* Update the state referrers mappings of all new referenced paths. */
references. */ for (PathSet::const_iterator i = stateReferences.begin(); i != stateReferences.end(); ++i)
for (Paths::iterator i = oldReferences.begin(); if (oldStateReferences2.find(*i) == oldStateReferences2.end())
i != oldReferences.end(); ++i) nixDB.setString(txn, dbStateReferrers, addPrefix(*i, storePath), "");
/* Remove referrer mappings from paths that are no longer references. */
for (Paths::iterator i = oldReferences.begin(); i != oldReferences.end(); ++i)
if (references.find(*i) == references.end()) if (references.find(*i) == references.end())
nixDB.delPair(txn, dbReferrers, addPrefix(*i, storePath)); nixDB.delPair(txn, dbReferrers, addPrefix(*i, storePath));
/* Remove referrer mappings from paths that are no longer state references. */
for (Paths::iterator i = oldStateReferences.begin(); i != oldStateReferences.end(); ++i)
if (stateReferences.find(*i) == stateReferences.end())
nixDB.delPair(txn, dbStateReferrers, addPrefix(*i, storePath));
} }
@ -415,15 +438,11 @@ void queryStateReferences(const Transaction & txn,
stateReferences.insert(stateReferences2.begin(), stateReferences2.end()); stateReferences.insert(stateReferences2.begin(), stateReferences2.end());
} }
void LocalStore::queryStateReferences(const Path & storePath, void LocalStore::queryStateReferences(const Path & storePath, PathSet & stateReferences)
PathSet & stateReferences)
{ {
nix::queryStateReferences(noTxn, storePath, stateReferences); nix::queryStateReferences(noTxn, storePath, stateReferences);
} }
//TODO getStateReferrers....
void queryReferrers(const Transaction & txn, void queryReferrers(const Transaction & txn,
const Path & storePath, PathSet & referrers) const Path & storePath, PathSet & referrers)
{ {
@ -441,6 +460,21 @@ void LocalStore::queryReferrers(const Path & storePath,
} }
void queryStateReferrers(const Transaction & txn, const Path & storePath, PathSet & stateReferrers)
{
if (!isRealisablePath(txn, storePath))
throw Error(format("path `%1%' is not valid") % storePath);
PathSet stateReferrers2 = getStateReferrers(txn, storePath);
stateReferrers.insert(stateReferrers2.begin(), stateReferrers2.end());
}
void LocalStore::queryStateReferrers(const Path & storePath, PathSet & stateReferrers)
{
nix::queryStateReferrers(noTxn, storePath, stateReferrers);
}
void setDeriver(const Transaction & txn, const Path & storePath, const Path & deriver) void setDeriver(const Transaction & txn, const Path & storePath, const Path & deriver)
{ {
assertStorePath(storePath); assertStorePath(storePath);
@ -498,19 +532,31 @@ bool LocalStore::isStateComponent(const Path & storePath)
return nix::isStateComponentTxn(noTxn, storePath); return nix::isStateComponentTxn(noTxn, storePath);
} }
//TODO Add and .. //TODO Add and ..
bool isStateDrv(const Path & drvPath) bool isStateDrvPathTxn(const Transaction & txn, const Path & drvPath)
{
Derivation drv = derivationFromPath(drvPath);
return isStateDrvTxn(txn, drv);
}
bool LocalStore::isStateDrvPath(const Path & isStateDrv)
{
return nix::isStateDrvPathTxn(noTxn, isStateDrv);
}
//TODO Add and ..
bool isStateDrvTxn(const Transaction & txn, Derivation drv)
{ {
Derivation drv = derivationFromPath(drvPath); //maybe redirect the out path to isStateComponent?
if (drv.stateOutputs.size() != 0) if (drv.stateOutputs.size() != 0)
return true; return true;
else else
return false; return false;
} }
bool LocalStore::isStateDrv(const Path & isStateDrv) bool LocalStore::isStateDrv(Derivation drv)
{ {
return nix::isStateDrv(isStateDrv); return nix::isStateDrvTxn(noTxn, drv);
} }
Path queryDeriver(const Transaction & txn, const Path & storePath) Path queryDeriver(const Transaction & txn, const Path & storePath)
@ -1088,6 +1134,9 @@ void deleteFromStore(const Path & _path, unsigned long long & bytesFreed)
if (*i != path && isValidPathTxn(txn, *i)) if (*i != path && isValidPathTxn(txn, *i))
throw PathInUse(format("cannot delete path `%1%' because it is in use by path `%2%'") % path % *i); throw PathInUse(format("cannot delete path `%1%' because it is in use by path `%2%'") % path % *i);
invalidatePath(txn, path); invalidatePath(txn, path);
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//Also delete stateReferrers?????
} }
txn.commit(); txn.commit();
@ -1178,6 +1227,7 @@ void verifyStore(bool checkContents)
} }
} }
//TODO also check state references and refererres
/* Check the `references' table. */ /* Check the `references' table. */
printMsg(lvlInfo, "checking the references table"); printMsg(lvlInfo, "checking the references table");
@ -1245,6 +1295,7 @@ void verifyStore(bool checkContents)
queryReferences(txn, from, references); queryReferences(txn, from, references);
PathSet stateReferences; PathSet stateReferences;
queryStateReferences(txn, from, stateReferences);
//TODO TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //TODO TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if (find(references.begin(), references.end(), to) == references.end()) { if (find(references.begin(), references.end(), to) == references.end()) {
@ -1257,7 +1308,7 @@ void verifyStore(bool checkContents)
} }
//TODO Check statecounters table.... //TODO Check stateinfo and statecounters table
txn.commit(); txn.commit();

View file

@ -51,6 +51,8 @@ public:
void queryReferrers(const Path & path, PathSet & referrers); void queryReferrers(const Path & path, PathSet & referrers);
void queryStateReferrers(const Path & path, PathSet & stateReferrers);
Path addToStore(const Path & srcPath, bool fixed = false, Path addToStore(const Path & srcPath, bool fixed = false,
bool recursive = false, string hashAlgo = "", bool recursive = false, string hashAlgo = "",
PathFilter & filter = defaultPathFilter); PathFilter & filter = defaultPathFilter);
@ -84,7 +86,9 @@ public:
bool isStateComponent(const Path & path); bool isStateComponent(const Path & path);
bool isStateDrv(const Path & drvpath); bool isStateDrvPath(const Path & drvpath);
bool isStateDrv(Derivation drv);
}; };
@ -140,7 +144,7 @@ void canonicalisePathMetaData(const Path & path);
/* Checks whether a path is valid. */ /* Checks whether a path is valid. */
bool isValidPathTxn(const Transaction & txn, const Path & path); bool isValidPathTxn(const Transaction & txn, const Path & path);
/* Sets the set of outgoing FS references for a store path. Use with /* Sets the set of outgoing FS (also state) references for a store path. Use with
care! */ care! */
void setReferences(const Transaction & txn, const Path & path, void setReferences(const Transaction & txn, const Path & path,
const PathSet & references, const PathSet & stateReferences); const PathSet & references, const PathSet & stateReferences);
@ -191,6 +195,10 @@ PathSet mergeNewDerivationIntoList(const Path & storepath, const Path & newdrv,
bool isStateComponentTxn(const Transaction & txn, const Path & path); bool isStateComponentTxn(const Transaction & txn, const Path & path);
bool isStateDrvPathTxn(const Transaction & txn, const Path & drvPath);
bool isStateDrvTxn(const Transaction & txn, Derivation drv);
} }

View file

@ -206,10 +206,8 @@ void RemoteStore::queryStateReferences(const Path & path,
writeInt(wopQueryStateReferences, to); writeInt(wopQueryStateReferences, to);
writeString(path, to); writeString(path, to);
processStderr(); processStderr();
PathSet stateReferences2 = readStorePaths(from);
//TODO TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stateReferences.insert(stateReferences2.begin(), stateReferences2.end());
// PathSet references2 = readStorePaths(from);
// references.insert(references2.begin(), references2.end());
} }
@ -224,6 +222,15 @@ void RemoteStore::queryReferrers(const Path & path,
referrers.insert(referrers2.begin(), referrers2.end()); referrers.insert(referrers2.begin(), referrers2.end());
} }
void RemoteStore::queryStateReferrers(const Path & path, PathSet & stateReferrers)
{
writeInt(wopQueryStateReferrers, to);
writeString(path, to);
processStderr();
PathSet stateReferrers2 = readStorePaths(from);
stateReferrers.insert(stateReferrers2.begin(), stateReferrers2.end());
}
Path RemoteStore::addToStore(const Path & _srcPath, bool fixed, Path RemoteStore::addToStore(const Path & _srcPath, bool fixed,
bool recursive, string hashAlgo, PathFilter & filter) bool recursive, string hashAlgo, PathFilter & filter)
@ -402,15 +409,22 @@ vector<int> RemoteStore::getStatePathsInterval(const PathSet & statePaths)
return intervals; return intervals;
} }
//TODO
bool RemoteStore::isStateComponent(const Path & path) bool RemoteStore::isStateComponent(const Path & path)
{ {
return false; return false;
} }
bool RemoteStore::isStateDrv(const Path & drvpath) //TODO
bool RemoteStore::isStateDrvPath(const Path & drvpath)
{ {
return false; return false;
} }
//TODO
bool RemoteStore::isStateDrv(Derivation drv)
{
return false;
}
} }

View file

@ -39,6 +39,8 @@ public:
void queryReferrers(const Path & path, PathSet & referrers); void queryReferrers(const Path & path, PathSet & referrers);
void queryStateReferrers(const Path & path, PathSet & stateReferrers);
Path addToStore(const Path & srcPath, bool fixed = false, Path addToStore(const Path & srcPath, bool fixed = false,
bool recursive = false, string hashAlgo = "", bool recursive = false, string hashAlgo = "",
PathFilter & filter = defaultPathFilter); PathFilter & filter = defaultPathFilter);
@ -72,7 +74,9 @@ public:
bool isStateComponent(const Path & path); bool isStateComponent(const Path & path);
bool isStateDrv(const Path & drvpath); bool isStateDrvPath(const Path & drvpath);
bool isStateDrv(Derivation drv);
private: private:

View file

@ -83,6 +83,10 @@ public:
virtual void queryReferrers(const Path & path, virtual void queryReferrers(const Path & path,
PathSet & referrers) = 0; PathSet & referrers) = 0;
/* Queries the set of incoming FS state-references for a store path.
The result is not cleared. */
virtual void queryStateReferrers(const Path & path, PathSet & stateReferrers) = 0;
/* Copy the contents of a path to the store and register the /* Copy the contents of a path to the store and register the
validity the resulting path. The resulting path is returned. validity the resulting path. The resulting path is returned.
If `fixed' is true, then the output of a fixed-output If `fixed' is true, then the output of a fixed-output
@ -196,7 +200,10 @@ public:
virtual bool isStateComponent(const Path & path) = 0; virtual bool isStateComponent(const Path & path) = 0;
/* TODO */ /* TODO */
virtual bool isStateDrv(const Path & drvpath) = 0; virtual bool isStateDrvPath(const Path & drvpath) = 0;
/* TODO */
virtual bool isStateDrv(Derivation drv) = 0;
}; };

View file

@ -147,6 +147,17 @@ static void opShowStateReposRootPath(Strings opFlags, Strings opArgs)
} }
//TODO
static void recheckrefsinstaterecursive()
{
//PathSet state_references = scanForReferences(statePath, allPaths);
//PathSet state_stateReferences = scanForStateReferences(statePath, allStatePaths);
}
static void opRunComponent(Strings opFlags, Strings opArgs) static void opRunComponent(Strings opFlags, Strings opArgs)
{ {
//get the derivation of the current component //get the derivation of the current component
@ -356,7 +367,7 @@ void run(Strings args)
store = openStore(); store = openStore();
printMsg(lvlError, format("1: %1%") % bool2string( store->isStateComponent("/nix/store/7xkw5fkz5yw7dpx0pc6l12bh9a56135c-hellostateworld-1.0") ) ); printMsg(lvlError, format("1: %1%") % bool2string( store->isStateComponent("/nix/store/7xkw5fkz5yw7dpx0pc6l12bh9a56135c-hellostateworld-1.0") ) );
printMsg(lvlError, format("2: %1%") % bool2string( store->isStateComponent("/nix/store/05441jm8xmsidqm43ivk0micckf0mr2m-nvidiaDrivers") ) ); printMsg(lvlError, format("2: %1%") % bool2string( store->isStateComponent("/nix/store/05441jm8xmsidqm43ivk0micckf0mr2m-nvidiaDrivers") ) );
printMsg(lvlError, format("3: %1%") % bool2string( store->isStateDrv("/nix/store/2hpx60ibdfv2pslg4rjvp177frijamvi-hellostateworld-1.0.drv") ) ); printMsg(lvlError, format("3: %1%") % bool2string( store->isStateDrvPath("/nix/store/2hpx60ibdfv2pslg4rjvp177frijamvi-hellostateworld-1.0.drv") ) );
return; return;
/* test */ /* test */
@ -394,6 +405,11 @@ void run(Strings args)
--user=... --user=...
--show-state-references- -rev = ...
--show-state-references-current //in nix-store
--show-state-referrers- -rev = ...
--show-state-referrers-current //in nix-store
*/ */
else else

View file

@ -34,6 +34,7 @@ Query flags:
--references: print all paths referenced by the given path --references: print all paths referenced by the given path
--references-state: print all state paths referenced by the given path --references-state: print all state paths referenced by the given path
--referrers: print all paths directly refering to the given path --referrers: print all paths directly refering to the given path
--referrers-state: print all state paths directly refering to the given path
--referrers-closure: print all paths (in)directly refering to the given path --referrers-closure: print all paths (in)directly refering to the given path
--tree: print a tree showing the dependency graph of the given paths --tree: print a tree showing the dependency graph of the given paths
--graph: print a dot graph rooted at given paths --graph: print a dot graph rooted at given paths

View file

@ -257,7 +257,7 @@ static void printTree(const Path & path,
/* Perform various sorts of queries. */ /* Perform various sorts of queries. */
static void opQuery(Strings opFlags, Strings opArgs) static void opQuery(Strings opFlags, Strings opArgs)
{ {
enum { qOutputs, qRequisites, qReferences, qStateReferences, qReferrers enum { qOutputs, qRequisites, qReferences, qStateReferences, qReferrers, qStateReferrers
, qReferrersClosure, qDeriver, qBinding, qHash , qReferrersClosure, qDeriver, qBinding, qHash
, qTree, qGraph, qResolve } query = qOutputs; , qTree, qGraph, qResolve } query = qOutputs;
bool useOutput = false; bool useOutput = false;
@ -272,6 +272,7 @@ static void opQuery(Strings opFlags, Strings opArgs)
else if (*i == "--references") query = qReferences; else if (*i == "--references") query = qReferences;
else if (*i == "--references-state") query = qStateReferences; else if (*i == "--references-state") query = qStateReferences;
else if (*i == "--referrers" || *i == "--referers") query = qReferrers; else if (*i == "--referrers" || *i == "--referers") query = qReferrers;
else if (*i == "--referrers-state" || *i == "--referers-state") query = qStateReferrers;
else if (*i == "--referrers-closure" || *i == "--referers-closure") query = qReferrersClosure; else if (*i == "--referrers-closure" || *i == "--referers-closure") query = qReferrersClosure;
else if (*i == "--deriver" || *i == "-d") query = qDeriver; else if (*i == "--deriver" || *i == "-d") query = qDeriver;
else if (*i == "--binding" || *i == "-b") { else if (*i == "--binding" || *i == "-b") {
@ -308,6 +309,7 @@ static void opQuery(Strings opFlags, Strings opArgs)
case qReferences: case qReferences:
case qStateReferences: case qStateReferences:
case qReferrers: case qReferrers:
case qStateReferrers:
case qReferrersClosure: { case qReferrersClosure: {
PathSet paths; PathSet paths;
for (Strings::iterator i = opArgs.begin(); for (Strings::iterator i = opArgs.begin();
@ -319,6 +321,7 @@ static void opQuery(Strings opFlags, Strings opArgs)
else if (query == qReferences) store->queryReferences(path, paths); else if (query == qReferences) store->queryReferences(path, paths);
else if (query == qStateReferences) store->queryStateReferences(path, paths); else if (query == qStateReferences) store->queryStateReferences(path, paths);
else if (query == qReferrers) store->queryReferrers(path, paths); else if (query == qReferrers) store->queryReferrers(path, paths);
else if (query == qStateReferrers) store->queryStateReferrers(path, paths);
else if (query == qReferrersClosure) computeFSClosure(path, paths, true); else if (query == qReferrersClosure) computeFSClosure(path, paths, true);
} }
Paths sorted = topoSortPaths(paths); Paths sorted = topoSortPaths(paths);

View file

@ -284,8 +284,8 @@ static void performOp(Source & from, Sink & to, unsigned int op)
PathSet paths; PathSet paths;
if (op == wopQueryStateReferences) if (op == wopQueryStateReferences)
store->queryStateReferences(path, paths); store->queryStateReferences(path, paths);
//else else
// store->queryStateReferrers(path, paths); //TODO TODO implemnt function, and then commen out !!!!!!!!!!!!!!!!!!!!! store->queryStateReferrers(path, paths); //TODO Does this work???
stopWork(); stopWork();
writeStringSet(paths, to); writeStringSet(paths, to);
break; break;