[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
07/10: channels: 'latest-channel-instances' doesn't leak internal state.
From: |
guix-commits |
Subject: |
07/10: channels: 'latest-channel-instances' doesn't leak internal state. |
Date: |
Sun, 24 May 2020 18:00:53 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 9b049de84ed101e2c0a5d071e76f424b3bc46bd9
Author: Ludovic Courtès <address@hidden>
AuthorDate: Wed May 20 15:55:37 2020 +0200
channels: 'latest-channel-instances' doesn't leak internal state.
* guix/channels.scm (latest-channel-instances): Remove
'previous-channels' argument. Introduce 'loop' and use it.
---
guix/channels.scm | 69 +++++++++++++++++++++++++++----------------------------
1 file changed, 34 insertions(+), 35 deletions(-)
diff --git a/guix/channels.scm b/guix/channels.scm
index f0174de..e0a7a84 100644
--- a/guix/channels.scm
+++ b/guix/channels.scm
@@ -231,10 +231,9 @@ result is unspecified."
#:select? (negate dot-git?))))
(channel-instance channel commit checkout))))
-(define* (latest-channel-instances store channels #:optional
(previous-channels '()))
+(define* (latest-channel-instances store channels)
"Return a list of channel instances corresponding to the latest checkouts of
-CHANNELS and the channels on which they depend. PREVIOUS-CHANNELS is a list
-of previously processed channels."
+CHANNELS and the channels on which they depend."
;; Only process channels that are unique, or that are more specific than a
;; previous channel specification.
(define (ignore? channel others)
@@ -245,38 +244,38 @@ of previously processed channels."
(not (or (channel-commit a)
(channel-commit b))))))))
- ;; Accumulate a list of instances. A list of processed channels is also
- ;; accumulated to decide on duplicate channel specifications.
- (define-values (resulting-channels instances)
- (fold2 (lambda (channel previous-channels instances)
- (if (ignore? channel previous-channels)
- (values previous-channels instances)
- (begin
- (format (current-error-port)
- (G_ "Updating channel '~a' from Git repository at
'~a'...~%")
- (channel-name channel)
- (channel-url channel))
- (let ((instance (latest-channel-instance store channel)))
- (let-values (((new-instances new-channels)
- (latest-channel-instances
- store
- (channel-instance-dependencies instance)
- previous-channels)))
- (values (append (cons channel new-channels)
- previous-channels)
- (append (cons instance new-instances)
- instances)))))))
- previous-channels
- '() ;instances
- channels))
-
- (let ((instance-name (compose channel-name channel-instance-channel)))
- ;; Remove all earlier channel specifications if they are followed by a
- ;; more specific one.
- (values (delete-duplicates instances
- (lambda (a b)
- (eq? (instance-name a) (instance-name b))))
- resulting-channels)))
+ (let loop ((channels channels)
+ (previous-channels '()))
+ ;; Accumulate a list of instances. A list of processed channels is also
+ ;; accumulated to decide on duplicate channel specifications.
+ (define-values (resulting-channels instances)
+ (fold2 (lambda (channel previous-channels instances)
+ (if (ignore? channel previous-channels)
+ (values previous-channels instances)
+ (begin
+ (format (current-error-port)
+ (G_ "Updating channel '~a' from Git repository at
'~a'...~%")
+ (channel-name channel)
+ (channel-url channel))
+ (let ((instance (latest-channel-instance store channel)))
+ (let-values (((new-instances new-channels)
+ (loop (channel-instance-dependencies
instance)
+ previous-channels)))
+ (values (append (cons channel new-channels)
+ previous-channels)
+ (append (cons instance new-instances)
+ instances)))))))
+ previous-channels
+ '() ;instances
+ channels))
+
+ (let ((instance-name (compose channel-name channel-instance-channel)))
+ ;; Remove all earlier channel specifications if they are followed by a
+ ;; more specific one.
+ (values (delete-duplicates instances
+ (lambda (a b)
+ (eq? (instance-name a) (instance-name b))))
+ resulting-channels))))
(define* (checkout->channel-instance checkout
#:key commit
- branch master updated (9b572ab -> 9744cc7), guix-commits, 2020/05/24
- 03/10: gnu: guile-dsv: Build with Guile 3.0., guix-commits, 2020/05/24
- 02/10: gnu: guile-dsv: Wrap script., guix-commits, 2020/05/24
- 05/10: gnu: protonvpn-cli: Tweak description., guix-commits, 2020/05/24
- 04/10: gnu: Add protonvpn-cli., guix-commits, 2020/05/24
- 07/10: channels: 'latest-channel-instances' doesn't leak internal state.,
guix-commits <=
- 01/10: doc: cookbook: Add subsection about session locking with xss-lock., guix-commits, 2020/05/24
- 08/10: git: 'update-cached-checkout' returns the commit relation., guix-commits, 2020/05/24
- 10/10: pull: Protect against downgrade attacks., guix-commits, 2020/05/24
- 09/10: channels: 'latest-channel-instances' guards against non-forward updates., guix-commits, 2020/05/24
- 06/10: git: Add 'commit-relation'., guix-commits, 2020/05/24