From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id MMfsBw7Z3GB1ZQEAgWs5BA (envelope-from ) for ; Wed, 30 Jun 2021 22:50:22 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id UFumAw7Z3GDsRAAAB5/wlQ (envelope-from ) for ; Wed, 30 Jun 2021 20:50:22 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9DE21221DF for ; Wed, 30 Jun 2021 22:50:21 +0200 (CEST) Received: from localhost ([::1]:53484 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyhA4-00016c-LP for larch@yhetil.org; Wed, 30 Jun 2021 16:50:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyh9r-0000yt-0k for guix-patches@gnu.org; Wed, 30 Jun 2021 16:50:07 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:47415) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lyh9q-0001ks-PN for guix-patches@gnu.org; Wed, 30 Jun 2021 16:50:06 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lyh9q-0005Cq-N7 for guix-patches@gnu.org; Wed, 30 Jun 2021 16:50:06 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49169] [PATCH v2 09/16] utils: 'edit-expression' modifies the file only if necessary. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 30 Jun 2021 20:50:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49169 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49169@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 49169-submit@debbugs.gnu.org id=B49169.162508615519844 (code B ref 49169); Wed, 30 Jun 2021 20:50:06 +0000 Received: (at 49169) by debbugs.gnu.org; 30 Jun 2021 20:49:15 +0000 Received: from localhost ([127.0.0.1]:58940 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyh91-00059u-AV for submit@debbugs.gnu.org; Wed, 30 Jun 2021 16:49:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47896) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyh8n-00055w-Gg for 49169@debbugs.gnu.org; Wed, 30 Jun 2021 16:49:01 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:53136) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyh8i-0000zk-8J; Wed, 30 Jun 2021 16:48:56 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=42586 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lyh8h-0001jQ-SV; Wed, 30 Jun 2021 16:48:56 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Wed, 30 Jun 2021 22:48:25 +0200 Message-Id: <20210630204832.25753-10-ludo@gnu.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210630204832.25753-1-ludo@gnu.org> References: <20210622090221.15182-1-ludo@gnu.org> <20210630204832.25753-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1625086221; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=nwrPPxf0+hQHK+h8bLAHGpR+y/By3vxqUM5YQxO2s5E=; b=MHqWiruUC89OB6QSj4lvXLxU1u5pIoZCmBbBI7Vx0cYx6OnVkyZ5jlM5Rs8q+IptJJd/Pq PQ7QevUtcUywbRqLQpgNWS0VVxqpRQ/a3n/tpsRxC7nG/j1aahtVDm2FUGFzokg8if3JU/ Zx/VD8bZyjVWIpRlsEa36gQhplRx6AOdZ3jxeU0mW7WTBF6ALVgiAQ2KEyhoO9DzxvnrOd dHOLcnJr4pcEX2kMxnNt0Ze8aGfLSrA3XQVRDnoNgXiKudd4WfN0ijZHegziXqXhvDGhJy jAu7l6kikMRkFkZ9P9W7JuT9+EUgYPsHCUv0ex07MN9iC687Eywe/N0kAu2O7w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1625086221; a=rsa-sha256; cv=none; b=fkxo/r/wTtc8UPdJaqjmoyU0TCk/RYvR4LTgc7aiOPTNZtOm99tvwNy1QOXz37djSXTjbq AwnloStydFmfBH4y5WrelUG0q6jpSbiExLqJRqM3dMKY3si3P15CYMoB4PIqfFvFvozWh6 93R9+vOzRCbnAbdst9YDrXlQhqYvphX71js+lsSV/X+Nu+DwMrYCePIF/4LzcjNkEA1ehQ 28Yyddp7cNEoioh0DWVhT0B8dJx7URaIY12B/xJPKCKxGGi2xyW6v/PP9pwjqtLRUy5lEt RrlBERElZFAjNhcxinJ4NzPvBaO+PyelqB8rdpGZ7QP1X5xn9SDDrEYRzPISYw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: 3.58 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 9DE21221DF X-Spam-Score: 3.58 X-Migadu-Scanner: scn0.migadu.com X-TUID: 9QHilUfJwNeO * guix/utils.scm (edit-expression): Check whether STR* equals STR. --- guix/utils.scm | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/guix/utils.scm b/guix/utils.scm index f8f6672bb1..e6d0761679 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -423,17 +423,19 @@ This procedure returns #t on success." (port-encoding in))) (post-bv (get-bytevector-all in)) (str* (proc str))) - ;; Verify the edited expression is still a scheme expression. - (call-with-input-string str* read) - ;; Update the file with edited expression. - (with-atomic-file-output file - (lambda (out) - (put-bytevector out pre-bv) - (display str* out) - ;; post-bv maybe the end-of-file object. - (when (not (eof-object? post-bv)) - (put-bytevector out post-bv)) - #t)))))))) + ;; Modify FILE only if there are changes. + (unless (string=? str* str) + ;; Verify the edited expression is still a scheme expression. + (call-with-input-string str* read) + ;; Update the file with edited expression. + (with-atomic-file-output file + (lambda (out) + (put-bytevector out pre-bv) + (display str* out) + ;; post-bv maybe the end-of-file object. + (when (not (eof-object? post-bv)) + (put-bytevector out post-bv)) + #t))))))))) ;;; -- 2.32.0