Mercurial > hgbook
annotate en/examples/ch09/hook.ws @ 821:88828b784971
Add more complex example hook
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Tue, 28 Apr 2009 23:10:43 -0700 |
parents | en/examples/hook.ws@e67251ac336f |
children |
rev | line source |
---|---|
47
6f37e6a7d8cd
Get Emacs to figure out what syntax highlighting to use for examples.
Bryan O'Sullivan <bos@serpentine.com>
parents:
44
diff
changeset
|
1 #!/bin/bash |
6f37e6a7d8cd
Get Emacs to figure out what syntax highlighting to use for examples.
Bryan O'Sullivan <bos@serpentine.com>
parents:
44
diff
changeset
|
2 |
44
012df94a02fe
Start hook examples. First is for trailing whitespace.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
3 hg init a |
012df94a02fe
Start hook examples. First is for trailing whitespace.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
4 cd a |
012df94a02fe
Start hook examples. First is for trailing whitespace.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
5 echo '[hooks]' > .hg/hgrc |
167
e67251ac336f
Small portability change. "grep -P" doesn't work on Debian.
Bryan O'Sullivan <bos@serpentine.com>
parents:
165
diff
changeset
|
6 echo "pretxncommit.whitespace = hg export tip | (! egrep -q '^\\+.*[ \\t]$')" >> .hg/hgrc |
44
012df94a02fe
Start hook examples. First is for trailing whitespace.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
7 |
012df94a02fe
Start hook examples. First is for trailing whitespace.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
8 #$ name: simple |
012df94a02fe
Start hook examples. First is for trailing whitespace.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
9 |
012df94a02fe
Start hook examples. First is for trailing whitespace.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
10 cat .hg/hgrc |
012df94a02fe
Start hook examples. First is for trailing whitespace.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
11 echo 'a ' > a |
012df94a02fe
Start hook examples. First is for trailing whitespace.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
12 hg commit -A -m 'test with trailing whitespace' |
49 | 13 echo 'a' > a |
14 hg commit -A -m 'drop trailing whitespace and try again' | |
15 | |
16 #$ name: | |
17 | |
18 echo '[hooks]' > .hg/hgrc | |
150 | 19 echo "pretxncommit.whitespace = .hg/check_whitespace.py" >> .hg/hgrc |
821
88828b784971
Add more complex example hook
Bryan O'Sullivan <bos@serpentine.com>
parents:
167
diff
changeset
|
20 cp $EXAMPLE_DIR/ch09/check_whitespace.py.lst .hg/check_whitespace.py |
88828b784971
Add more complex example hook
Bryan O'Sullivan <bos@serpentine.com>
parents:
167
diff
changeset
|
21 chmod +x .hg/check_whitespace.py |
49 | 22 |
23 #$ name: better | |
24 | |
25 cat .hg/hgrc | |
26 echo 'a ' >> a | |
27 hg commit -A -m 'add new line with trailing whitespace' | |
165
06d18465df03
Make an example run more predictably.
Bryan O'Sullivan <bos@serpentine.com>
parents:
150
diff
changeset
|
28 sed -i 's, *$,,' a |
49 | 29 hg commit -A -m 'trimmed trailing whitespace' |
74
ec1f144968de
Fix a few examples now that run-examples is more stringent.
Bryan O'Sullivan <bos@serpentine.com>
parents:
49
diff
changeset
|
30 |
ec1f144968de
Fix a few examples now that run-examples is more stringent.
Bryan O'Sullivan <bos@serpentine.com>
parents:
49
diff
changeset
|
31 #$ name: |
ec1f144968de
Fix a few examples now that run-examples is more stringent.
Bryan O'Sullivan <bos@serpentine.com>
parents:
49
diff
changeset
|
32 exit 0 |