[PATCH 7 of 8] revsetbenchmark: automatically finds the perf extension

pierre-yves.david at ens-lyon.org pierre-yves.david at ens-lyon.org
Thu May 1 20:45:28 CDT 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1398802702 25200
#      Tue Apr 29 13:18:22 2014 -0700
# Node ID cf39f49b464e8d1b28cc934ef43c3f305d1fd2be
# Parent  5aa9fb32c6eb67357a7bdada00d1d7b0725bbf47
revsetbenchmark: automatically finds the perf extension

We now figure out the contrib directory from the location of this script. This
makes it possible to run the script from other location that the mercurial repo
root (but you still need to be in the core mercurial repository)

diff --git a/contrib/revsetbenchmarks.py b/contrib/revsetbenchmarks.py
--- a/contrib/revsetbenchmarks.py
+++ b/contrib/revsetbenchmarks.py
@@ -12,10 +12,11 @@
 #
 # This script also does one run of the current version of mercurial installed
 # to compare performance.
 
 import sys
+import os
 from subprocess import check_call, Popen, CalledProcessError, STDOUT, PIPE
 # cannot use argparse, python 2.7 only
 from optparse import OptionParser
 
 
@@ -40,11 +41,12 @@ def update(rev):
 def perf(revset):
     """run benchmark for this very revset"""
     try:
         output = check_output(['./hg',
                                '--config',
-                               'extensions.perf=contrib/perf.py',
+                               'extensions.perf='
+                               + os.path.join(contribdir, 'perf.py'),
                                'perfrevset',
                                revset],
                                stderr=STDOUT)
         output = output.lstrip('!') # remove useless ! in this context
         return output.strip()
@@ -77,10 +79,11 @@ parser.add_option("-f", "--file",
 
 if len(sys.argv) < 2:
     parser.print_help()
     sys.exit(255)
 
+contribdir = os.path.dirname(sys.argv[0])
 
 target_rev = args[0]
 
 revsetsfile = sys.stdin
 if options.file:


More information about the Mercurial-devel mailing list