changeset 50878:bbaac3a222bb

gpg: use a context manager to write `.hgsigs`
author Matt Harbison <matt_harbison@yahoo.com>
date Sun, 20 Aug 2023 16:20:56 -0400
parents b3ac579bde41
children 7e6cd8472dc8
files hgext/gpg.py
diffstat 1 files changed, 2 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/gpg.py	Sun Aug 20 16:19:41 2023 -0400
+++ b/hgext/gpg.py	Sun Aug 20 16:20:56 2023 -0400
@@ -348,9 +348,8 @@
                 hint=_(b"please commit .hgsigs manually"),
             )
 
-    sigsfile = repo.wvfs(b".hgsigs", b"ab")
-    sigsfile.write(sigmessage)
-    sigsfile.close()
+    with repo.wvfs(b".hgsigs", b"ab") as sigsfile:
+        sigsfile.write(sigmessage)
 
     if b'.hgsigs' not in repo.dirstate:
         with repo.dirstate.changing_files(repo):