From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Kost Subject: Re: [PATCH] Emacs interface for Guix Date: Fri, 15 Aug 2014 09:51:21 +0400 Message-ID: <878umqe1wm.fsf@gmail.com> References: <87k3719v7p.fsf@gmail.com> <87r419fa50.fsf@gnu.org> <87fvho9fqm.fsf@gmail.com> <87a97taixl.fsf@gmail.com> <87sil2rbly.fsf@gnu.org> <87tx5idn7f.fsf_-_@gmail.com> <87egwlkcy1.fsf@gnu.org> <87ppg5el2i.fsf@gmail.com> <87d2c5h4if.fsf@gnu.org> <87lhqsev1d.fsf@gmail.com> <877g2c74xh.fsf@gnu.org> <87ha1gds3w.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52447) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIAQF-0003pb-AZ for guix-devel@gnu.org; Fri, 15 Aug 2014 01:51:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XIAQ6-0000li-9H for guix-devel@gnu.org; Fri, 15 Aug 2014 01:51:31 -0400 In-Reply-To: <87ha1gds3w.fsf@gmail.com> (Alex Kost's message of "Thu, 14 Aug 2014 00:58:27 +0400") 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-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: guix-devel@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Alex Kost (2014-08-14 00:58 +0400) wrote: > Ludovic Court=C3=A8s (2014-08-13 20:03 +0400) wrote: > > [...] > >> Could you turn the above thing into a patch with a commit log? Bonus >> points for =E2=80=98manifest-perform-transaction=E2=80=99 unit tests. M= ake sure to add >> a copyright line for yourself in profiles.scm. >> >> And then a second patch to actually use it in (guix scripts package) >> would be wonderful. :-) > > Ok, I'm attaching these patches. But there are several issues there: > > - I fixed a typo in "tests/profiles.scm" (=E2=80=9Cprofile=E2=80=9D -> = =E2=80=9Cprofiles=E2=80=9D) =E2=80=93 Is > it ok to do this in that commit or should there be a separate commit? > > - I added a copyright line to the test file as well. Is it ok? > > - The main thing: look at =E2=80=98manifest-show-transaction=E2=80=99 =E2= =80=93 unlike > =E2=80=98show-what-to-remove/install=E2=80=99 it doesn't display an out= put path of a > package item, because a store should be used for that. So is it > acceptable or should something be changed there? > >> In the next iteration, =E2=80=98show-what-to-remove/install=E2=80=99 sho= uld report >> packages that are going to be upgraded (by checking among =E2=80=98insta= ll=E2=80=99 >> those are already in the manifest.) > > I'll try to do this. Hello and pardon for replying to my own letter. If the displaying an ouput path is not an issue, what about the following variant of =E2=80=98manifest-show-transaction=E2=80=99: --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=manifest-show-transaction.scm (define* (manifest-show-transaction manifest transaction #:key dry-run?) "Display what will/would be installed/removed from MANIFEST by TRANSACTION." (define (display-entries entries action-string) (match entries ((($ name version output item _) ..1) (let ((len (length name)) (package-strings (map (lambda (name version output item) (if (package? item) (format #f " ~a-~a\t~a" name version output) (format #f " ~a-~a\t~a\t~a" name version output item))) name version output item))) (format (current-error-port) (N_ "The following package ~:[will~;would~] be ~a:~%~{~a~%~}~%" "The following packages ~:[will~;would~] be ~a:~%~{~a~%~}~%" len) dry-run? action-string package-strings))) (_ #f))) (let* ((remove (manifest-matching-entries manifest (manifest-transaction-remove transaction))) (install (manifest-transaction-install transaction)) (upgrade (append-map (lambda (entry) (manifest-matching-entries manifest (list (manifest-pattern (name (manifest-entry-name entry)) (output (manifest-entry-output entry)))))) install))) (display-entries upgrade "upgraded (removed)") (display-entries install "installed") (display-entries remove "removed"))) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable I tried to avoid the code duplicating, so it became more compact and perhaps less readable. Also I added reporting about the packages to upgrade: I thought as they are going to be replaced by the packages to install, it is ok to add =E2=80=9C(removed)=E2=80=9D there. So an output s= hould look like this (assuming "file-5.17" and "guile-2.0.9" are installed and are being upgraded): The following packages will be upgraded (removed): file-5.17 out /gnu/store/... guile-2.0.9 out /gnu/store/... The following packages will be installed: file-5.18 out guile-2.0.11 out --=-=-=--