| 1 |
|
| 2 |
$ cat > unix2mac.py <<EOF |
| 3 |
> import sys |
| 4 |
> |
| 5 |
> for path in sys.argv[1:]: |
| 6 |
> data = open(path, 'rb').read() |
| 7 |
> data = data.replace(b'\n', b'\r') |
| 8 |
> open(path, 'wb').write(data) |
| 9 |
> EOF |
| 10 |
$ hg init |
| 11 |
$ echo '[hooks]' >> .hg/hgrc |
| 12 |
$ echo 'pretxncommit.cr = python:hgext.win32text.forbidcr' >> .hg/hgrc |
| 13 |
$ echo 'pretxnchangegroup.cr = python:hgext.win32text.forbidcr' >> .hg/hgrc |
| 14 |
$ cat .hg/hgrc |
| 15 |
[hooks] |
| 16 |
pretxncommit.cr = python:hgext.win32text.forbidcr |
| 17 |
pretxnchangegroup.cr = python:hgext.win32text.forbidcr |
| 18 |
|
| 19 |
$ echo hello > f |
| 20 |
$ hg add f |
| 21 |
$ hg ci -m 1 |
| 22 |
|
| 23 |
$ "$PYTHON" unix2mac.py f |
| 24 |
$ hg ci -m 2 |
| 25 |
attempt to commit or push text file(s) using CR line endings |
| 26 |
in dea860dc51ec: f |
| 27 |
transaction abort! |
| 28 |
rollback completed |
| 29 |
abort: pretxncommit.cr hook failed |
| 30 |
[40] |
| 31 |
$ hg cat f | f --hexdump |
| 32 |
|
| 33 |
0000: 68 65 6c 6c 6f 0a |hello.| |
| 34 |
$ f --hexdump f |
| 35 |
f: |
| 36 |
0000: 68 65 6c 6c 6f 0d |hello.| |