me
/
guix
Archived
1
0
Fork 0

channels: Use 'fold2'.

* guix/channels.scm (latest-channel-instances): Use 'fold2' instead of
'fold'.
master
Ludovic Courtès 2019-01-20 18:45:40 +01:00
parent ab6025b52c
commit f58f676b12
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 36 additions and 36 deletions

View File

@ -26,6 +26,7 @@
#:use-module (guix monads) #:use-module (guix monads)
#:use-module (guix profiles) #:use-module (guix profiles)
#:use-module (guix derivations) #:use-module (guix derivations)
#:use-module (guix combinators)
#:use-module (guix store) #:use-module (guix store)
#:use-module (guix i18n) #:use-module (guix i18n)
#:use-module ((guix utils) #:use-module ((guix utils)
@ -162,44 +163,43 @@ of previously processed channels."
(or (channel-commit b) (or (channel-commit b)
(not (or (channel-commit a) (not (or (channel-commit a)
(channel-commit b)))))))) (channel-commit b))))))))
;; Accumulate a list of instances. A list of processed channels is also ;; Accumulate a list of instances. A list of processed channels is also
;; accumulated to decide on duplicate channel specifications. ;; accumulated to decide on duplicate channel specifications.
(match (fold (lambda (channel acc) (define-values (resulting-channels instances)
(match acc (fold2 (lambda (channel previous-channels instances)
((#:channels previous-channels #:instances instances) (if (ignore? channel previous-channels)
(if (ignore? channel previous-channels) (values previous-channels instances)
acc (begin
(begin (format (current-error-port)
(format (current-error-port) (G_ "Updating channel '~a' from Git repository at '~a'...~%")
(G_ "Updating channel '~a' from Git repository at '~a'...~%") (channel-name channel)
(channel-name channel) (channel-url channel))
(channel-url channel)) (let-values (((checkout commit)
(let-values (((checkout commit) (latest-repository-commit store (channel-url channel)
(latest-repository-commit store (channel-url channel) #:ref (channel-reference
#:ref (channel-reference channel))))
channel)))) (let ((instance (channel-instance channel commit checkout)))
(let ((instance (channel-instance channel commit checkout))) (let-values (((new-instances new-channels)
(let-values (((new-instances new-channels) (latest-channel-instances
(latest-channel-instances store
store (channel-instance-dependencies instance)
(channel-instance-dependencies instance) previous-channels)))
previous-channels))) (values (append (cons channel new-channels)
`(#:channels previous-channels)
,(append (cons channel new-channels) (append (cons instance new-instances)
previous-channels) instances))))))))
#:instances previous-channels
,(append (cons instance new-instances) '() ;instances
instances)))))))))) channels))
`(#:channels ,previous-channels #:instances ())
channels) (let ((instance-name (compose channel-name channel-instance-channel)))
((#:channels channels #:instances instances) ;; Remove all earlier channel specifications if they are followed by a
(let ((instance-name (compose channel-name channel-instance-channel))) ;; more specific one.
;; Remove all earlier channel specifications if they are followed by a (values (delete-duplicates instances
;; more specific one. (lambda (a b)
(values (delete-duplicates instances (eq? (instance-name a) (instance-name b))))
(lambda (a b) resulting-channels)))
(eq? (instance-name a) (instance-name b))))
channels)))))
(define* (checkout->channel-instance checkout (define* (checkout->channel-instance checkout
#:key commit #:key commit