Skip to content
Snippets Groups Projects
Commit e48a996d authored by Julien Cristau's avatar Julien Cristau
Browse files

hghave: cache the result of gethgversion

hghave --test-features calls it 90 times, each one calling hg --version
which takes a tenth of a second on my workstation, adding up to about
10s win on test-hghave.t.

Fixes https://bugs.debian.org/939756

Differential Revision: https://phab.mercurial-scm.org/D8092
parent 3245cdea
No related branches found
No related tags found
1 merge request!21WIP: ramfs usage for test
......@@ -307,10 +307,10 @@
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)))
......@@ -311,9 +311,19 @@
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)])
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment