From patchwork Thu Jul 20 16:34:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 51863 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 591C727BBE9; Thu, 20 Jul 2023 17:35:27 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id AC26427BBE2 for ; Thu, 20 Jul 2023 17:35:26 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMWcT-0006pi-Qt; Thu, 20 Jul 2023 12:35:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMWcP-0006nt-1C for guix-patches@gnu.org; Thu, 20 Jul 2023 12:35:10 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qMWcO-000776-97; Thu, 20 Jul 2023 12:35:08 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qMWcI-0007Ji-1a; Thu, 20 Jul 2023 12:35:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#64746] [PATCH 2/2] scripts: time-machine: Error when attempting to visit too old commits. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: mail@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Thu, 20 Jul 2023 16:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 64746 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 64746@debbugs.gnu.org, maxim.cournoyer@gmail.com Cc: Simon Tournier , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-To: guix-patches@gnu.org, maxim.cournoyer@gmail.com X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by submit@debbugs.gnu.org id=B.168987085828058 (code B ref -1); Thu, 20 Jul 2023 16:35:01 +0000 Received: (at submit) by debbugs.gnu.org; 20 Jul 2023 16:34:18 +0000 Received: from localhost ([127.0.0.1]:59634 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qMWba-0007IT-Bi for submit@debbugs.gnu.org; Thu, 20 Jul 2023 12:34:18 -0400 Received: from lists.gnu.org ([2001:470:142::17]:50774) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qMWbX-0007I8-Kv for submit@debbugs.gnu.org; Thu, 20 Jul 2023 12:34:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMWbS-0006KA-2U for guix-patches@gnu.org; Thu, 20 Jul 2023 12:34:10 -0400 Received: from mail-qt1-x830.google.com ([2607:f8b0:4864:20::830]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qMWbP-0006lX-V5 for guix-patches@gnu.org; Thu, 20 Jul 2023 12:34:09 -0400 Received: by mail-qt1-x830.google.com with SMTP id d75a77b69052e-4039a2b71c1so8120951cf.0 for ; Thu, 20 Jul 2023 09:34:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689870846; x=1690475646; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=045dGLNHIPQhzDZ2hgQBBy4cIPRrb+GTPYAsubP80dE=; b=GPYkpFFgwQ+WqAjOua0dMZhrPk9NSeVoWqWsPsKSI0Tx8RPRdulEZmhsvkbqDmwj3L AidSDmDWIg/Dx7Mv8uDtIyvF/teVJZesZZx3rmgGij1c8jBnH5LRlQBZHwoq56upVf8W mQ2H0GodNjPI1q27At3IJ9Rk/c+tEKgNsAulpdga9DgEtbKS37FrwqGa76WFILKUJcuW h3am+z014jJeAHhux6t4HpRAoAF66TqoYbFUNkIsq2dAL8P6L1Jsi9KNQQtjxfXAWRmk K4HGHUF6sV5o+6rP2CYbeurp69zlFmHupBuw/2qMRsf2VTLXI4qoXHjKKr5wPTs1IpI1 U8lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689870846; x=1690475646; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=045dGLNHIPQhzDZ2hgQBBy4cIPRrb+GTPYAsubP80dE=; b=QENp7BsgoeiyDG8O1eG+/gCmB8N34kugHWreSVeZjW6TcT49CcyLxLQryyT7bBNyyh hyoIqQK6rjbWSlvhHbZ0TlBuXmF3SK/rkNx0FIr37dWg18g/jyGPZBsbH/ELN/xlUUdO HcLEok/X3rlhtM4MHQLWvsfWsvn8twlJjOvkizAzIq87ZsoVx2nXiru35xgNF5S+btBS PnAaZkjmgqdsGRvRpfUsjCD4UJx6vIy3mTmq6icMEHV6tCOtFs0aWwmTIrKj4gR7qcry FOW4FouQqGOJUpsYaavb5tNMvT6DFmdqsiJe0eNT7W0L2Fnw2ATvIk4C+NXVjp8JlFVn /tfA== X-Gm-Message-State: ABy/qLYlvdHFdPn9saJe5T5LW9f/xRMEAuJhramhuutuqsaaGs//hco+ 5PMTE3Zw2OWmFwr1xjKQOSNaBWw2Xek= X-Google-Smtp-Source: APBJJlH0pXITnxf/op/3+JE3lKNDWzUBJKgkEVyUutKUo/oXXuGgi5mhmqsW5jyNpKTTOqO52hjCxA== X-Received: by 2002:ac8:5992:0:b0:405:4673:58e0 with SMTP id e18-20020ac85992000000b00405467358e0mr1378729qte.63.1689870846507; Thu, 20 Jul 2023 09:34:06 -0700 (PDT) Received: from localhost.localdomain (dsl-159-145.b2b2c.ca. [66.158.159.145]) by smtp.gmail.com with ESMTPSA id j7-20020ac84c87000000b00401e04c66fesm510860qtv.37.2023.07.20.09.34.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jul 2023 09:34:06 -0700 (PDT) From: Maxim Cournoyer Date: Thu, 20 Jul 2023 12:34:01 -0400 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::830; envelope-from=maxim.cournoyer@gmail.com; helo=mail-qt1-x830.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * doc/guix.texi (Invoking guix time-machine): Document limitation. * guix/scripts/time-machine.scm (%oldest-possible-commit): New variable. (guix-time-machine): Raise an error when the channel commit is too old. Suggested-by: Simon Tournier --- doc/guix.texi | 6 ++++++ guix/scripts/time-machine.scm | 23 ++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index 1d8ebcd72f..30fef813c0 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -5056,6 +5056,12 @@ Invoking guix time-machine large number of packages; the result is cached though and subsequent commands targeting the same commit are almost instantaneous. +Due to @command{guix time-machine} relying on the ``inferiors'' +mechanism (@pxref{Inferiors}), the oldest commit it can travel to is +commit @samp{2ca299caf} (``Add (guix inferior) and (guix scripts +repl).''), dated July 10@sup{th}, 2018. An error is returned when +attempting to navigate to older commits. + @quotation Note The history of Guix is immutable and @command{guix time-machine} provides the exact same software as they are in a specific Guix diff --git a/guix/scripts/time-machine.scm b/guix/scripts/time-machine.scm index d7c71ef705..36a40a1538 100644 --- a/guix/scripts/time-machine.scm +++ b/guix/scripts/time-machine.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2019 Konrad Hinsen ;;; Copyright © 2019, 2020, 2021 Ludovic Courtès ;;; Copyright © 2021 Simon Tournier +;;; Copyright © 2023 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -19,13 +20,15 @@ ;;; along with GNU Guix. If not, see . (define-module (guix scripts time-machine) + #:use-module (guix channels) + #:use-module (guix diagnostics) #:use-module (guix ui) #:use-module (guix scripts) #:use-module (guix inferior) #:use-module (guix store) #:use-module (guix status) #:use-module ((guix git) - #:select (with-git-error-handling)) + #:select (update-cached-checkout with-git-error-handling)) #:use-module ((guix utils) #:select (%current-system)) #:use-module ((guix scripts pull) @@ -38,9 +41,16 @@ (define-module (guix scripts time-machine) #:use-module (srfi srfi-1) #:use-module (srfi srfi-11) #:use-module (srfi srfi-26) + #:use-module (srfi srfi-34) #:use-module (srfi srfi-37) + #:use-module (srfi srfi-71) #:export (guix-time-machine)) +;;; The commit introducing the 'inferiors' mechanism; it is the oldest commit +;;; that can be travelled to. +(define %oldest-possible-commit + "2ca299caf64489f4e1e665ec1158fb0309b0b565") + ;;; ;;; Command-line options. @@ -139,9 +149,20 @@ (define-command (guix-time-machine . args) (with-git-error-handling (let* ((opts (parse-args args)) (channels (channel-list opts)) + (guix-channel (find guix-channel? channels)) (command-line (assoc-ref opts 'exec)) + (ref (assoc-ref opts 'ref)) + (checkout commit relation (update-cached-checkout + (channel-url guix-channel) + #:ref (or ref '()) + #:starting-commit + %oldest-possible-commit)) (substitutes? (assoc-ref opts 'substitutes?)) (authenticate? (assoc-ref opts 'authenticate-channels?))) + (unless (memq relation '(ancestor self)) + (raise (formatted-message + (G_ "cannot travel past commit `~a' from July 10th, 2018") + (string-take %oldest-possible-commit 12)))) (when command-line (let* ((directory (with-store store