Patchwork [5,of,7] largefiles: convert EOL of hgrc before appending to bytes IO

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

Comments

Yuya Nishihara - Jan. 13, 2018, 5:02 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1515818035 -32400
#      Sat Jan 13 13:33:55 2018 +0900
# Node ID 6f68aa0c4c0aa59dd651e81e813c1a11e4761889
# Parent  c4ecde5fbf1e40f0c918c9b4f6c1215b2cbebb7c
largefiles: convert EOL of hgrc before appending to bytes IO

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

Patch

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -888,8 +888,8 @@  def hgclone(orig, ui, opts, *args, **kwa
 
         # If largefiles is required for this repo, permanently enable it locally
         if 'largefiles' in repo.requirements:
-            with repo.vfs('hgrc', 'a', text=True) as fp:
-                fp.write('\n[extensions]\nlargefiles=\n')
+            repo.vfs.append('hgrc',
+                            util.tonativeeol('\n[extensions]\nlargefiles=\n'))
 
         # Caching is implicitly limited to 'rev' option, since the dest repo was
         # truncated at that point.  The user may expect a download count with
@@ -907,8 +907,8 @@  def hgpostshare(orig, sourcerepo, destre
 
     # If largefiles is required for this repo, permanently enable it locally
     if 'largefiles' in destrepo.requirements:
-        with destrepo.vfs('hgrc', 'a+', text=True) as fp:
-            fp.write('\n[extensions]\nlargefiles=\n')
+        destrepo.vfs.append('hgrc',
+                            util.tonativeeol('\n[extensions]\nlargefiles=\n'))
 
 def overriderebase(orig, ui, repo, **opts):
     if not util.safehasattr(repo, '_largefilesenabled'):