Patchwork D7780: util: avoid referencing `time.clock()` on Windows when missing (issue6238)

login
register
mail settings
Submitter phabricator
Date Dec. 31, 2019, 9:58 p.m.
Message ID <differential-rev-PHID-DREV-3uscqznkkmyiwecxdcks-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/44139/
State Superseded
Headers show

Comments

phabricator - Dec. 31, 2019, 9:58 p.m.
mharbison72 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  It's been removed in 3.8, and issues a deprecation warning since 3.3.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D7780

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS




To: mharbison72, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -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):