[PATCH] tests: adjust hook creation for ksh89

Mads Kiilerich mads at kiilerich.com
Mon Sep 3 08:21:40 CDT 2012


On 09/03/2012 02:01 PM, Jim Hague wrote:
> # HG changeset patch
> # User Jim Hague <jim.hague at acm.org>
> # Date 1346673606 -3600
> # Branch stable
> # Node ID 0c6d35fad1d26320ab57fac9cc6a67ff8eb6d0b0
> # Parent  3ee5d3c372fabcf57c305835dac98da78bdc1837
> tests: adjust hook creation for ksh89.
>
> In ksh89, default shell on AIX, here documents mess with quoting.
>
> $ cat << EOF
>> sh -c "echo \"Quote\"; ls"
>> EOF
> sh -c "echo "Quote"; ls"

Escapes are processed for "here" documents, so this ksh behaviour is not 
completely wrong. It just handles the invalid ' \" ' differently than 
some other shells.

> Work around this and get test-commit-amend.t and test-largefiles.t working.
>
> diff -r 3ee5d3c372fa -r 0c6d35fad1d2 tests/test-commit-amend.t
> --- a/tests/test-commit-amend.t	Sat Sep 01 12:49:43 2012 -0500
> +++ b/tests/test-commit-amend.t	Mon Sep 03 13:00:06 2012 +0100
> @@ -25,7 +25,7 @@
>   
>     $ cat >> $HGRCPATH <<EOF
>     > [hooks]
> -  > pretxncommit.foo = sh -c "echo \"pretxncommit \$HG_NODE\"; hg id -r \$HG_NODE"
> +  > pretxncommit.foo = sh -c 'echo "pretxncommit \$HG_NODE"; hg id -r \$HG_NODE'
>     > EOF

This will probably fail on windows. The command line will be executed by 
cmd.exe, and ' is not handled correctly in that environment.

I think it would be better to use
   ...
   pretxncommit.foo = sh -c "echo \\"pretxncommit \\$HG_NODE\\"; hg id 
-r \\$HG_NODE"
   ...

Does that work for  you?

/Mads

>   Amending changeset with changes in working dir:
> diff -r 3ee5d3c372fa -r 0c6d35fad1d2 tests/test-largefiles.t
> --- a/tests/test-largefiles.t	Sat Sep 01 12:49:43 2012 -0500
> +++ b/tests/test-largefiles.t	Mon Sep 03 13:00:06 2012 +0100
> @@ -13,7 +13,7 @@
>     > patterns=glob:**.dat
>     > usercache=${USERCACHE}
>     > [hooks]
> -  > precommit=sh -c "echo \"Invoking status precommit hook\"; hg status"
> +  > precommit=sh -c 'echo "Invoking status precommit hook"; hg status'
>     > EOF
>   
>   Create the repo with a couple of revisions of both large and normal
> @@ -434,7 +434,7 @@
>     $ cd ../addrm
>     $ cat >> .hg/hgrc <<EOF
>     > [hooks]
> -  > post-commit.stat=sh -c "echo \"Invoking status postcommit hook\"; hg status -A"
> +  > post-commit.stat=sh -c 'echo "Invoking status postcommit hook"; hg status -A'
>     > EOF
>     $ touch foo
>     $ hg add --large foo
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel



More information about the Mercurial-devel mailing list