* In nix-store: added query `--referers-closure' that returns the
closure of the referers relation rather than the references relation, i.e., the set of all paths that directly or indirectly refer to the given path. Note that contrary to the references closure this set is not fixed; it can change as paths are added to or removed from the store.
This commit is contained in:
parent
80faa2f98a
commit
52bf9b86bb
5 changed files with 31 additions and 10 deletions
|
|
@ -21,9 +21,12 @@ Derivation derivationFromPath(const Path & drvPath);
|
|||
|
||||
/* Place in `paths' the set of all store paths in the file system
|
||||
closure of `storePath'; that is, all paths than can be directly or
|
||||
indirectly reached from it. `paths' is not cleared. */
|
||||
indirectly reached from it. `paths' is not cleared. If
|
||||
`flipDirection' is true, the set of paths that can reach
|
||||
`storePath' is returned; that is, the closures under the `referers'
|
||||
relation instead of the `references' relation is returned. */
|
||||
void computeFSClosure(const Path & storePath,
|
||||
PathSet & paths);
|
||||
PathSet & paths, bool flipDirection = false);
|
||||
|
||||
/* Place in `paths' the set of paths that are required to `realise'
|
||||
the given store path, i.e., all paths necessary for valid
|
||||
|
|
|
|||
|
|
@ -12,17 +12,20 @@ Derivation derivationFromPath(const Path & drvPath)
|
|||
|
||||
|
||||
void computeFSClosure(const Path & storePath,
|
||||
PathSet & paths)
|
||||
PathSet & paths, bool flipDirection)
|
||||
{
|
||||
if (paths.find(storePath) != paths.end()) return;
|
||||
paths.insert(storePath);
|
||||
|
||||
PathSet references;
|
||||
queryReferences(storePath, references);
|
||||
if (flipDirection)
|
||||
queryReferers(storePath, references);
|
||||
else
|
||||
queryReferences(storePath, references);
|
||||
|
||||
for (PathSet::iterator i = references.begin();
|
||||
i != references.end(); ++i)
|
||||
computeFSClosure(*i, paths);
|
||||
computeFSClosure(*i, paths, flipDirection);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue