GNU bug report logs - #43170
[PATCH 1/2] ui: Refactor the package-strings helper in show-manifest-transaction.

Previous Next

Package: guix-patches;

Reported by: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Date: Wed, 2 Sep 2020 17:21:02 UTC

Severity: normal

Tags: fixed, patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 43170 in the body.
You can then email your comments to 43170 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#43170; Package guix-patches. (Wed, 02 Sep 2020 17:21:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Maxim Cournoyer <maxim.cournoyer <at> gmail.com>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Wed, 02 Sep 2020 17:21:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: guix-patches <at> gnu.org
Cc: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Subject: [PATCH 1/2] ui: Refactor the package-strings helper in
 show-manifest-transaction.
Date: Wed,  2 Sep 2020 13:20:46 -0400
* 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(-)

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 <at> tobias.gr>
 ;;; Copyright © 2019 Simon Tournier <zimon.toutoune <at> gmail.com>
 ;;; Copyright © 2020 Arun Isaac <arunisaac <at> systemreboot.net>
+;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer <at> 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





Information forwarded to guix-patches <at> gnu.org:
bug#43170; Package guix-patches. (Wed, 02 Sep 2020 17:23:03 GMT) Full text and rfc822 format available.

Message #8 received at 43170 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: 43170 <at> debbugs.gnu.org,
	guix-patches <at> gnu.org
Cc: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Subject: [PATCH 2/2] ui: Lexicographically sort transaction entries based on
 their package name.
Date: Wed,  2 Sep 2020 13:22:16 -0400
* 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(-)

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





Information forwarded to guix-patches <at> gnu.org:
bug#43170; Package guix-patches. (Fri, 04 Sep 2020 08:48:02 GMT) Full text and rfc822 format available.

Message #11 received at 43170 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Cc: 43170 <at> debbugs.gnu.org
Subject: Re: [bug#43170] [PATCH 1/2] ui: Refactor the package-strings helper
 in show-manifest-transaction.
Date: Fri, 04 Sep 2020 10:47:28 +0200
Hi!

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

> * 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 (show-manifest-transaction): Sort entries to be displayed in a
> tabulated view.

LGTM, thanks!

Ludo’.




Added tag(s) fixed. Request was from Ludovic Courtès <ludo <at> gnu.org> to control <at> debbugs.gnu.org. (Thu, 24 Sep 2020 15:20:03 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 43170 <at> debbugs.gnu.org and Maxim Cournoyer <maxim.cournoyer <at> gmail.com> Request was from Ludovic Courtès <ludo <at> gnu.org> to control <at> debbugs.gnu.org. (Thu, 24 Sep 2020 15:20:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 23 Oct 2020 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 184 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.