From patchwork Thu Jul 20 03:28:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 51856 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 5269927BBE9; Thu, 20 Jul 2023 04:32:19 +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 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 B16F527BBE2 for ; Thu, 20 Jul 2023 04:32:18 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMKOc-0000G7-0M; Wed, 19 Jul 2023 23:32:06 -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 1qMKOa-0000FZ-Fy for guix-patches@gnu.org; Wed, 19 Jul 2023 23:32:04 -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 1qMKOa-0003hT-2H; Wed, 19 Jul 2023 23:32:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qMKOX-00068a-Lk; Wed, 19 Jul 2023 23:32:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#64737] [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 03:32:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64737 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 64737@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.168982386523526 (code B ref -1); Thu, 20 Jul 2023 03:32:01 +0000 Received: (at submit) by debbugs.gnu.org; 20 Jul 2023 03:31:05 +0000 Received: from localhost ([127.0.0.1]:57417 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qMKNd-00067O-EB for submit@debbugs.gnu.org; Wed, 19 Jul 2023 23:31:05 -0400 Received: from lists.gnu.org ([2001:470:142::17]:53674) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qMKNX-00066N-RY for submit@debbugs.gnu.org; Wed, 19 Jul 2023 23:31:04 -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 1qMKNR-0008LD-PS for guix-patches@gnu.org; Wed, 19 Jul 2023 23:30:53 -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 1qMKNP-0002FE-WD for guix-patches@gnu.org; Wed, 19 Jul 2023 23:30:53 -0400 Received: by mail-qt1-x830.google.com with SMTP id d75a77b69052e-4039a2b71c1so3177471cf.0 for ; Wed, 19 Jul 2023 20:30:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689823850; x=1690428650; 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=nNZ1aIR2FtJiGSwA7Zhg8LuLbfrjVr6S874lvlGoMEk=; b=efn5hmgrOuWTq53ocblEzCYbliUS9HkPIXj9DVVldCzRmVSgwEmYbHzhy33WxX5eTF 3Md7Tmudwh1aPv2CpChrK1WvjB6lHvqkpZcyXHIDCwcNnQPCf4g8ZPPJCGRvSBTHCtLF fSDhlHXDqszNn6xFsKq64cEgJ5x6+4ryIBZCQKZemd0OEOtazIjhsKqeJivrpO0LIfYX Yj053QUolVIA+YoERiGF7OAeDJZGA6sQp281nxS+HQCV9TECvJjh9dao5iKUM0Hms6/2 sykkQeIiCV5ATIQ7TT0a+eGMYj3dY493+9JveCtMmcQ5pMAbglDhjE8ew/6taklkftW4 BdGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689823850; x=1690428650; 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=nNZ1aIR2FtJiGSwA7Zhg8LuLbfrjVr6S874lvlGoMEk=; b=ZGm1hgKuRW5G5d+vhWjHONTaGRjkWPRp92zT/2EQUEp8Yen7JrCKEXWZsfwxDLYEhY DWIbzujG08GAJphRRV17sRxsncTuN+AM4MbzpRtlYr7BTMv2owfnHxyPJnCxekk60Eox ul2KvhdNKkUNV2LEEYrKMR5e5c6V8YqZKduPZwY2pVCjMeitIe8Pp3/0s9y2h9S40+09 F3QxXXndpQ8TqWTHh0ggB5IyBDeAKX+WMtQERRBDkjBLPVivZsF1qT40F/z3wEpoSD0o 1+t9PTe+m702l9UmZIh4UuupPnvtgPaD9ckBMN7j+S/uOHcRuiLvMeNk/R+fkakjFKzz dpJA== X-Gm-Message-State: ABy/qLZp1JQ9Q6lp+T4M888IAM9BDqqIOo6phwa3E8HHUo6NeADfu1tF UVZH4PYuw11O/A44exJRqBEZQD/LKzY= X-Google-Smtp-Source: APBJJlHO/xCM7o5V9EXYJNLFU1+C2pPySLVKnDhQsG0OS4nScydxqpdks5OnUvIbZYgnFOvQ3MHwfw== X-Received: by 2002:ac8:5914:0:b0:403:ae76:d0a3 with SMTP id 20-20020ac85914000000b00403ae76d0a3mr23232139qty.8.1689823850392; Wed, 19 Jul 2023 20:30:50 -0700 (PDT) Received: from localhost.localdomain (dsl-159-145.b2b2c.ca. [66.158.159.145]) by smtp.gmail.com with ESMTPSA id s15-20020ac8528f000000b003f9efa2ddb4sm31495qtn.66.2023.07.19.20.30.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jul 2023 20:30:50 -0700 (PDT) From: Maxim Cournoyer Date: Wed, 19 Jul 2023 23:28:51 -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