comparison mercurial/util.py @ 44020: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 4222b9d5d4fb
children 6d3b67a837a6
comparison
equal deleted inserted replaced
44019:6b90f5c89cb4 44020:f9d29e1d3354
2055 ) 2055 )
2056 % t 2056 % t
2057 ) 2057 )
2058 2058
2059 2059
2060 timer = getattr(time, "perf_counter", None)
2061
2060 if pycompat.iswindows: 2062 if pycompat.iswindows:
2061 checkosfilename = checkwinfilename 2063 checkosfilename = checkwinfilename
2062 timer = time.clock 2064 if not timer:
2065 timer = time.clock
2063 else: 2066 else:
2064 # mercurial.windows doesn't have platform.checkosfilename 2067 # mercurial.windows doesn't have platform.checkosfilename
2065 checkosfilename = platform.checkosfilename # pytype: disable=module-attr 2068 checkosfilename = platform.checkosfilename # pytype: disable=module-attr
2066 timer = time.time 2069 if not timer:
2067 2070 timer = time.time
2068 if safehasattr(time, "perf_counter"):
2069 timer = time.perf_counter
2070 2071
2071 2072
2072 def makelock(info, pathname): 2073 def makelock(info, pathname):
2073 """Create a lock file atomically if possible 2074 """Create a lock file atomically if possible
2074 2075