From patchwork Sat Sep 21 21:12:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 15426 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 8A81517400; Sat, 21 Sep 2019 22:13:39 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 4C356173FB for ; Sat, 21 Sep 2019 22:13:39 +0100 (BST) Received: from localhost ([::1]:43750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBmhG-00039n-Bv for patchwork@mira.cbaines.net; Sat, 21 Sep 2019 17:13:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41346) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBmgk-0002yP-Uu for guix-patches@gnu.org; Sat, 21 Sep 2019 17:13:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iBmgj-0005uy-Py for guix-patches@gnu.org; Sat, 21 Sep 2019 17:13:06 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:52658) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iBmgj-0005us-N2 for guix-patches@gnu.org; Sat, 21 Sep 2019 17:13:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iBmgj-0000O4-Ft for guix-patches@gnu.org; Sat, 21 Sep 2019 17:13:05 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#37413] [PATCH v2 01/11] pull: '--news' shows the list of channels added or removed. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 21 Sep 2019 21:13:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37413 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 37413@debbugs.gnu.org Received: via spool by 37413-submit@debbugs.gnu.org id=B37413.15691003781385 (code B ref 37413); Sat, 21 Sep 2019 21:13:05 +0000 Received: (at 37413) by debbugs.gnu.org; 21 Sep 2019 21:12:58 +0000 Received: from localhost ([127.0.0.1]:33222 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iBmgb-0000Ly-7R for submit@debbugs.gnu.org; Sat, 21 Sep 2019 17:12:57 -0400 Received: from eggs.gnu.org ([209.51.188.92]:32814) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iBmgU-0000Kt-JY for 37413@debbugs.gnu.org; Sat, 21 Sep 2019 17:12:50 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:49538) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iBmgP-0005eT-H8; Sat, 21 Sep 2019 17:12:45 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=53014 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1iBmgP-00065A-1B; Sat, 21 Sep 2019 17:12:45 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Sat, 21 Sep 2019 23:12:18 +0200 Message-Id: <20190921211228.13096-2-ludo@gnu.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190921211228.13096-1-ludo@gnu.org> References: <87sgow0w7w.fsf@gnu.org> <20190921211228.13096-1-ludo@gnu.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * 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 c9835cef34..4091f926ac 100644 --- a/guix/scripts/pull.scm +++ b/guix/scripts/pull.scm @@ -213,6 +213,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 @@ -521,10 +577,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 (process-generation-change opts profile) "Process a request to change the current generation (roll-back, switch, delete)."