about summary refs log tree commit diff
path: root/src/libstore
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/build.hh7
-rw-r--r--src/libstore/misc.cc9
2 files changed, 11 insertions, 5 deletions
diff --git a/src/libstore/build.hh b/src/libstore/build.hh
index ed83d678ec66..52e7c9b9d5de 100644
--- a/src/libstore/build.hh
+++ b/src/libstore/build.hh
@@ -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
diff --git a/src/libstore/misc.cc b/src/libstore/misc.cc
index dbb9273f7955..802e576512f1 100644
--- a/src/libstore/misc.cc
+++ b/src/libstore/misc.cc
@@ -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);
 }