# HG changeset patch # User Matt Harbison # Date 1692508346 14400 # Node ID de3191c0cec908e3a55ad8882fde1cb993e4b1a6 # Parent 7d54b877782eb2f0feda808defd7349f68116626 config: use the writefile() utility to create the sample hgrc This function uses a context manager. diff -r 7d54b877782e -r de3191c0cec9 mercurial/commands.py --- a/mercurial/commands.py Sun Aug 20 01:08:58 2023 -0400 +++ b/mercurial/commands.py Sun Aug 20 01:12:26 2023 -0400 @@ -18,7 +18,6 @@ short, wdirrev, ) -from .pycompat import open from . import ( archival, bookmarks, @@ -2354,9 +2353,7 @@ samplehgrc = uimod.samplehgrcs[b'user'] f = paths[0] - fp = open(f, b"wb") - fp.write(util.tonativeeol(samplehgrc)) - fp.close() + util.writefile(f, util.tonativeeol(samplehgrc)) editor = ui.geteditor() ui.system(