config: use the writefile() utility to create the sample hgrc
This function uses a context manager.
--- 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(