revsetbenchmark: automatically finds the perf extension
authorPierre-Yves David <pierre-yves.david@fb.com>
Tue, 29 Apr 2014 13:18:22 -0700
changeset 21548 651d7548a744
parent 21546 cb0e28d61905
child 21549 ea3d75ebea6d
revsetbenchmark: automatically finds the perf extension Before this changeset, you had to stand in the root of the mercurial repo to run the `revsetbenchmark.py` script. Otherwise, the perf extension would not be found a `./contrib/perf.py` and the script would crash in panic. 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)
contrib/revsetbenchmarks.py
--- a/contrib/revsetbenchmarks.py	Mon May 19 14:39:19 2014 -0700
+++ b/contrib/revsetbenchmarks.py	Tue Apr 29 13:18:22 2014 -0700
@@ -14,6 +14,7 @@
 # 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
@@ -42,7 +43,8 @@
     try:
         output = check_output(['./hg',
                                '--config',
-                               'extensions.perf=contrib/perf.py',
+                               'extensions.perf='
+                               + os.path.join(contribdir, 'perf.py'),
                                'perfrevset',
                                revset],
                                stderr=STDOUT)
@@ -79,6 +81,8 @@
     parser.print_help()
     sys.exit(255)
 
+# the directory where both this script and the perf.py extension live.
+contribdir = os.path.dirname(__file__)
 
 target_rev = args[0]