summaryrefslogtreecommitdiff
path: root/guix/ui.scm
diff options
context:
space:
mode:
authorRoel Janssen <roel@gnu.org>2016-10-26 14:53:29 +0200
committerRoel Janssen <roel@gnu.org>2016-10-26 14:53:29 +0200
commite95ae7c22373d2ba0e90ade2a46973ae9473d394 (patch)
tree1399695b44b2173f2b18f10d10501070bcab980d /guix/ui.scm
parentb2a2232c33e34aab6de02eb72c56494e006abc9d (diff)
downloadguix-patches-e95ae7c22373d2ba0e90ade2a46973ae9473d394.tar
guix-patches-e95ae7c22373d2ba0e90ade2a46973ae9473d394.tar.gz
guix package: Display generation diffs.
* guix/ui.scm (display-profile-content-diff): New variable. * guix/scripts/package.scm (process-query): Use display-profile-content-diff. In collaboration with Benz Schenk.
Diffstat (limited to 'guix/ui.scm')
-rw-r--r--guix/ui.scm28
1 files changed, 28 insertions, 0 deletions
diff --git a/guix/ui.scm b/guix/ui.scm
index eb85df3b18..9af8648211 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -7,6 +7,8 @@
;;; Copyright © 2014, 2015 Alex Kost <alezost@gmail.com>
;;; Copyright © 2015 David Thompson <davet@gnu.org>
;;; Copyright © 2015, 2016 Mathieu Lirzin <mthl@gnu.org>
+;;; Copyright © 2016 Roel Janssen <roel@gnu.org>
+;;; Copyright © 2016 Benz Schenk <benz.schenk@uzh.ch>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -87,6 +89,7 @@
matching-generations
display-generation
display-profile-content
+ display-profile-content-diff
roll-back*
switch-to-generation*
delete-generation*
@@ -1070,6 +1073,31 @@ DURATION-RELATION with the current time."
(format #t (_ "~a\t(current)~%") header)
(format #t "~a~%" header)))))
+(define (display-profile-content-diff profile gen1 gen2)
+ "Display the changed packages in PROFILE GEN2 compared to generation GEN2."
+
+ (define (equal-entry? first second)
+ (string= (manifest-entry-item first) (manifest-entry-item second)))
+
+ (define (display-entry entry prefix)
+ (match entry
+ (($ <manifest-entry> name version output location _)
+ (format #t " ~a ~a\t~a\t~a\t~a~%" prefix name version output location))))
+
+ (define (list-entries number)
+ (manifest-entries (profile-manifest (generation-file-name profile number))))
+
+ (define (display-diff profile old new)
+ (display-generation profile new)
+ (let ((added (lset-difference
+ equal-entry? (list-entries new) (list-entries old)))
+ (removed (lset-difference
+ equal-entry? (list-entries old) (list-entries new))))
+ (for-each (cut display-entry <> "+") added)
+ (for-each (cut display-entry <> "-") removed)))
+
+ (display-diff profile gen1 gen2))
+
(define (display-profile-content profile number)
"Display the packages in PROFILE, generation NUMBER, in a human-readable
way."