comparison mercurial/streamclone.py @ 27859:f55a5ace8e69

with: use context manager in streamclone consumev1
author Bryan O'Sullivan <bryano@fb.com>
date Fri, 15 Jan 2016 13:14:49 -0800
parents 49cfddbf54ba
children ed9950ba091e
comparison
equal deleted inserted replaced
27858:7575c048482d 27859:f55a5ace8e69
288 repository. 288 repository.
289 289
290 Like "streamout," the status line added by the wire protocol is not handled 290 Like "streamout," the status line added by the wire protocol is not handled
291 by this function. 291 by this function.
292 """ 292 """
293 lock = repo.lock() 293 with repo.lock():
294 try:
295 repo.ui.status(_('%d files to transfer, %s of data\n') % 294 repo.ui.status(_('%d files to transfer, %s of data\n') %
296 (filecount, util.bytecount(bytecount))) 295 (filecount, util.bytecount(bytecount)))
297 handled_bytes = 0 296 handled_bytes = 0
298 repo.ui.progress(_('clone'), 0, total=bytecount) 297 repo.ui.progress(_('clone'), 0, total=bytecount)
299 start = time.time() 298 start = time.time()
331 elapsed = 0.001 330 elapsed = 0.001
332 repo.ui.progress(_('clone'), None) 331 repo.ui.progress(_('clone'), None)
333 repo.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') % 332 repo.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') %
334 (util.bytecount(bytecount), elapsed, 333 (util.bytecount(bytecount), elapsed,
335 util.bytecount(bytecount / elapsed))) 334 util.bytecount(bytecount / elapsed)))
336 finally:
337 lock.release()
338 335
339 def applybundlev1(repo, fp): 336 def applybundlev1(repo, fp):
340 """Apply the content from a stream clone bundle version 1. 337 """Apply the content from a stream clone bundle version 1.
341 338
342 We assume the 4 byte header has been read and validated and the file handle 339 We assume the 4 byte header has been read and validated and the file handle