[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
09/17: utils: 'edit-expression' modifies the file only if necessary.
From: |
guix-commits |
Subject: |
09/17: utils: 'edit-expression' modifies the file only if necessary. |
Date: |
Sat, 10 Jul 2021 19:07:11 -0400 (EDT) |
civodul pushed a commit to branch core-updates
in repository guix.
commit f05433f2083d467bdf0aafe18dd57bf35f0a7343
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Mon Jun 21 13:56:59 2021 +0200
utils: 'edit-expression' modifies the file only if necessary.
* 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 f8f6672..e6d0761 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)))))))))
;;;
- branch core-updates updated (2a3cd4e -> 9b4c3c6), guix-commits, 2021/07/10
- 01/17: records: Support field sanitizers., guix-commits, 2021/07/10
- 08/17: utils: Add 'go-to-location' with source location caching., guix-commits, 2021/07/10
- 06/17: gnu: Change inputs of core packages to plain lists., guix-commits, 2021/07/10
- 07/17: utils: 'edit-expression' no longer leaks file ports., guix-commits, 2021/07/10
- 14/17: import: cran: Emit new-style package inputs., guix-commits, 2021/07/10
- 13/17: import: pypi: Emit new-style package inputs., guix-commits, 2021/07/10
- 10/17: utils: 'edit-expression' copies part of the original source map., guix-commits, 2021/07/10
- 09/17: utils: 'edit-expression' modifies the file only if necessary.,
guix-commits <=
- 16/17: import: elpa: Emit new-style package inputs., guix-commits, 2021/07/10
- 17/17: news: Add news entry for simplified package inputs., guix-commits, 2021/07/10
- 04/17: packages: Add 'lookup-package-input' & co., guix-commits, 2021/07/10
- 02/17: packages: Allow inputs to be plain package lists., guix-commits, 2021/07/10
- 03/17: lint: Add 'input-labels' checker., guix-commits, 2021/07/10
- 11/17: Add 'guix style'., guix-commits, 2021/07/10
- 05/17: packages: Add 'modify-inputs'., guix-commits, 2021/07/10
- 12/17: packages: 'hidden-package' inherits the original package location., guix-commits, 2021/07/10
- 15/17: import: print: Emit new-style package inputs when possible., guix-commits, 2021/07/10