From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [PATCH] guix package: Add '--switch-generation' option. Date: Wed, 08 Oct 2014 11:44:36 +0200 Message-ID: <87siiysxob.fsf@gnu.org> References: <87k3719v7p.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> <8761hsmxkl.fsf@gnu.org> <87zjf4d1mh.fsf@gmail.com> <87mwb0b3fq.fsf@gnu.org> <87ha17ctyv.fsf_-_@gmail.com> <87ppfs6gxk.fsf@gnu.org> <87wq8fk979.fsf_-_@gmail.com> <87eguninyx.fsf@gnu.org> <8738b1jndu.fsf_-_@gmail.com> <87ppe5vw1b.fsf@gnu.org> <87y4ssi4ak.fsf@gmail.com> <87h9zfc1ko.fsf@gnu.org> <87lhorin05.fsf@gmail.com> 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]:37149) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XbnnW-00051G-Gj for guix-devel@gnu.org; Wed, 08 Oct 2014 05:44:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XbnnN-0002Cx-5Y for guix-devel@gnu.org; Wed, 08 Oct 2014 05:44:42 -0400 Received: from hera.aquilenet.fr ([2a01:474::1]:50679) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XbnnM-0002Ca-Mt for guix-devel@gnu.org; Wed, 08 Oct 2014 05:44:33 -0400 In-Reply-To: <87lhorin05.fsf@gmail.com> (Alex Kost's message of "Wed, 08 Oct 2014 01:32:58 +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: Alex Kost Cc: guix-devel@gnu.org Alex Kost skribis: > Ludovic Court=C3=A8s (2014-10-07 20:00 +0400) wrote: > >> Alex Kost skribis: [...] >> It=E2=80=99d be enough for me to just call =E2=80=98switch-symlinks=E2= =80=99 and let it throw >> =E2=80=98system-error=E2=80=99 if something=E2=80=99s wrong. The except= ion will be caught, the >> user will see a =E2=80=9CNo such file=E2=80=9D error, and =E2=80=98guix = package=E2=80=99 with exit with >> non-zero (this is done by =E2=80=98call-with-error-handling=E2=80=99.) > > =E2=80=98switch-symlinks=E2=80=99 does not throw an error even if files d= on't exist, so=E2=80=A6 Oh right, =E2=80=98symlink=E2=80=99 doesn=E2=80=99t care about its first ar= gument. >> It=E2=80=99s less informative than what you did, though. The other opti= on would >> be to define specific error condition types and throw them from here. >> >> WDYT? > > =E2=80=A6 I tried to make it this way, thank you for pointing. I made an= other > commit for adding and using condition types (3 patches are attached > now). Great. > Also I moved =E2=80=98process-query=E2=80=99 inside =E2=80=98with-error-h= andling=E2=80=99 (because I > used =E2=80=98raise=E2=80=99 there). Could there be unwanted consequence= s after that? No, I think it=E2=80=99s fine. > From d5e9abb0395a21e79d4f77181597103d4daf138c Mon Sep 17 00:00:00 2001 > From: Alex Kost > Date: Wed, 8 Oct 2014 00:32:28 +0400 > Subject: [PATCH 1/3] profiles: Add condition types for profile and genera= tion. > > * guix/profiles.scm (&profile-error, &generation-error): New condition ty= pes. > * guix/ui.scm (call-with-error-handling): Handle these types. > * guix/scripts/package.scm (roll-back, guix-package): Raise '&profile-err= or' > where needed. This is bikeshedding, but I would make a hierarchy like this: &profile-error, with =E2=80=98profile=E2=80=99 field ^ .=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94= =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=93+=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80= =93. | | &profile-not-found-error &missing-generation-error, with =E2=80=98= generation=E2=80=99 field WDYT? Other than that the patch looks good. > From e47644b43aaa73885ca648118b6fc59fdb499303 Mon Sep 17 00:00:00 2001 > From: Alex Kost > Date: Wed, 8 Oct 2014 00:39:42 +0400 > Subject: [PATCH 2/3] profiles: Add procedures for switching generations. > > * guix/scripts/package.scm (switch-to-previous-generation): Move to... > * guix/profiles.scm: ... here. Use 'switch-to-generation'. > (relative-generation): New procedure. > (previous-generation-number): Use it. > (switch-to-generation): New procedure. OK. > From 003e5c192796e8ea07491a94a85824a533155825 Mon Sep 17 00:00:00 2001 > From: Alex Kost > Date: Wed, 8 Oct 2014 00:45:38 +0400 > Subject: [PATCH 3/3] guix package: Add '--switch-generation' option. > > * guix/scripts/package.scm: Add '--switch-generation' option. > (guix-package): Adjust accordingly. > * tests/guix-package.sh: Test it. > * doc/guix.texi (Invoking guix package): Document it. OK. Thanks again! Ludo=E2=80=99.