Patchwork [3,of,7] subrepo: convert EOL of hgrc before writing to bytes IO

login
register
mail settings
Submitter Yuya Nishihara
Date Jan. 13, 2018, 5:02 a.m.
Message ID <41f5fc043698f6c8ff04.1515819774@mimosa>
Download mbox | patch
Permalink /patch/26717/
State Accepted
Headers show

Comments

Yuya Nishihara - Jan. 13, 2018, 5:02 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1515817692 -32400
#      Sat Jan 13 13:28:12 2018 +0900
# Node ID 41f5fc043698f6c8ff042ebb7d380f76a68a006b
# Parent  f5558d75ef44a2db64131b4e5bca98102542f13b
subrepo: convert EOL of hgrc before writing to bytes IO

Follows up f2f0a777b2e2. Text IO is useless on Python 3 as it must be a
unicode stream.

Patch

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -841,11 +841,7 @@  class hgsubrepo(abstractsubrepo):
             if defpath != defpushpath:
                 addpathconfig('default-push', defpushpath)
 
-            fp = self._repo.vfs("hgrc", "wb", text=True)
-            try:
-                fp.write(''.join(lines))
-            finally:
-                fp.close()
+            self._repo.vfs.write('hgrc', util.tonativeeol(''.join(lines)))
 
     @annotatesubrepoerror
     def add(self, ui, match, prefix, explicitonly, **opts):