# HG changeset patch # User Pierre-Yves David # Date 1513037444 -3600 # Node ID 4a9718a83602bcf7466d0758f5c39d6c025dd1ce # Parent 26b604d7e1a8026f931e6dc8e214d1aff34a69ef genericcaches: handle the lack of util.timer in 4.1 We do the same trick as usual. diff -r 26b604d7e1a8 -r 4a9718a83602 hgext3rd/evolve/genericcaches.py --- a/hgext3rd/evolve/genericcaches.py Mon Dec 11 15:49:22 2017 +0100 +++ b/hgext3rd/evolve/genericcaches.py Tue Dec 12 01:10:44 2017 +0100 @@ -8,12 +8,25 @@ import abc import struct +import time +import os from mercurial import ( node, + pycompat, util, ) +# prior to hg-4.2 there are not util.timer +if util.safehasattr(util, 'timer'): + timer = util.timer +elif util.safehasattr(time, "perf_counter"): + timer = time.perf_counter +elif getattr(pycompat, 'osname', os.name) == 'nt': + timer = time.clock +else: + timer = time.time + class incrementalcachebase(object): """base class for incremental cache from append only source @@ -116,9 +129,9 @@ % self._cachename) self.clear(reset=True) - starttime = util.timer() + starttime = timer() self._updatefrom(repo, data) - duration = util.timer() - starttime + duration = timer() - starttime summary = self._updatesummary(data) repo.ui.log('cache', 'updated %s in %.4f seconds (%s)\n', self._cachename, duration, summary)