config: use the writefile() utility to create the sample hgrc
authorMatt Harbison <matt_harbison@yahoo.com>
Sun, 20 Aug 2023 01:12:26 -0400
changeset 50833 de3191c0cec9
parent 50832 7d54b877782e
child 50834 57ae6063c494
config: use the writefile() utility to create the sample hgrc This function uses a context manager.
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(