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

Yuya Nishihara yuya at tcha.org
Sat Jan 13 00:02:54 EST 2018


# HG changeset patch
# User Yuya Nishihara <yuya at 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.

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):


More information about the Mercurial-devel mailing list