timer: drop compat layer for time
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 19 Apr 2018 13:35:31 +0200
changeset 3685 bf000d1a525f
parent 3684 2a62f0f480f3
child 3686 36714eeb51d1
timer: drop compat layer for time Support for 4.1 and 4.2 has been dropped.
hgext3rd/evolve/genericcaches.py
hgext3rd/evolve/obscache.py
hgext3rd/evolve/obsdiscovery.py
hgext3rd/evolve/stablerange.py
--- a/hgext3rd/evolve/genericcaches.py	Thu Apr 19 11:38:13 2018 +0200
+++ b/hgext3rd/evolve/genericcaches.py	Thu Apr 19 13:35:31 2018 +0200
@@ -8,25 +8,12 @@
 
 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
 
@@ -129,9 +116,9 @@
                         % self._cachename)
             self.clear(reset=True)
 
-        starttime = timer()
+        starttime = util.timer()
         self._updatefrom(repo, data)
-        duration = timer() - starttime
+        duration = util.timer() - starttime
         summary = self._updatesummary(data)
         repo.ui.log('cache', 'updated %s in %.4f seconds (%s)\n',
                     self._cachename, duration, summary)
--- a/hgext3rd/evolve/obscache.py	Thu Apr 19 11:38:13 2018 +0200
+++ b/hgext3rd/evolve/obscache.py	Thu Apr 19 13:35:31 2018 +0200
@@ -9,9 +9,7 @@
 
 import errno
 import hashlib
-import os
 import struct
-import time
 import weakref
 
 from mercurial import (
@@ -19,7 +17,6 @@
     localrepo,
     obsolete,
     phases,
-    pycompat,
     node,
     util,
 )
@@ -33,17 +30,6 @@
 
 eh = exthelper.exthelper()
 
-# 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
-
-
 obsstorefilecache = localrepo.localrepository.obsstore
 
 # obsstore is a filecache so we have do to some spacial dancing
@@ -224,11 +210,11 @@
             repo.ui.log('evoext-cache', 'strip detected, %s cache reset\n' % self._cachename)
             self.clear(reset=True)
 
-        starttime = timer()
+        starttime = util.timer()
         revs = list(revs)
         obsmarkers = list(obsmarkers)
         self._updatefrom(repo, revs, obsmarkers)
-        duration = timer() - starttime
+        duration = util.timer() - starttime
         repo.ui.log('evoext-cache', 'updated %s in %.4f seconds (%sr, %so)\n',
                     self._cachename, duration, len(revs), len(obsmarkers))
 
--- a/hgext3rd/evolve/obsdiscovery.py	Thu Apr 19 11:38:13 2018 +0200
+++ b/hgext3rd/evolve/obsdiscovery.py	Thu Apr 19 13:35:31 2018 +0200
@@ -24,10 +24,8 @@
 
 import hashlib
 import heapq
-import os
 import sqlite3
 import struct
-import time
 import weakref
 
 from mercurial import (
@@ -38,7 +36,6 @@
     localrepo,
     node,
     obsolete,
-    pycompat,
     scmutil,
     setdiscovery,
     util,
@@ -63,16 +60,6 @@
     from mercurial.wireprotov1peer import wirepeer
     from mercurial.wireprototypes import encodelist, decodelist
 
-# 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
-
 _pack = struct.pack
 _unpack = struct.unpack
 _calcsize = struct.calcsize
@@ -154,7 +141,7 @@
                      initialsamplesize=100,
                      fullsamplesize=200):
     missing = set()
-    starttime = timer()
+    starttime = util.timer()
 
     heads = local.revs('heads(%ld)', probeset)
     local.stablerange.warmup(local)
@@ -244,7 +231,7 @@
                     unit=_("queries"))
     ui.progress(_("comparing obsmarker with other"), None)
     local.obsstore.rangeobshashcache.save(local)
-    duration = timer() - starttime
+    duration = util.timer() - starttime
     logmsg = ('obsdiscovery, %d/%d mismatch'
               ' - %d obshashrange queries in %.4f seconds\n')
     logmsg %= (len(missing), len(probeset), querycount, duration)
--- a/hgext3rd/evolve/stablerange.py	Thu Apr 19 11:38:13 2018 +0200
+++ b/hgext3rd/evolve/stablerange.py	Thu Apr 19 13:35:31 2018 +0200
@@ -11,13 +11,11 @@
 import functools
 import heapq
 import math
-import os
 import time
 
 from mercurial import (
     error,
     node as nodemod,
-    pycompat,
     scmutil,
     util,
 )
@@ -37,16 +35,6 @@
 eh.merge(stablesort.eh)
 eh.merge(firstmergecache.eh)
 
-# 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
-
 
 #################################
 ### Stable Range computation  ###
@@ -592,7 +580,7 @@
         #
         # we use the revnumber as an approximation for depth
         ui = repo.ui
-        starttime = timer()
+        starttime = util.timer()
 
         if upto is None:
             upto = len(cl) - 1
@@ -649,7 +637,7 @@
         self._tiprev = upto
         self._tipnode = cl.node(upto)
 
-        duration = timer() - starttime
+        duration = util.timer() - starttime
         repo.ui.log('evoext-cache', 'updated stablerange cache in %.4f seconds\n',
                     duration)