From: Roel Janssen <roel@gnu.org>
To: guix-devel@gnu.org
Subject: Display diffs between generations.
Date: Sun, 28 Aug 2016 01:02:47 +0200 [thread overview]
Message-ID: <87eg59izmw.fsf@gnu.org> (raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0001-guix-package-Display-generation-diffs.patch --]
[-- Type: text/x-patch, Size: 3002 bytes --]
From 1ea5eaae4b492c82358c7394c22cd46497388449 Mon Sep 17 00:00:00 2001
From: Roel Janssen <roel@gnu.org>
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
+ (($ <manifest-entry> 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
[-- Attachment #2: Type: text/plain, Size: 579 bytes --]
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
next reply other threads:[~2016-08-27 23:02 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-27 23:02 Roel Janssen [this message]
2016-08-29 16:25 ` Display diffs between generations Ludovic Courtès
2016-08-29 19:08 ` Roel Janssen
2016-08-31 20:52 ` Ludovic Courtès
2016-08-31 21:11 ` Vincent Legoll
2016-09-01 12:12 ` Ludovic Courtès
2016-09-03 13:03 ` Vincent Legoll
2016-09-04 16:53 ` Roel Janssen
2016-10-10 20:30 ` Ludovic Courtès
2016-10-11 7:19 ` Roel Janssen
2016-10-18 12:43 ` Roel Janssen
2016-10-19 20:22 ` Ludovic Courtès
2016-10-19 21:48 ` Roel Janssen
2016-10-20 12:36 ` Ludovic Courtès
2016-10-20 12:56 ` Roel Janssen
2016-10-20 19:38 ` Ludovic Courtès
2016-10-21 9:37 ` Roel Janssen
2016-10-21 14:40 ` Benz Schenk
2016-10-24 20:33 ` Ludovic Courtès
2016-10-25 16:01 ` Roel Janssen
2016-10-26 11:13 ` Benz Schenk
2016-10-26 11:38 ` Ludovic Courtès
2016-10-26 12:58 ` Roel Janssen
2016-09-04 22:12 ` Ludovic Courtès
2016-09-05 7:52 ` Hartmut Goebel
2016-09-05 10:38 ` Vincent Legoll
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87eg59izmw.fsf@gnu.org \
--to=roel@gnu.org \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.