From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: Display diffs between generations. Date: Wed, 31 Aug 2016 22:52:56 +0200 Message-ID: <87y43ck6dz.fsf@gnu.org> References: <87eg59izmw.fsf@gnu.org> <87d1kry22u.fsf@gnu.org> <87inuj5r5v.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49926) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bfCVO-0006dy-5y for guix-devel@gnu.org; Wed, 31 Aug 2016 16:53:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bfCVH-0002kC-9v for guix-devel@gnu.org; Wed, 31 Aug 2016 16:53:04 -0400 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:48812) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bfCVH-0002k8-6m for guix-devel@gnu.org; Wed, 31 Aug 2016 16:52:59 -0400 In-Reply-To: <87inuj5r5v.fsf@gnu.org> (Roel Janssen's message of "Mon, 29 Aug 2016 21:08:44 +0200") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Roel Janssen Cc: guix-devel@gnu.org Roel Janssen skribis: > Ludovic Court=C3=A8s writes: > >> Hi Roel, >> >> I=E2=80=99ve just tried the patch and I think it=E2=80=99s awesome! I= =E2=80=99ve also always >> been dissatisfied with what =E2=80=98--list-generations=E2=80=99 provide= s=E2=80=94it=E2=80=99s >> inconvenient as soon as you have more than a handful packages. >> >> Perhaps we could add an optional argument to --list-generations where: >> >> --list-generations >> >> would be equivalent to: >> >> --list-generations=3Ddiff >> >> and: >> >> --list-generations=3Dfull >> >> would restore the previous behavior. It doesn=E2=80=99t cost much to do= that. >> >> WDYT? > > That would be great. Currently, the --list-generations already takes a > generation number. Ah, good point. Well, forget my suggestion then; I=E2=80=99d say, let=E2= =80=99s just do diffs, and that=E2=80=99s it. If someone wants to list the contents of one generation, they can always do =E2=80=9C--list-generations=3D42=E2=80=9D, w= hich does exactly that. Anyone against =E2=80=98--list-generations=E2=80=99 always displaying diffs= ? Time to speak up! :-) >> In general, I find it clearer to define the singular form and inline the >> =E2=80=98for-each=E2=80=99: >> >> (define display-entry >> (match-lambda =E2=80=A6)) >> >> =E2=80=A6 >> >> (for-each display-entry entries) >> >> Otherwise LGTM! > > Right. That does look clearer. I refactored the function further to > the following: > > ------- BEGIN ------- > (define (display-profile-content-diff profile number) > "Display the changed packages in PROFILE compared to generation NUMBER." > > (define (equal-entry? first second) > (string=3D (manifest-entry-item first) > (manifest-entry-item second))) > > (define display-entry > (match-lambda > (($ name version output location _) > (format #f "~a\t~a\t~a\t~a~%" name version output location)))) > > (define (display-entries entries prefix) > (for-each (lambda (entry) > (format #t " ~a ~a" prefix (display-entry entry))) entri= es)) [...] > The thing with `display-entries' is because I cannot pass two arguments > in the function used in the `for-each', and the prefix for `installed' > or `removed' differs, I cannot remove it that easily :-). Maybe like this: (define (display-entry entry prefix) (match entry =E2=80=A6)) =E2=80=A6 (for-each (cut display-entry <> "+") added) (for-each (cut display-entry <> "-") removed) Let=E2=80=99s wait a bit to see what people think. Thanks! Ludo=E2=80=99.