[PATCH] run-tests: alias hg to hg.exe in scripts for MSYS if hg.exe exists in BINDIR

Adrian Buehlmann adrian at cadifra.com
Sat Jun 30 17:43:37 CDT 2012


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1341094232 -7200
# Node ID d0dd825abca9f626e54acede8993b4508f8a4743
# Parent  5f2cacb715dcf6dd2676088d5218f014e1a5d2a9
run-tests: alias hg to hg.exe in scripts for MSYS if hg.exe exists in BINDIR

If sh.exe encounters a hg call in a testscript, it looks if there is a file
with that exact name. If it's there, it reads the hg file, sees the hashbang,
calls env.exe, which in turn calls python with the hg script (as instructed by
the hashbang).

So that's exactly also what's happening on non-windows platforms (e.g. Linux) as
well. Which is good in the sense that we are close to the "model platform".

sh.exe doesn't care if there is a hg.exe next to the hg file in the same dir.

But this is needlessly slow, if we *do* happen to have a hg.exe. If we do have
a hg.exe, we can spare us the env.exe call for the hg calls in the script by
aliasing hg to hg.exe. This will affect the vast majority of the hg calls in
the testscript.

Note that the alias is only in effect for calls in the top level script itself.
Other hg calls, like, for example, in temporary scripts assembled by the test,
are not affected. But that's not a problem. These will just continue to work via
env.exe and the hashbang.

So this is basically just a speed improvement - nothing else.

As a side effect, the hg.exe is used a bit more, so it's perhaps a little bit
better tested.

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -617,6 +617,8 @@
         script.append('set -x\n')
     if os.getenv('MSYSTEM'):
         script.append('alias pwd="pwd -W"\n')
+        if os.path.exists(os.path.join(BINDIR, 'hg.exe')):
+            script.append('alias hg=hg.exe\n')
     for n, l in enumerate(t):
         if not l.endswith('\n'):
             l += '\n'


More information about the Mercurial-devel mailing list