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

login
register
mail settings
Submitter phabricator
Date Jan. 8, 2020, 7:50 p.m.
Message ID <a657ee1c1e767358eece44a07fe6734d@localhost.localdomain>
Download mbox | patch
Permalink /patch/44198/
State Not Applicable
Headers show

Comments

phabricator - Jan. 8, 2020, 7:50 p.m.
Closed by commit rHGf9d29e1d3354: util: avoid referencing `time.clock()` on Windows when missing (issue6238) (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7780?vs=19028&id=19092

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7780/new/

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):