[PATCH 0/4] 'guix pull -l' no longer displays package lists by default

  • Done
  • quality assurance status badge
Details
2 participants
  • Ludovic Courtès
  • zimoun
Owner
unassigned
Submitted by
Ludovic Courtès
Severity
normal
L
L
Ludovic Courtès wrote on 9 Feb 2022 23:12
(address . guix-patches@gnu.org)(name . Ludovic Courtès)(address . ludo@gnu.org)
20220209221237.8549-1-ludo@gnu.org
Hi!

The other day on IRC zimoun noted that ‘guix pull -l’ doesn’t work for
them because it prints those long package lists, which incidentally
makes it slower.

This series changes ‘guix pull -l’ so that by default it only prints
channel info and news:

Toggle snippet (41 lines)
$ ./pre-inst-env guix pull -l
Generation 192 Oct 25 2021 00:12:47
guix b5f45a2
repository URL: https://git.savannah.gnu.org/git/guix.git
branch: master
commit: b5f45a21c27b80210753e184e52708bb75a347bb
Generation 193 Oct 25 2021 21:29:18
guix b0735c7
repository URL: https://git.savannah.gnu.org/git/guix.git
branch: master
commit: b0735c79b0d1d34117ec36d5dc5f14a3f9392bc1

News for channel 'guix'
New `guix shell' command supersedes `guix environment'
commit 746584e0ca200e7bf51b139ceb36c19ea81d6ef1

A new `guix shell' command is now available. It is similar to `guix environment', but with a
more convenient interface (`guix environment' is deprecated but will remain available until
May, 1st 2023). The main difference compared to `guix environment' is that the "ad hoc" mode
is the default. Thus, to create an interactive environment containing Python, NumPy, and
SciPy, you would run:
guix shell python python-numpy python-scipy
To get a development environment for, say, Inkscape, pass the `-D' flag:
guix shell -D inkscape
Another difference is that running `guix shell' without arguments loads `manifest.scm' or
`guix.scm' for the current directory or an ancestor, provided you allowed it. The command
maintains a cache to speed up access to such environments.
Run `info "(guix) Invoking guix shell"' for more information.

Generation 194 Nov 07 2021 23:40:30
guix bd41e59
repository URL: https://git.savannah.gnu.org/git/guix.git
branch: master
commit: bd41e590dd24e54797fb8b6854c244efd4d12df5

One can pass ‘--details’ to get view new/upgraded packages:

Toggle snippet (19 lines)
$ ./pre-inst-env guix pull --detail -l
Generation 192 Oct 25 2021 00:12:47
guix b5f45a2
repository URL: https://git.savannah.gnu.org/git/guix.git
branch: master
commit: b5f45a21c27b80210753e184e52708bb75a347bb
Generation 193 Oct 25 2021 21:29:18
guix b0735c7
repository URL: https://git.savannah.gnu.org/git/guix.git
branch: master
commit: b0735c79b0d1d34117ec36d5dc5f14a3f9392bc1
3 new packages: lttng-tools, vim-gitgutter, vim-mucomplete
7 packages upgraded: flatpak@1.12.1, libportal@0.4, mspdebug@0.25-0.4c4d94e,
p11-kit@0.24.0, reprotest@0.7.18, xdg-desktop-portal-gtk@1.10.0, xdg-desktop-portal@1.10.1

News for channel 'guix'
New `guix shell' command supersedes `guix environment'

Last, ‘guix pull -l’ pipes its output to $PAGER by default.

Thoughts?

Ludo’.

Ludovic Courtès (4):
pull: '--list-generations' doesn't list package changes by default.
ui: 'with-paginated-output-port' gives access to the wrapped port.
ui: 'display-generation' uses color when talking to a pager.
pull: '--list-generations' pipes its output to the pager.

doc/guix.texi | 15 +++++++++------
guix/scripts/pull.scm | 35 +++++++++++++++++++++++++++--------
guix/ui.scm | 24 ++++++++++++++++++++++--
3 files changed, 58 insertions(+), 16 deletions(-)

--
2.34.0
L
L
Ludovic Courtès wrote on 9 Feb 2022 23:17
[PATCH 1/4] pull: '--list-generations' doesn't list package changes by default.
(address . 53909@debbugs.gnu.org)(name . Ludovic Courtès)(address . ludo@gnu.org)
20220209221712.8724-1-ludo@gnu.org
* guix/scripts/pull.scm (show-help, %options): Add "--details".
(process-query): Honor it.
* doc/guix.texi (Invoking guix pull): Document it.
---
doc/guix.texi | 15 +++++++++------
guix/scripts/pull.scm | 19 +++++++++++++++----
2 files changed, 24 insertions(+), 10 deletions(-)

Toggle diff (106 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index 583ba1c61d..5ef750786f 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -4426,18 +4426,12 @@ Generation 2 Jun 11 2018 11:02:49
repository URL: https://git.savannah.gnu.org/git/guix.git
branch: origin/master
commit: e0cc7f669bec22c37481dd03a7941c7d11a64f1d
- 2 new packages: keepalived, libnfnetlink
- 6 packages upgraded: emacs-nix-mode@@2.0.4,
- guile2.0-guix@@0.14.0-12.77a1aac, guix@@0.14.0-12.77a1aac,
- heimdal@@7.5.0, milkytracker@@1.02.00, nix@@2.0.4
Generation 3 Jun 13 2018 23:31:07 (current)
guix 844cc1c
repository URL: https://git.savannah.gnu.org/git/guix.git
branch: origin/master
commit: 844cc1c8f394f03b404c5bb3aee086922373490c
- 28 new packages: emacs-helm-ls-git, emacs-helm-mu, @dots{}
- 69 packages upgraded: borg@@1.1.6, cheese@@3.28.0, @dots{}
@end example
@xref{Invoking guix describe, @command{guix describe}}, for other ways to
@@ -4507,6 +4501,15 @@ is provided, the subset of generations that match @var{pattern}.
The syntax of @var{pattern} is the same as with @code{guix package
--list-generations} (@pxref{Invoking guix package}).
+By default, this prints information about the channels used in each
+revision as well as the corresponding news entries. If you pass
+@option{--details}, it will also print the list of packages added and
+upgraded in each generation compared to the previous one.
+
+@item --details
+Instruct @option{--list-generations} to display more information about
+the differences between subsequent generations---see above.
+
@item --roll-back
@cindex rolling back
@cindex undoing transactions
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index fb8ce50fa7..707f1f0929 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014, 2015, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013-2015, 2017-2022 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
;;; Copyright © 2020, 2021 Tobias Geerinckx-Rice <me@tobias.gr>
;;;
@@ -104,6 +104,8 @@ (define (show-help)
(display (G_ "
-l, --list-generations[=PATTERN]
list generations matching PATTERN"))
+ (display (G_ "
+ --details show details when listing generations"))
(display (G_ "
--roll-back roll back to the previous generation"))
(display (G_ "
@@ -138,6 +140,9 @@ (define %options
(lambda (opt name arg result)
(cons `(query list-generations ,arg)
result)))
+ (option '("details") #f #f
+ (lambda (opt name arg result)
+ (alist-cons 'details? #t result)))
(option '("roll-back") #f #f
(lambda (opt name arg result)
(cons '(generation roll-back)
@@ -640,17 +645,23 @@ (define (package-alist generation)
(define (process-query opts profile)
"Process any query on PROFILE specified by OPTS."
+ (define details?
+ (assoc-ref opts 'details?))
+
(match (assoc-ref opts 'query)
(('list-generations pattern)
(define (list-generations profile numbers)
(match numbers
((first rest ...)
(display-profile-content profile first)
+
(let loop ((numbers numbers))
(match numbers
((first second rest ...)
- (display-profile-content-diff profile
- first second)
+ (if details?
+ (display-profile-content-diff profile
+ first second)
+ (display-profile-content profile second))
(display-channel-news (generation-file-name profile second)
(generation-file-name profile first))
(loop (cons second rest)))
@@ -754,7 +765,7 @@ (define (environment-variable)
(define-command (guix-pull . args)
(synopsis "pull the latest revision of Guix")
- (define (no-arguments arg _?)
+ (define (no-arguments arg _)
(leave (G_ "~A: extraneous argument~%") arg))
(with-error-handling
--
2.34.0
L
L
Ludovic Courtès wrote on 9 Feb 2022 23:17
[PATCH 2/4] ui: 'with-paginated-output-port' gives access to the wrapped port.
(address . 53909@debbugs.gnu.org)(name . Ludovic Courtès)(address . ludo@gnu.org)
20220209221712.8724-2-ludo@gnu.org
* guix/ui.scm (pager-port-mapping): New variable.
(pager-wrapped-port): New procedure.
(call-with-paginated-output-port): Parameterize 'pager-port-mapping'.
---
guix/ui.scm | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)

Toggle diff (47 lines)
diff --git a/guix/ui.scm b/guix/ui.scm
index 093de1b4ab..d1f92ce7be 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -124,6 +124,7 @@ (define-module (guix ui)
file-hyperlink
location->hyperlink
+ pager-wrapped-port
with-paginated-output-port
relevance
package-relevance
@@ -1665,6 +1666,20 @@ (define (package-relevance package regexps)
zero means that PACKAGE does not match any of REGEXPS."
(relevance package regexps %package-metrics))
+(define pager-port-mapping
+ ;; If a pager is being used, via 'with-paginated-output-port', this maps the
+ ;; pager port (pipe) to the underlying output port.
+ (make-parameter #f))
+
+(define* (pager-wrapped-port #:optional (port (current-output-port)))
+ "If PORT is a pipe to a pager created by 'with-paginated-output-port',
+return the underlying port. Otherwise return #f."
+ (match (pager-port-mapping)
+ ((pager . wrapped)
+ (and (eq? pager port) wrapped))
+ (_
+ #f)))
+
(define* (call-with-paginated-output-port proc
#:key (less-options "FrX"))
(let ((pager-command-line (or (getenv "GUIX_PAGER")
@@ -1691,7 +1706,10 @@ (define* (call-with-paginated-output-port proc
char-set:whitespace))))))
(dynamic-wind
(const #t)
- (lambda () (proc pager))
+ (lambda ()
+ (parameterize ((pager-port-mapping
+ (cons pager (current-output-port))))
+ (proc pager)))
(lambda () (close-pipe pager))))
(proc (current-output-port)))))
--
2.34.0
L
L
Ludovic Courtès wrote on 9 Feb 2022 23:17
[PATCH 3/4] ui: 'display-generation' uses color when talking to a pager.
(address . 53909@debbugs.gnu.org)(name . Ludovic Courtès)(address . ludo@gnu.org)
20220209221712.8724-3-ludo@gnu.org
This makes sure that, say, 'guix pull -l' benefits from colors when its
output is piped to a pager, as long as the underlying terminal supports
it.

* guix/ui.scm (display-generation): Add second argument to 'highlight'.
---
guix/ui.scm | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

Toggle diff (17 lines)
diff --git a/guix/ui.scm b/guix/ui.scm
index d1f92ce7be..238952723e 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -1900,7 +1900,9 @@ (define (display-generation profile number)
(link (if (supports-hyperlinks?)
(cut file-hyperlink file <>)
identity))
- (header (format #f (link (highlight (G_ "Generation ~a\t~a")))
+ (header (format #f (link (highlight (G_ "Generation ~a\t~a")
+ (or (pager-wrapped-port)
+ (current-output-port))))
number
(date->string
(time-utc->date
--
2.34.0
L
L
Ludovic Courtès wrote on 9 Feb 2022 23:17
[PATCH 4/4] pull: '--list-generations' pipes its output to the pager.
(address . 53909@debbugs.gnu.org)(name . Ludovic Courtès)(address . ludo@gnu.org)
20220209221712.8724-4-ludo@gnu.org
* guix/scripts/pull.scm (process-query): For 'list-generations queries,
use 'with-paginated-output-port'.
(display-news-entry-title): Pass second argument to 'highlight'.
(display-news-entry): Pass second argument to 'dim'.
---
guix/scripts/pull.scm | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)

Toggle diff (49 lines)
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index 707f1f0929..7fe738229b 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -279,7 +279,8 @@ (define title
(texi->plain-text title))
;; When Texinfo markup is invalid, display it as-is.
- (const title)))))))
+ (const title)))
+ (or (pager-wrapped-port port) port)))))
(define (display-news-entry entry channel language port)
"Display ENTRY, a <channel-news-entry> from CHANNEL, in LANGUAGE, a language
@@ -291,7 +292,8 @@ (define commit
(channel-news-entry-commit entry))
(display-news-entry-title entry language port)
- (format port (dim (G_ " commit ~a~%"))
+ (format port (dim (G_ " commit ~a~%")
+ (or (pager-wrapped-port port) port))
(if (supports-hyperlinks?)
(channel-commit-hyperlink channel commit)
commit))
@@ -673,14 +675,20 @@ (define (list-generations profile numbers)
(raise (condition (&profile-not-found-error
(profile profile)))))
((not pattern)
- (list-generations profile (profile-generations profile)))
+ (with-paginated-output-port port
+ (with-output-to-port port
+ (lambda ()
+ (list-generations profile (profile-generations profile))))))
((matching-generations pattern profile)
=>
(match-lambda
(()
(exit 1))
((numbers ...)
- (list-generations profile numbers)))))))
+ (with-paginated-output-port port
+ (with-output-to-port port
+ (lambda ()
+ (list-generations profile numbers))))))))))
(('display-news)
(display-news profile))))
--
2.34.0
Z
Z
zimoun wrote on 10 Feb 2022 18:21
Re: bug#53909: [PATCH 0/4] 'guix pull -l' no longer displays package lists by default
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 53909@debbugs.gnu.org)
87mtiy8wnm.fsf_-_@gmail.com
Hi Ludo,

Cool! Thanks.


On Wed, 09 Feb 2022 at 23:17, Ludovic Courtès <ludo@gnu.org> wrote:

Toggle quote (2 lines)
> * guix/scripts/pull.scm (show-help, %options): Add "--details".

IMHO, the commit online header should reflect that.


Toggle quote (2 lines)
> diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm

[...]

Toggle quote (25 lines)
> (define (process-query opts profile)
> "Process any query on PROFILE specified by OPTS."
> + (define details?
> + (assoc-ref opts 'details?))
> +
> (match (assoc-ref opts 'query)
> (('list-generations pattern)
> (define (list-generations profile numbers)
> (match numbers
> ((first rest ...)
> (display-profile-content profile first)
> +
> (let loop ((numbers numbers))
> (match numbers
> ((first second rest ...)
> - (display-profile-content-diff profile
> - first second)
> + (if details?
> + (display-profile-content-diff profile
> + first second)
> + (display-profile-content profile second))
> (display-channel-news (generation-file-name profile second)
> (generation-file-name profile first))
> (loop (cons second rest)))

Well, "guix pull --details" pulls; which I find annoying. Instead, I
propose to silently runs "guix pull --details -l", see this diff:
Toggle diff (15 lines)
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index 707f1f0929..fb1dd6c82c 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -142,7 +142,9 @@ (define %options
result)))
(option '("details") #f #f
(lambda (opt name arg result)
- (alist-cons 'details? #t result)))
+ (alist-cons 'details? #t
+ (cons '(query list-generations #f)
+ result))))
(option '("roll-back") #f #f
(lambda (opt name arg result)
(cons '(generation roll-back)
Because warn people that "guix pull --details" alone is not what they
want adds some complexity, and when '--details' only works in tandem
with the option '--list-generations', that’s why I propose this
behaviour.


Last, about this change…

Toggle quote (3 lines)
> - (define (no-arguments arg _?)
> + (define (no-arguments arg _)

…it a Git twist? I miss what changed––my whitespace mode is badly
configured?



Cheers,
simon
Z
Z
zimoun wrote on 10 Feb 2022 18:51
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 53909@debbugs.gnu.org)
87k0e28var.fsf@gmail.com
Hi Ludo,


On Wed, 09 Feb 2022 at 23:12, Ludovic Courtès <ludo@gnu.org> wrote:

Toggle quote (4 lines)
> The other day on IRC zimoun noted that ‘guix pull -l’ doesn’t work for
> them because it prints those long package lists, which incidentally
> makes it slower.

My remark is based on the rate of changes. Let assume that regular
users "pull" once a week – I even guess it is less frequent than that.

Here the number of additions this user would see for the last 10 weeks:

Toggle snippet (13 lines)
$ for i in $(seq 10); do git log --after="$(($i + 1)) week ago" --before="$i week ago" --oneline | grep Add | wc -l; done
108
59
84
149
76
212
48
83
46
63

And for Update, it reads:

Toggle snippet (12 lines)
106
115
103
247
261
134
167
99
100
145

Therefore, the current display of “guix pull -l” is not human readable.


Toggle quote (2 lines)
> $ ./pre-inst-env guix pull --details -l

Note it hits bug#50472 [1]. Other said,

guix pull -l --details

does not work as expected.




Toggle quote (6 lines)
> Ludovic Courtès (4):
> pull: '--list-generations' doesn't list package changes by default.
> ui: 'with-paginated-output-port' gives access to the wrapped port.
> ui: 'display-generation' uses color when talking to a pager.
> pull: '--list-generations' pipes its output to the pager.

Well, I am mainly running CLI with Emacs ’M-x shell’, so Emacs is my
pager. :-) However, I have tried with xterm and PAGER=less, nothing is
different. Do I miss something?



Cheers,
simon
L
L
Ludovic Courtès wrote on 14 Feb 2022 13:56
(name . zimoun)(address . zimon.toutoune@gmail.com)(address . 53909@debbugs.gnu.org)
87fsoly5cc.fsf_-_@gnu.org
Hi!

zimoun <zimon.toutoune@gmail.com> skribis:

Toggle quote (11 lines)
> On Wed, 09 Feb 2022 at 23:12, Ludovic Courtès <ludo@gnu.org> wrote:
>
>> The other day on IRC zimoun noted that ‘guix pull -l’ doesn’t work for
>> them because it prints those long package lists, which incidentally
>> makes it slower.
>
> My remark is based on the rate of changes. Let assume that regular
> users "pull" once a week – I even guess it is less frequent than that.
>
> Here the number of additions this user would see for the last 10 weeks:

[...]

Toggle quote (2 lines)
> Therefore, the current display of “guix pull -l” is not human readable.

Yeah, though it’s searchable in $PAGER.

Toggle quote (10 lines)
>> $ ./pre-inst-env guix pull --details -l
>
> Note it hits bug#50472 [1]. Other said,
>
> guix pull -l --details
>
> does not work as expected.
>
> 1:<http://issues.guix.gnu.org/issue/50472

Right.

Toggle quote (10 lines)
>> Ludovic Courtès (4):
>> pull: '--list-generations' doesn't list package changes by default.
>> ui: 'with-paginated-output-port' gives access to the wrapped port.
>> ui: 'display-generation' uses color when talking to a pager.
>> pull: '--list-generations' pipes its output to the pager.
>
> Well, I am mainly running CLI with Emacs ’M-x shell’, so Emacs is my
> pager. :-) However, I have tried with xterm and PAGER=less, nothing is
> different. Do I miss something?

The output gets piped to the pager now, which wasn’t the case before (I
tested in xterm FWIW).

Thanks,
Ludo’.
L
L
Ludovic Courtès wrote on 14 Feb 2022 15:56
(name . zimoun)(address . zimon.toutoune@gmail.com)(address . 53909-done@debbugs.gnu.org)
87ilthwl6z.fsf_-_@gnu.org
Hi,

zimoun <zimon.toutoune@gmail.com> skribis:

Toggle quote (6 lines)
> On Wed, 09 Feb 2022 at 23:17, Ludovic Courtès <ludo@gnu.org> wrote:
>
>> * guix/scripts/pull.scm (show-help, %options): Add "--details".
>
> IMHO, the commit online header should reflect that.

Right, fixed.

Toggle quote (16 lines)
> Well, "guix pull --details" pulls; which I find annoying. Instead, I
> propose to silently runs "guix pull --details -l", see this diff:
>
> diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
> index 707f1f0929..fb1dd6c82c 100644
> --- a/guix/scripts/pull.scm
> +++ b/guix/scripts/pull.scm
> @@ -142,7 +142,9 @@ (define %options
> result)))
> (option '("details") #f #f
> (lambda (opt name arg result)
> - (alist-cons 'details? #t result)))
> + (alist-cons 'details? #t
> + (cons '(query list-generations #f)
> + result))))

It’s a bit more complicated since you don’t want to override previous
‘-l’ arguments, but I did that.

Toggle quote (8 lines)
> Last, about this change…
>
>> - (define (no-arguments arg _?)
>> + (define (no-arguments arg _)
>
> …it a Git twist? I miss what changed––my whitespace mode is badly
> configured?

There’s a ZERO WIDTH NON-JOINER above; you can see it with a trick I
recently learned: (set-face-background 'glyphless-char "red").

:-)

Anyway, pushed:

054ec2e242 pull: '--list-generations' pipes its output to the pager.
5b6e31b020 ui: 'display-generation' uses color when talking to a pager.
7ffcee1937 ui: 'with-paginated-output-port' gives access to the wrapped port.
b9df2e2b4d pull: '--list-generations' lists packages only with '--details'.

Thanks!

Ludo’.
Closed
Z
Z
zimoun wrote on 14 Feb 2022 18:28
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 53909-done@debbugs.gnu.org)
CAJ3okZ0ZTRLgi2kHHd6gsBekOxfcTeFGU21i=yY5S7B1-hLZ5g@mail.gmail.com
Hi Ludo,

On Mon, 14 Feb 2022 at 15:56, Ludovic Courtès <ludo@gnu.org> wrote:

Toggle quote (10 lines)
> > (option '("details") #f #f
> > (lambda (opt name arg result)
> > - (alist-cons 'details? #t result)))
> > + (alist-cons 'details? #t
> > + (cons '(query list-generations #f)
> > + result))))
>
> It’s a bit more complicated since you don’t want to override previous
> ‘-l’ arguments, but I did that.

Ah yes, indeed. Keep the pattern. :-)

Toggle quote (3 lines)
> There’s a ZERO WIDTH NON-JOINER above; you can see it with a trick I
> recently learned: (set-face-background 'glyphless-char "red").

Oh, cool. Thanks!


Toggle quote (2 lines)
> Anyway, pushed:

Thanks for the quick fix and I hope more people will read now the news. :-)

Cheers,
simon
Closed
?