From patchwork Sun Mar 23 07:28:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40713 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 ED45627BBE9; Sun, 23 Mar 2025 07:31:09 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,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 C4E4727BBE2 for ; Sun, 23 Mar 2025 07:31:09 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1twFmv-0001UU-QP; Sun, 23 Mar 2025 03:30:29 -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 1twFmt-0001RW-Fg for guix-patches@gnu.org; Sun, 23 Mar 2025 03:30:27 -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 1twFmt-000056-0Z; Sun, 23 Mar 2025 03:30:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=rrhSfMRParvnEoPsd8PRNLNnCpGJ1AEC4RVTgfshvK8=; b=oBGwPLrBON3lpFPWBdG/eum78KfoMU2wMKwhPsbnPR3wW0B5xUXm/leAJJjEvUTpkZXJdf/gxYoWBzS1+l8tDyoIFCTIPwLv5xWXyqAlnp+oOwJQOcKtgDCG4ynfdz2fygQMSQzfZv1Elg4hruqcHtIbKnTv2VSkItiTwHPVj/bxqqDKLOHJ+/sJBj1Gh1u14XwZNy5omYwgbR1JFzvc3xO7mJsuVLqxR5aqJBnsAocrVixjBSGtJ+3muUOCgK+Ye5iltwXaf/+fhVh2849x09ITu6pD0nAOr0UQnRKFSFQJbqfaYJWI79u02YR8XTTrhF0EVdF1n/6Dh+zhts10PQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1twFms-0004Rg-3a; Sun, 23 Mar 2025 03:30:26 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v3 12/17] scripts: import: Skip existing definition for =?utf-8?b?4oCYLS1pbnNlcnTigJk=?= option. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Sun, 23 Mar 2025 07:30:26 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174271500116395 (code B ref 77093); Sun, 23 Mar 2025 07:30:26 +0000 Received: (at 77093) by debbugs.gnu.org; 23 Mar 2025 07:30:01 +0000 Received: from localhost ([127.0.0.1]:47351 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1twFmS-0004GE-DE for submit@debbugs.gnu.org; Sun, 23 Mar 2025 03:30:00 -0400 Received: from mx.boiledscript.com ([88.99.243.112]:48284) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1twFm8-0004CY-V9 for 77093@debbugs.gnu.org; Sun, 23 Mar 2025 03:29:42 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742714979; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rrhSfMRParvnEoPsd8PRNLNnCpGJ1AEC4RVTgfshvK8=; b=LPnH+aIrc6AAC52yIAYOvvWD8T4BotIa0TG1Ve17I7cZkFtbGs4P57Q5bGAscqWlFyAd2L Xd4cV7RsW5jkeJQkJs2Rz8NtWCEd73hUHRO4dlAX12LNeGGs4sd4GMxth4lgvwzEtk3vO6 8kZ+7gcqro9Cc9y0SioNfgXQyRzkBVLxnSMvgtKx1qANINHgrm9Zxvo7Duvxt9r5PHAmm6 7Ho+YD7Y5jefo+dzw2DRc6O+8gZfq8G/V4HINZVJfxoT2Rrj3ME8Pxcth0hKTxR4+cTZlN lPoL8A7Gf7Q3pbSqNePKkHk543URjjo8oG/zlC75gCHj+OOtMVbqWwTCf1/lCg== Date: Sun, 23 Mar 2025 15:28:34 +0800 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-MS-Reactions: disallow 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/import.scm (guix-import): Skip existing definition for ‘--insert’ option. Change-Id: I2c4242669f974b263a018ab0cf56538bd7c81d06 --- guix/scripts/import.scm | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm index 38349bff3a..1bddac15c6 100644 --- a/guix/scripts/import.scm +++ b/guix/scripts/import.scm @@ -136,16 +136,19 @@ (define-command (guix-import . args) (lambda (expr) (match expr (((? define-prefix? define-prefix) term _ ...) - (let ((source-properties - (find-definition-insertion-location - file term #:define-prefix define-prefix))) - (if source-properties - (insert-expression source-properties expr) - (let ((port (open-file file "a"))) - (pretty-print-with-comments port expr) - (newline port) - (newline port) - (close-port port))))))))) + ;; Skip existing definition. + (unless (find-definition-location + file term #:define-prefix define-prefix) + (let ((source-properties + (find-definition-insertion-location + file term #:define-prefix define-prefix))) + (if source-properties + (insert-expression source-properties expr) + (let ((port (open-file file "a"))) + (pretty-print-with-comments port expr) + (newline port) + (newline port) + (close-port port)))))))))) (import-as-definitions importer (cons (string-append "--file-to-insert=" file) args)