Submitter | Pierre-Yves David |
---|---|
Date | May 13, 2014, 8:19 a.m. |
Message ID | <ecfe676f25f7c02f7eae.1399969156@marginatus.alto.octopoid.net> |
Download | mbox | patch |
Permalink | /patch/4734/ |
State | Superseded |
Headers | show |
Comments
On May 13, 2014, at 4:19 AM, pierre-yves.david@ens-lyon.org wrote: > # HG changeset patch > # User Pierre-Yves David <pierre-yves.david@fb.com> > # Date 1398802702 25200 > # Tue Apr 29 13:18:22 2014 -0700 > # Node ID ecfe676f25f7c02f7eae88496de1adebb258f822 > # Parent d8a52ce003ac21569dae2023ecc648e7769bdb54 > 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) > > 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]) Why can't this be os.path.dirname(__file__)? Then it would work even if you weren't in the repo, or at least I think that'd be the case. That seems to work for me here. > > target_rev = args[0] > > revsetsfile = sys.stdin > if options.file: > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@selenic.com > http://selenic.com/mailman/listinfo/mercurial-devel
Patch
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: