[PATCH 6 of 7] lfs: convert EOL of hgrc before appending to bytes IO

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


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1515818471 -32400
#      Sat Jan 13 13:41:11 2018 +0900
# Node ID 2a43867d18bbbbdfedd0708a6dfb87ab2fc80e5c
# Parent  6f68aa0c4c0aa59dd651e81e813c1a11e4761889
lfs: convert EOL of hgrc before appending to bytes IO

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

diff --git a/hgext/lfs/wrapper.py b/hgext/lfs/wrapper.py
--- a/hgext/lfs/wrapper.py
+++ b/hgext/lfs/wrapper.py
@@ -197,8 +197,8 @@ def convertsink(orig, sink):
                         self.repo._writerequirements()
 
                         # Permanently enable lfs locally
-                        with self.repo.vfs('hgrc', 'a', text=True) as fp:
-                            fp.write('\n[extensions]\nlfs=\n')
+                        self.repo.vfs.append(
+                            'hgrc', util.tonativeeol('\n[extensions]\nlfs=\n'))
 
                 return node
 
@@ -232,8 +232,8 @@ def hgclone(orig, ui, opts, *args, **kwa
 
         # If lfs is required for this repo, permanently enable it locally
         if 'lfs' in repo.requirements:
-            with repo.vfs('hgrc', 'a', text=True) as fp:
-                fp.write('\n[extensions]\nlfs=\n')
+            repo.vfs.append('hgrc',
+                            util.tonativeeol('\n[extensions]\nlfs=\n'))
 
     return result
 
@@ -242,8 +242,7 @@ def hgpostshare(orig, sourcerepo, destre
 
     # If lfs is required for this repo, permanently enable it locally
     if 'lfs' in destrepo.requirements:
-        with destrepo.vfs('hgrc', 'a', text=True) as fp:
-            fp.write('\n[extensions]\nlfs=\n')
+        destrepo.vfs.append('hgrc', util.tonativeeol('\n[extensions]\nlfs=\n'))
 
 def _canskipupload(repo):
     # if remotestore is a null store, upload is a no-op and can be skipped


More information about the Mercurial-devel mailing list