comparison mercurial/streamclone.py @ 30975:22fbca1d11ed

mercurial: switch to util.timer for all interval timings util.timer is now the best available interval timer, at the expense of not having a known epoch. Let's use it whenever the epoch is irrelevant.
author Simon Farnsworth <simonfar@fb.com>
date Wed, 15 Feb 2017 13:17:39 -0800
parents 318a24b52eeb
children 076f1ff43f0f
comparison
equal deleted inserted replaced
30974:ae5d60bb70c9 30975:22fbca1d11ed
6 # GNU General Public License version 2 or any later version. 6 # GNU General Public License version 2 or any later version.
7 7
8 from __future__ import absolute_import 8 from __future__ import absolute_import
9 9
10 import struct 10 import struct
11 import time
12 11
13 from .i18n import _ 12 from .i18n import _
14 from . import ( 13 from . import (
15 branchmap, 14 branchmap,
16 error, 15 error,
295 with repo.lock(): 294 with repo.lock():
296 repo.ui.status(_('%d files to transfer, %s of data\n') % 295 repo.ui.status(_('%d files to transfer, %s of data\n') %
297 (filecount, util.bytecount(bytecount))) 296 (filecount, util.bytecount(bytecount)))
298 handled_bytes = 0 297 handled_bytes = 0
299 repo.ui.progress(_('clone'), 0, total=bytecount, unit=_('bytes')) 298 repo.ui.progress(_('clone'), 0, total=bytecount, unit=_('bytes'))
300 start = time.time() 299 start = util.timer()
301 300
302 # TODO: get rid of (potential) inconsistency 301 # TODO: get rid of (potential) inconsistency
303 # 302 #
304 # If transaction is started and any @filecache property is 303 # If transaction is started and any @filecache property is
305 # changed at this point, it causes inconsistency between 304 # changed at this point, it causes inconsistency between
338 337
339 # force @filecache properties to be reloaded from 338 # force @filecache properties to be reloaded from
340 # streamclone-ed file at next access 339 # streamclone-ed file at next access
341 repo.invalidate(clearfilecache=True) 340 repo.invalidate(clearfilecache=True)
342 341
343 elapsed = time.time() - start 342 elapsed = util.timer() - start
344 if elapsed <= 0: 343 if elapsed <= 0:
345 elapsed = 0.001 344 elapsed = 0.001
346 repo.ui.progress(_('clone'), None) 345 repo.ui.progress(_('clone'), None)
347 repo.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') % 346 repo.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') %
348 (util.bytecount(bytecount), elapsed, 347 (util.bytecount(bytecount), elapsed,