comparison hgext/lfs/wrapper.py @ 35624:188b1371d1ed

lfs: convert EOL of hgrc before appending to bytes IO Text IO is useless on Python 3 as it must be a unicode stream.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 13 Jan 2018 13:41:11 +0900
parents c780e0649e41
children 588d02d9208a
comparison
equal deleted inserted replaced
35623:f56f8abbeaf1 35624:188b1371d1ed
195 if any(f in ctx and ctx[f].islfs() for f, n in files): 195 if any(f in ctx and ctx[f].islfs() for f, n in files):
196 self.repo.requirements.add('lfs') 196 self.repo.requirements.add('lfs')
197 self.repo._writerequirements() 197 self.repo._writerequirements()
198 198
199 # Permanently enable lfs locally 199 # Permanently enable lfs locally
200 with self.repo.vfs('hgrc', 'a', text=True) as fp: 200 self.repo.vfs.append(
201 fp.write('\n[extensions]\nlfs=\n') 201 'hgrc', util.tonativeeol('\n[extensions]\nlfs=\n'))
202 202
203 return node 203 return node
204 204
205 sink.__class__ = lfssink 205 sink.__class__ = lfssink
206 206
230 if not repo: 230 if not repo:
231 return result 231 return result
232 232
233 # If lfs is required for this repo, permanently enable it locally 233 # If lfs is required for this repo, permanently enable it locally
234 if 'lfs' in repo.requirements: 234 if 'lfs' in repo.requirements:
235 with repo.vfs('hgrc', 'a', text=True) as fp: 235 repo.vfs.append('hgrc',
236 fp.write('\n[extensions]\nlfs=\n') 236 util.tonativeeol('\n[extensions]\nlfs=\n'))
237 237
238 return result 238 return result
239 239
240 def hgpostshare(orig, sourcerepo, destrepo, bookmarks=True, defaultpath=None): 240 def hgpostshare(orig, sourcerepo, destrepo, bookmarks=True, defaultpath=None):
241 orig(sourcerepo, destrepo, bookmarks, defaultpath) 241 orig(sourcerepo, destrepo, bookmarks, defaultpath)
242 242
243 # If lfs is required for this repo, permanently enable it locally 243 # If lfs is required for this repo, permanently enable it locally
244 if 'lfs' in destrepo.requirements: 244 if 'lfs' in destrepo.requirements:
245 with destrepo.vfs('hgrc', 'a', text=True) as fp: 245 destrepo.vfs.append('hgrc', util.tonativeeol('\n[extensions]\nlfs=\n'))
246 fp.write('\n[extensions]\nlfs=\n')
247 246
248 def _canskipupload(repo): 247 def _canskipupload(repo):
249 # if remotestore is a null store, upload is a no-op and can be skipped 248 # if remotestore is a null store, upload is a no-op and can be skipped
250 return isinstance(repo.svfs.lfsremoteblobstore, blobstore._nullremote) 249 return isinstance(repo.svfs.lfsremoteblobstore, blobstore._nullremote)
251 250