From mboxrd@z Thu Jan 1 00:00:00 1970 From: Roel Janssen Subject: Display diffs between generations. Date: Sun, 28 Aug 2016 01:02:47 +0200 Message-ID: <87eg59izmw.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55828) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bdmc7-0005nU-SV for guix-devel@gnu.org; Sat, 27 Aug 2016 19:02:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bdmc1-00070y-LW for guix-devel@gnu.org; Sat, 27 Aug 2016 19:02:10 -0400 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:43563) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bdmc1-00070Q-Hf for guix-devel@gnu.org; Sat, 27 Aug 2016 19:02:05 -0400 Received: from 541e9304.cm-5-7c.dynamic.ziggo.nl ([84.30.147.4]:59056 helo=roel-tp) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1bdmbz-00089o-Tf for guix-devel@gnu.org; Sat, 27 Aug 2016 19:02:04 -0400 List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-guix-package-Display-generation-diffs.patch >From 1ea5eaae4b492c82358c7394c22cd46497388449 Mon Sep 17 00:00:00 2001 From: Roel Janssen Date: Sun, 28 Aug 2016 00:54:06 +0200 Subject: [PATCH] guix package: Display generation diffs. --- guix/scripts/package.scm | 2 +- guix/ui.scm | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 2a751a4..32cbcdc 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -640,7 +640,7 @@ processed, #f otherwise." (define (list-generation number) (unless (zero? number) (display-generation profile number) - (display-profile-content profile number) + (display-profile-content-diff profile number) (newline))) (cond ((not (file-exists? profile)) ; XXX: race condition diff --git a/guix/ui.scm b/guix/ui.scm index 906b349..cb056a0 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -87,6 +87,7 @@ matching-generations display-generation display-profile-content + display-profile-content-diff roll-back* switch-to-generation* delete-generation* @@ -1070,6 +1071,39 @@ DURATION-RELATION with the current time." (format #t (_ "~a\t(current)~%") header) (format #t "~a~%" header))))) +(define (display-profile-content-diff profile number) + "Display the changed packages in PROFILE with generation specified by NUMBER." + + (define (equal-entry? first second) + (string= (manifest-entry-item first) + (manifest-entry-item second))) + + (define* (display-entries entries #:optional (prefix " ")) + (for-each + (match-lambda + (($ name version output location _) + (format #t " ~a ~a\t~a\t~a\t~a~%" + prefix name version output location))) + entries)) + + (define (display-profile-content-diff-between profile older newer) + (if (= older 0) + (display-profile-content profile newer) + (let* ((old (profile-manifest (generation-file-name profile older))) + (new (profile-manifest (generation-file-name profile newer))) + (installed (lset-difference equal-entry? + (manifest-entries new) + (manifest-entries old))) + (removed (lset-difference equal-entry? + (manifest-entries old) + (manifest-entries new)))) + + (display-entries installed "+") + (display-entries removed "-")))) + + (let ((previous (previous-generation-number profile number))) + (display-profile-content-diff-between profile previous number))) + (define (display-profile-content profile number) "Display the packages in PROFILE, generation NUMBER, in a human-readable way." -- 2.9.3 --=-=-= Content-Type: text/plain Dear Guix, After looking at a terribly long output of `guix package --list-generations', I thought it may be a good idea to only display the difference between profile versions. I came up with the following patch. What do you think about changing from displaying the full profile contents for each generation to only showing the differences between the profiles? And, I am probably missing something, because some of my generation entries are empty.. So how could I improve this patch for it to be complete? Thanks in advance for your feedback! Kind regards, Roel Janssen --=-=-=--