[PATCH] test-hook: use sh when running hg in hooks

Mads Kiilerich mads at kiilerich.com
Sun Jun 17 23:47:34 UTC 2012


Adrian Buehlmann wrote, On 06/17/2012 09:49 AM:
> # HG changeset patch
> # User Adrian Buehlmann <adrian at cadifra.com>
> # Date 1339917294 -7200
> # Node ID a0f221f45f846aea982355840c614d6fced41edb
> # Parent  6df859e0a6cd261eb5dea82b4a6b4186a662a650
> test-hook: use sh when running hg in hooks
>
> This eliminates the requirement (for this test) to have a hg.exe (on $PATH) when
> running on Windows.

 From one point of view:
I think it would be fine to support testing in such an environment ... 
of course assuming the wiki had a description of how to make such a 
setup ... and why.

 From another point of view (which might be the same):
Is it really relevant to test Mercurial in an environment where you 
can't run 'hg' in a native shell? One thing is to rely on msys for 
executing the test scripts, but is it relevant to rely on msys bash for 
launching Mercurial with the right Python? How realistic is a Windows 
Mercurial setup where you don't have a hg.exe (from exemaker or py2exe)?

/Mads

> diff --git a/tests/test-hook.t b/tests/test-hook.t
> --- a/tests/test-hook.t
> +++ b/tests/test-hook.t
> @@ -8,7 +8,7 @@
>     > commit.b = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" commit.b"
>     > precommit = sh -c  "HG_LOCAL= HG_NODE= HG_TAG= python \"$TESTDIR/printenv.py\" precommit"
>     > pretxncommit = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" pretxncommit"
> -  > pretxncommit.tip = hg -q tip
> +  > pretxncommit.tip = sh -c "hg -q tip"
>     > pre-identify = python "$TESTDIR/printenv.py" pre-identify 1
>     > pre-cat = python "$TESTDIR/printenv.py" pre-cat
>     > post-cat = python "$TESTDIR/printenv.py" post-cat
> @@ -129,7 +129,7 @@
>   pretxncommit hook can see changeset, can roll back txn, changeset no
>   more there after
>   
> -  $ echo "pretxncommit.forbid0 = hg tip -q" >> .hg/hgrc
> +  $ echo "pretxncommit.forbid0 = sh -c 'hg tip -q'" >> .hg/hgrc
>     $ echo "pretxncommit.forbid1 = python \"$TESTDIR/printenv.py\" pretxncommit.forbid 1" >> .hg/hgrc
>     $ echo z > z
>     $ hg add z
> @@ -254,7 +254,7 @@
>   
>     $ cat > .hg/hgrc <<EOF
>     > [hooks]
> -  > pretxnchangegroup.forbid0 = hg tip -q
> +  > pretxnchangegroup.forbid0 = sh -c "hg tip -q"
>     > pretxnchangegroup.forbid1 = python "$TESTDIR/printenv.py" pretxnchangegroup.forbid 1
>     > EOF
>     $ hg pull ../a
> @@ -555,9 +555,11 @@
>   
>   commit and update hooks should run after command completion
>   
> -  $ echo '[hooks]' > .hg/hgrc
> -  $ echo 'commit = hg id' >> .hg/hgrc
> -  $ echo 'update = hg id' >> .hg/hgrc
> +  $ cat > .hg/hgrc <<EOF
> +  > [hooks]
> +  > commit = sh -c "hg id"
> +  > update = sh -c "hg id"
> +  > EOF
>     $ echo bb > a
>     $ hg ci -ma
>     223eafe2750c tip
> @@ -603,8 +605,10 @@
>   
>     $ cd ..
>     $ hg init to
> -  $ echo '[hooks]' >> to/.hg/hgrc
> -  $ echo 'pretxnchangegroup = hg --traceback tip' >> to/.hg/hgrc
> +  $ cat >> to/.hg/hgrc <<EOF
> +  > [hooks]
> +  > pretxnchangegroup = sh -c "hg --traceback tip"
> +  > EOF
>     $ echo a >> to/a
>     $ hg --cwd to ci -Ama
>     adding a
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel





More information about the Mercurial-devel mailing list