Patchwork D8092: hghave: cache the result of gethgversion

login
register
mail settings
Submitter phabricator
Date Feb. 7, 2020, 9:37 p.m.
Message ID <ae5d3ec1d69e0b87c03a401078bea7d3@localhost.localdomain>
Download mbox | patch
Permalink /patch/45033/
State Not Applicable
Headers show

Comments

phabricator - Feb. 7, 2020, 9:37 p.m.
Closed by commit rHG8607dc2aa686: hghave: cache the result of gethgversion (authored by jcristau).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8092?vs=19985&id=19998

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

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

AFFECTED FILES
  tests/hghave.py

CHANGE DETAILS




To: jcristau, #hg-reviewers, marmoute, pulkit
Cc: pulkit, marmoute, mercurial-devel

Patch

diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -307,13 +307,21 @@ 
         return False
 
 
-def gethgversion():
+def _gethgversion():
     m = matchoutput('hg --version --quiet 2>&1', br'(\d+)\.(\d+)')
     if not m:
         return (0, 0)
     return (int(m.group(1)), int(m.group(2)))
 
 
+_hgversion = None
+def gethgversion():
+    global _hgversion
+    if _hgversion is None:
+        _hgversion = _gethgversion()
+    return _hgversion
+
+
 @checkvers(
     "hg", "Mercurial >= %s", list([(1.0 * x) / 10 for x in range(9, 99)])
 )