From patchwork Thu May 18 15:16:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 50112 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 0672017A9A; Thu, 18 May 2023 16:17:56 +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_INVALID, DKIM_SIGNED,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 54D2E17A6F for ; Thu, 18 May 2023 16:17:55 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzfNZ-0003aX-Be; Thu, 18 May 2023 11:17:22 -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 1pzfNO-0003KS-1i for guix-patches@gnu.org; Thu, 18 May 2023 11:17:11 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzfNM-0001yr-PN; Thu, 18 May 2023 11:17:09 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pzfNI-0005U7-0U; Thu, 18 May 2023 11:17:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63571] [PATCH 07/14] diagnostics: Factorize 'absolute-location'. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= 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, 18 May 2023 15:17:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63571 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63571@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice 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 63571-submit@debbugs.gnu.org id=B63571.168442301421003 (code B ref 63571); Thu, 18 May 2023 15:17:03 +0000 Received: (at 63571) by debbugs.gnu.org; 18 May 2023 15:16:54 +0000 Received: from localhost ([127.0.0.1]:54124 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pzfN8-0005Sb-21 for submit@debbugs.gnu.org; Thu, 18 May 2023 11:16:54 -0400 Received: from eggs.gnu.org ([209.51.188.92]:55656) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pzfMy-0005QU-CH for 63571@debbugs.gnu.org; Thu, 18 May 2023 11:16:45 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzfMt-0001vQ-6L; Thu, 18 May 2023 11:16:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=SdbfEdQYGJSe7HirGcp0UVp/kervV8q1evm4RQ5/DTs=; b=GQpQrjZ+2JNBvmrpAZc4 /8h28w84oIAR3ZgT2Nfz1bvVdfiwXswRrM9LB98oXg3X/ow23JXdK/j/5+GF+/uB5TnZErTAv55oQ xfZxPVWwi5PQ+e67QBzwoJX5F4H3r+3Z66jqA9MZ8ekYvE6H0/+uVOooE8KaAb6/0NcEVRnyKi52Z AIj1QhKsZO8Y3zmk8g0PpRMyfEU16+/UM+4VaLFLGyYrf2c4JwIcNwtshL4iTSSwEZ5SZsZsNAhO3 p4F3omEXXG2bdjYbaqacngwY85aezQKSOhCs55+fL19+pAG7IcGYwi6/t67/43F1peqE3nSJOxIKZ dpd4f0jVt3AzjA==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzfMs-0007G6-PJ; Thu, 18 May 2023 11:16:38 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Thu, 18 May 2023 17:16:15 +0200 Message-Id: <435ffbe3922c46f3e55bfe607f0f8e7a5dd4aa1b.1684421460.git.ludo@gnu.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 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 * guix/scripts/style.scm (absolute-location): Move to... * guix/diagnostics.scm (absolute-location): ... here. * guix/upstream.scm (update-package-source): Use it. --- guix/diagnostics.scm | 20 +++++++++++++++++++- guix/scripts/style.scm | 17 ----------------- guix/upstream.scm | 4 ++-- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/guix/diagnostics.scm b/guix/diagnostics.scm index 9f0d558f2f..3f1f527b43 100644 --- a/guix/diagnostics.scm +++ b/guix/diagnostics.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès +;;; Copyright © 2012-2021, 2023 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -36,6 +36,7 @@ (define-module (guix diagnostics) location-file location-line location-column + absolute-location source-properties->location location->source-properties location->string @@ -340,6 +341,23 @@ (define-syntax formatted-message (&formatted-message (format str) (arguments (list args ...)))))))))) +(define (absolute-location loc) + "Replace the file name in LOC by an absolute location." + (location (if (string-prefix? "/" (location-file loc)) + (location-file loc) + + ;; 'search-path' might return #f in obscure cases, such as + ;; when %LOAD-PATH includes "." or ".." and LOC comes from a + ;; file in a subdirectory thereof. + (match (search-path %load-path (location-file loc)) + (#f + (raise (formatted-message + (G_ "file '~a' not found on load path") + (location-file loc)))) + (str str))) + (location-line loc) + (location-column loc))) + (define guix-warning-port (make-parameter (current-warning-port))) diff --git a/guix/scripts/style.scm b/guix/scripts/style.scm index 00c7d3f90c..3f5d757e10 100644 --- a/guix/scripts/style.scm +++ b/guix/scripts/style.scm @@ -225,23 +225,6 @@ (define (edit-expression/dry-run properties rewrite-string) (G_ "would be edited~%"))) str))) -(define (absolute-location loc) - "Replace the file name in LOC by an absolute location." - (location (if (string-prefix? "/" (location-file loc)) - (location-file loc) - - ;; 'search-path' might return #f in obscure cases, such as - ;; when %LOAD-PATH includes "." or ".." and LOC comes from a - ;; file in a subdirectory thereof. - (match (search-path %load-path (location-file loc)) - (#f - (raise (formatted-message - (G_ "file '~a' not found on load path") - (location-file loc)))) - (str str))) - (location-line loc) - (location-column loc))) - (define (trivial-package-arguments? package) "Return true if PACKAGE has zero arguments or only \"trivial\" arguments guaranteed not to refer to input labels." diff --git a/guix/upstream.scm b/guix/upstream.scm index 6f2a4dca28..29dd923e63 100644 --- a/guix/upstream.scm +++ b/guix/upstream.scm @@ -630,8 +630,8 @@ (define* (update-package-source package source hash) ;; function of the person who uploads the package. Note that ;; package definitions usually concatenate fragments of the URL, ;; which is why we only attempt to replace a subset of the URL. - (let ((properties (assq-set! (location->source-properties loc) - 'filename file)) + (let ((properties (location->source-properties + (absolute-location loc))) (replacements `((,old-version . ,version) (,old-hash . ,hash) ,@(if (and old-commit new-commit)