# HG changeset patch # User Matt Harbison # Date 2019-12-31 21:24:38 # Node ID f9d29e1d3354e595a70f01faf3d5cba7373c5ef0 # Parent 6b90f5c89cb478b0d628c59a55f0cc2a28eedb79 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 diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -2057,16 +2057,17 @@ def checkwinfilename(path): ) +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):