changeset 30588:be0e7af80543

perf: add historical support of ui.load() ui.load() has been available since d83ca854 and at the time of writing isn't available on stable branch breaking benchmarking newer stable revisions. Add historical portability policy note on contrib/benchmarks
author Philippe Pepiot <philippe.pepiot@logilab.fr>
date Thu, 15 Dec 2016 12:17:08 +0100
parents b3643bfc7fcb
children 182cacaa4c32
files contrib/benchmarks/__init__.py
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/benchmarks/__init__.py	Wed Dec 14 02:17:59 2016 +0000
+++ b/contrib/benchmarks/__init__.py	Thu Dec 15 12:17:08 2016 +0100
@@ -5,6 +5,11 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
+# "historical portability" policy of contrib/benchmarks:
+#
+# We have to make this code work correctly with current mercurial stable branch
+# and if possible with reasonable cost with early Mercurial versions.
+
 '''ASV (https://asv.readthedocs.io) benchmark suite
 
 Benchmark are parameterized against reference repositories found in the
@@ -36,6 +41,7 @@
     extensions,
     hg,
     ui as uimod,
+    util,
 )
 
 basedir = os.path.abspath(os.path.join(os.path.dirname(__file__),
@@ -50,7 +56,12 @@
 
 def runperfcommand(reponame, command, *args, **kwargs):
     os.environ["HGRCPATH"] = os.environ.get("ASVHGRCPATH", "")
-    ui = uimod.ui.load()
+    # for "historical portability"
+    # ui.load() has been available since d83ca85
+    if util.safehasattr(uimod.ui, "load"):
+        ui = uimod.ui.load()
+    else:
+        ui = uimod.ui()
     repo = hg.repository(ui, os.path.join(reposdir, reponame))
     perfext = extensions.load(ui, 'perfext',
                               os.path.join(basedir, 'contrib', 'perf.py'))