Patchwork perf: add historical support of ui.load()

login
register
mail settings
Submitter Philippe Pepiot
Date Dec. 15, 2016, 11:21 a.m.
Message ID <f4b496c8abf1af7b1ded.1481800869@sh71.tls.logilab.fr>
Download mbox | patch
Permalink /patch/17921/
State Accepted
Headers show

Comments

Philippe Pepiot - Dec. 15, 2016, 11:21 a.m.
# HG changeset patch
# User Philippe Pepiot <philippe.pepiot@logilab.fr>
# Date 1481800628 -3600
#      Thu Dec 15 12:17:08 2016 +0100
# Node ID f4b496c8abf1af7b1dedd83a09c0a30e94f61a59
# Parent  7c0c722d568dd7120634f8ed7044cabdb9493f43
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
Jun Wu - Dec. 15, 2016, 11:26 a.m.
Looks good to me.

Excerpts from Philippe Pepiot's message of 2016-12-15 12:21:09 +0100:
> # HG changeset patch
> # User Philippe Pepiot <philippe.pepiot@logilab.fr>
> # Date 1481800628 -3600
> #      Thu Dec 15 12:17:08 2016 +0100
> # Node ID f4b496c8abf1af7b1dedd83a09c0a30e94f61a59
> # Parent  7c0c722d568dd7120634f8ed7044cabdb9493f43
> 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
> 
> diff --git a/contrib/benchmarks/__init__.py b/contrib/benchmarks/__init__.py
> --- a/contrib/benchmarks/__init__.py
> +++ b/contrib/benchmarks/__init__.py
> @@ -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 @@ from mercurial import (
>      extensions,
>      hg,
>      ui as uimod,
> +    util,
>  )
>  
>  basedir = os.path.abspath(os.path.join(os.path.dirname(__file__),
> @@ -50,7 +56,12 @@ outputre = re.compile((r'! wall (\d+.\d+
>  
>  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'))
Yuya Nishihara - Dec. 15, 2016, 12:58 p.m.
On Thu, 15 Dec 2016 12:21:09 +0100, Philippe Pepiot wrote:
> # HG changeset patch
> # User Philippe Pepiot <philippe.pepiot@logilab.fr>
> # Date 1481800628 -3600
> #      Thu Dec 15 12:17:08 2016 +0100
> # Node ID f4b496c8abf1af7b1dedd83a09c0a30e94f61a59
> # Parent  7c0c722d568dd7120634f8ed7044cabdb9493f43
> perf: add historical support of ui.load()

Ah, thanks. Queued per Jun's review.

Patch

diff --git a/contrib/benchmarks/__init__.py b/contrib/benchmarks/__init__.py
--- a/contrib/benchmarks/__init__.py
+++ b/contrib/benchmarks/__init__.py
@@ -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 @@  from mercurial import (
     extensions,
     hg,
     ui as uimod,
+    util,
 )
 
 basedir = os.path.abspath(os.path.join(os.path.dirname(__file__),
@@ -50,7 +56,12 @@  outputre = re.compile((r'! wall (\d+.\d+
 
 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'))