# HG changeset patch # User Matt Harbison # Date 2023-08-20 20:20:56 # Node ID bbaac3a222bbaafc7f9f3f2fb7e7a50342ed2fd6 # Parent b3ac579bde411f783e9897580e595767ea78fb6f gpg: use a context manager to write `.hgsigs` diff --git a/hgext/gpg.py b/hgext/gpg.py --- a/hgext/gpg.py +++ b/hgext/gpg.py @@ -348,9 +348,8 @@ def _dosign(ui, repo, *revs, **opts): 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):