changeset 44018:f9d29e1d3354

util: avoid referencing `time.clock()` on Windows when missing (issue6238) It's been removed in 3.8, and issues a deprecation warning since 3.3. Differential Revision: https://phab.mercurial-scm.org/D7780
author Matt Harbison <matt_harbison@yahoo.com>
date Tue, 31 Dec 2019 16:24:38 -0500
parents 6b90f5c89cb4
children 5bbd770d1324
files mercurial/util.py
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/util.py	Mon Dec 30 23:53:53 2019 -0500
+++ b/mercurial/util.py	Tue Dec 31 16:24:38 2019 -0500
@@ -2057,16 +2057,17 @@
             )
 
 
+timer = getattr(time, "perf_counter", None)
+
 if pycompat.iswindows:
     checkosfilename = checkwinfilename
-    timer = time.clock
+    if not timer:
+        timer = time.clock
 else:
     # mercurial.windows doesn't have platform.checkosfilename
     checkosfilename = platform.checkosfilename  # pytype: disable=module-attr
-    timer = time.time
-
-if safehasattr(time, "perf_counter"):
-    timer = time.perf_counter
+    if not timer:
+        timer = time.time
 
 
 def makelock(info, pathname):