From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:57950) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9cuB-0002Ih-I2 for guix-patches@gnu.org; Sun, 15 Sep 2019 18:22:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9cuA-000771-F8 for guix-patches@gnu.org; Sun, 15 Sep 2019 18:22:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:40021) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9cuA-00076x-Cc for guix-patches@gnu.org; Sun, 15 Sep 2019 18:22:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1i9cuA-0007gV-88 for guix-patches@gnu.org; Sun, 15 Sep 2019 18:22:02 -0400 Subject: [bug#37413] [PATCH 1/9] pull: '--news' shows the list of channels added or removed. References: <20190915221021.4165-1-ludo@gnu.org> In-Reply-To: <20190915221021.4165-1-ludo@gnu.org> Resent-Message-ID: From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Mon, 16 Sep 2019 00:20:58 +0200 Message-Id: <20190915222106.4463-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 37413@debbugs.gnu.org * guix/scripts/pull.scm (display-channel, channel=?) (display-channel-news, display-news): New procedures. (process-query): Call 'display-news' instead of 'display-profile-news'. --- guix/scripts/pull.scm | 61 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 4 deletions(-) diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm index 54bbaddf30..ca3b36f98c 100644 --- a/guix/scripts/pull.scm +++ b/guix/scripts/pull.scm @@ -192,6 +192,62 @@ newest generation of PROFILE." (G_ "New in this revision:\n"))))) (_ #t))) +(define (display-channel channel) + "Display information about CHANNEL." + (format (current-error-port) + ;; TRANSLATORS: This describes a "channel"; the first placeholder is + ;; the channel name (e.g., "guix") and the second placeholder is its + ;; URL. + (G_ " ~a at ~a~%") + (channel-name channel) + (channel-url channel))) + +(define (channel=? channel1 channel2) + "Return true if CHANNEL1 and CHANNEL2 are the same for all practical +purposes." + ;; Assume that the URL matters less than the name. + (eq? (channel-name channel1) (channel-name channel2))) + +(define (display-channel-news profile) + "Display new about the channels of PROFILE " + (define previous + (and=> (relative-generation profile -1) + (cut generation-file-name profile <>))) + + (when previous + (let ((old-channels (profile-channels previous)) + (new-channels (profile-channels profile))) + (and (pair? old-channels) (pair? new-channels) + (begin + (match (lset-difference channel=? new-channels old-channels) + (() + #t) + (new + (let ((count (length new))) + (format (current-error-port) + (N_ " ~*One new channel:~%" + " ~a new channels:~%" count) + count) + (for-each display-channel new)))) + (match (lset-difference channel=? old-channels new-channels) + (() + #t) + (removed + (let ((count (length removed))) + (format (current-error-port) + (N_ " ~*One channel removed:~%" + " ~a channels removed:~%" count) + count) + (for-each display-channel removed))))))))) + +(define (display-news profile) + ;; Display profile news, with the understanding that this process represents + ;; the newest generation. + (display-profile-news profile + #:current-is-newer? #t) + + (display-channel-news profile)) + (define* (build-and-install instances profile #:key use-substitutes? verbose? dry-run?) "Build the tool from SOURCE, and install it in PROFILE. When DRY-RUN? is @@ -493,10 +549,7 @@ list of package changes."))))) ((numbers ...) (list-generations profile numbers))))))) (('display-news) - ;; Display profile news, with the understanding that this process - ;; represents the newest generation. - (display-profile-news profile - #:current-is-newer? #t)))) + (display-news profile)))) (define (channel-list opts) "Return the list of channels to use. If OPTS specify a channel file, -- 2.23.0