[PATCH 1/2] ui: Refactor the package-strings helper in show-manifest-transaction.

  • Done
  • quality assurance status badge
Details
2 participants
  • Ludovic Courtès
  • Maxim Cournoyer
Owner
unassigned
Submitted by
Maxim Cournoyer
Severity
normal

Debbugs page

M
M
Maxim Cournoyer wrote on 2 Sep 2020 10:20
(address . guix-patches@gnu.org)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
20200902172046.3728-1-maxim.cournoyer@gmail.com
* guix/ui.scm (show-manifest-transaction)[package-strings]: Add an
OLD-VERSIONS keyword parameter. Absorb the code path previously found in the
upgrade-string. Remove upgrade-string.
(show-manifest-transaction): Adjust to the above changes.
---
guix/ui.scm | 33 +++++++++++++--------------------
1 file changed, 13 insertions(+), 20 deletions(-)

Toggle diff (77 lines)
diff --git a/guix/ui.scm b/guix/ui.scm
index efc3f39186..01af3d93d3 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -15,6 +15,7 @@
;;; Copyright © 2019 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2019 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2020 Arun Isaac <arunisaac@systemreboot.net>
+;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -1232,31 +1233,24 @@ separator between subsequent columns."
(define* (show-manifest-transaction store manifest transaction
#:key dry-run?)
"Display what will/would be installed/removed from MANIFEST by TRANSACTION."
- (define (package-strings names versions outputs)
+ (define* (package-strings names versions outputs #:key old-versions)
(tabulate (zip (map (lambda (name output)
(if (string=? output "out")
name
(string-append name ":" output)))
names outputs)
- versions)
- #:initial-indent 3))
-
- (define → ;an arrow that can be represented on stderr
- (right-arrow (current-error-port)))
-
- (define (upgrade-string names old-version new-version outputs)
- (tabulate (zip (map (lambda (name output)
- (if (string=? output "out")
- name
- (string-append name ":" output)))
- names outputs)
- (map (lambda (old new)
+ (if old-versions
+ (map (lambda (old new)
(if (string=? old new)
(G_ "(dependencies or package changed)")
(string-append old " " → " " new)))
- old-version new-version))
+ old-versions versions)
+ versions))
#:initial-indent 3))
+ (define → ;an arrow that can be represented on stderr
+ (right-arrow (current-error-port)))
+
(let-values (((remove install upgrade downgrade)
(manifest-transaction-effects manifest transaction)))
(match remove
@@ -1279,8 +1273,8 @@ separator between subsequent columns."
(((($ <manifest-entry> name old-version)
. ($ <manifest-entry> _ new-version output item)) ..1)
(let ((len (length name))
- (downgrade (upgrade-string name old-version new-version
- output)))
+ (downgrade (package-strings name new-version output
+ #:old-versions old-version)))
(if dry-run?
(format (current-error-port)
(N_ "The following package would be downgraded:~%~{~a~%~}~%"
@@ -1297,9 +1291,8 @@ separator between subsequent columns."
(((($ <manifest-entry> name old-version)
. ($ <manifest-entry> _ new-version output item)) ..1)
(let ((len (length name))
- (upgrade (upgrade-string name
- old-version new-version
- output)))
+ (upgrade (package-strings name new-version output
+ #:old-versions old-version)))
(if dry-run?
(format (current-error-port)
(N_ "The following package would be upgraded:~%~{~a~%~}~%"
--
2.27.0
M
M
Maxim Cournoyer wrote on 2 Sep 2020 10:22
[PATCH 2/2] ui: Lexicographically sort transaction entries based on their package name.
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
20200902172216.3813-1-maxim.cournoyer@gmail.com
* guix/ui.scm (show-manifest-transaction): Sort entries to be displayed in a
tabulated view.
---
guix/ui.scm | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)

Toggle diff (40 lines)
diff --git a/guix/ui.scm b/guix/ui.scm
index 01af3d93d3..e0d1dc1bb7 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -1234,18 +1234,21 @@ separator between subsequent columns."
#:key dry-run?)
"Display what will/would be installed/removed from MANIFEST by TRANSACTION."
(define* (package-strings names versions outputs #:key old-versions)
- (tabulate (zip (map (lambda (name output)
- (if (string=? output "out")
- name
- (string-append name ":" output)))
- names outputs)
- (if old-versions
- (map (lambda (old new)
- (if (string=? old new)
- (G_ "(dependencies or package changed)")
- (string-append old " " → " " new)))
- old-versions versions)
- versions))
+ (tabulate (stable-sort
+ (zip (map (lambda (name output)
+ (if (string=? output "out")
+ name
+ (string-append name ":" output)))
+ names outputs)
+ (if old-versions
+ (map (lambda (old new)
+ (if (string=? old new)
+ (G_ "(dependencies or package changed)")
+ (string-append old " " → " " new)))
+ old-versions versions)
+ versions))
+ (lambda (x y)
+ (string<? (first x) (first y))))
#:initial-indent 3))
(define → ;an arrow that can be represented on stderr
--
2.27.0
L
L
Ludovic Courtès wrote on 4 Sep 2020 01:47
Re: [bug#43170] [PATCH 1/2] ui: Refactor the package-strings helper in show-manifest-transaction.
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)(address . 43170@debbugs.gnu.org)
87blimvsgv.fsf@gnu.org
Hi!

Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:

Toggle quote (5 lines)
> * guix/ui.scm (show-manifest-transaction)[package-strings]: Add an
> OLD-VERSIONS keyword parameter. Absorb the code path previously found in the
> upgrade-string. Remove upgrade-string.
> (show-manifest-transaction): Adjust to the above changes.

[...]

Toggle quote (3 lines)
> * guix/ui.scm (show-manifest-transaction): Sort entries to be displayed in a
> tabulated view.

LGTM, thanks!

Ludo’.
L
L
Ludovic Courtès wrote on 24 Sep 2020 08:19
control message for bug #43170
(address . control@debbugs.gnu.org)
87y2kz6w2z.fsf@gnu.org
tags 43170 fixed
close 43170
quit
?
Your comment

This issue is archived.

To comment on this conversation send an email to 43170@patchwise.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 43170
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch