diff tests/test-doctest.py @ 6913:3c5966b42c21 mercurial-5.7

test-compat: merge mercurial-5.8 into mercurial-5.7
author Anton Shestakov <av6@dwimlabs.net>
date Fri, 25 Oct 2024 16:31:50 +0400
parents 16fd24f6cf22
children
line wrap: on
line diff
--- a/tests/test-doctest.py	Wed Jun 26 16:24:32 2024 +0400
+++ b/tests/test-doctest.py	Fri Oct 25 16:31:50 2024 +0400
@@ -67,11 +67,15 @@
 if not os.path.isdir(os.path.join(cwd, ".hg")):
     sys.exit(0)
 
-files = subprocess.check_output(
-    "hg files --print0 \"%s\"" % fileset,
-    shell=True,
-    cwd=cwd,
-).split(b'\0')
+files_cmd = 'hg files --print0 "%s"' % fileset
+
+# we prefer system hg for reading the repository, unless we're on python2
+# because then we assume that system hg is too old (this is not always true,
+# but it's an easy check and works well enough for us)
+if ispy3 and 'HGTEST_RESTOREENV':
+    files_cmd = '. $HGTEST_RESTOREENV; ' + files_cmd
+
+files = subprocess.check_output(files_cmd, shell=True, cwd=cwd).split(b'\0')
 
 if sys.version_info[0] >= 3:
     cwd = os.fsencode(cwd)