view en/examples/hook.ws @ 165:06d18465df03

Make an example run more predictably.
author Bryan O'Sullivan <bos@serpentine.com>
date Mon, 26 Mar 2007 22:45:48 -0700
parents 8cf40d4d9377
children e67251ac336f
line wrap: on
line source

#!/bin/bash

hg init a
cd a
echo '[hooks]' > .hg/hgrc
echo "pretxncommit.whitespace = hg export tip | (! grep -qP '^\\+.*[ \\t]$')" >> .hg/hgrc

#$ name: simple

cat .hg/hgrc
echo 'a ' > a
hg commit -A -m 'test with trailing whitespace'
echo 'a' > a
hg commit -A -m 'drop trailing whitespace and try again'

#$ name:

echo '[hooks]' > .hg/hgrc
echo "pretxncommit.whitespace = .hg/check_whitespace.py" >> .hg/hgrc
cp $EXAMPLE_DIR/data/check_whitespace.py .hg

#$ name: better

cat .hg/hgrc
echo 'a ' >> a
hg commit -A -m 'add new line with trailing whitespace'
sed -i 's, *$,,' a
hg commit -A -m 'trimmed trailing whitespace'

#$ name:
exit 0