changeset 50833:de3191c0cec9

config: use the writefile() utility to create the sample hgrc This function uses a context manager.
author Matt Harbison <matt_harbison@yahoo.com>
date Sun, 20 Aug 2023 01:12:26 -0400
parents 7d54b877782e
children 57ae6063c494
files mercurial/commands.py
diffstat 1 files changed, 1 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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(