summaryrefslogtreecommitdiff
path: root/guix/store.scm
diff options
context:
space:
mode:
Diffstat (limited to 'guix/store.scm')
-rw-r--r--guix/store.scm30
1 files changed, 17 insertions, 13 deletions
diff --git a/guix/store.scm b/guix/store.scm
index f99fa581a8..2d4917d841 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -1378,9 +1378,10 @@ SEED."
its references, recursively)."
(fold-path store cons '() paths))
-(define (topologically-sorted store paths)
+(define* (topologically-sorted store paths #:key (cut? (const #f)))
"Return a list containing PATHS and all their references sorted in
-topological order."
+topological order. Skip store items that match CUT? as well as their
+dependencies."
(define (traverse)
;; Do a simple depth-first traversal of all of PATHS.
(let loop ((paths paths)
@@ -1394,17 +1395,20 @@ topological order."
(match paths
((head tail ...)
- (if (visited? head)
- (loop tail visited result)
- (call-with-values
- (lambda ()
- (loop (references store head)
- (visit head)
- result))
- (lambda (visited result)
- (loop tail
- visited
- (cons head result))))))
+ (cond ((visited? head)
+ (loop tail visited result))
+ ((cut? head)
+ (loop tail visited result))
+ (else
+ (call-with-values
+ (lambda ()
+ (loop (references store head)
+ (visit head)
+ result))
+ (lambda (visited result)
+ (loop tail
+ visited
+ (cons head result)))))))
(()
(values visited result)))))