Show More
@@ -1,38 +1,36 b'' | |||
|
1 | 1 | |
|
2 | 2 | $ cat > unix2mac.py <<EOF |
|
3 | 3 | > import sys |
|
4 | 4 | > |
|
5 | 5 | > for path in sys.argv[1:]: |
|
6 | 6 | > data = open(path, 'rb').read() |
|
7 | 7 | > data = data.replace(b'\n', b'\r') |
|
8 | 8 | > open(path, 'wb').write(data) |
|
9 | 9 | > EOF |
|
10 | $ cat > print.py <<EOF | |
|
11 | > import sys | |
|
12 | > print(sys.stdin.read().replace('\n', '<LF>').replace('\r', '<CR>').replace('\0', '<NUL>')) | |
|
13 | > EOF | |
|
14 | 10 | $ hg init |
|
15 | 11 | $ echo '[hooks]' >> .hg/hgrc |
|
16 | 12 | $ echo 'pretxncommit.cr = python:hgext.win32text.forbidcr' >> .hg/hgrc |
|
17 | 13 | $ echo 'pretxnchangegroup.cr = python:hgext.win32text.forbidcr' >> .hg/hgrc |
|
18 | 14 | $ cat .hg/hgrc |
|
19 | 15 | [hooks] |
|
20 | 16 | pretxncommit.cr = python:hgext.win32text.forbidcr |
|
21 | 17 | pretxnchangegroup.cr = python:hgext.win32text.forbidcr |
|
22 | 18 | |
|
23 | 19 | $ echo hello > f |
|
24 | 20 | $ hg add f |
|
25 | 21 | $ hg ci -m 1 |
|
26 | 22 | |
|
27 | 23 | $ "$PYTHON" unix2mac.py f |
|
28 | 24 | $ hg ci -m 2 |
|
29 | 25 | attempt to commit or push text file(s) using CR line endings |
|
30 | 26 | in dea860dc51ec: f |
|
31 | 27 | transaction abort! |
|
32 | 28 | rollback completed |
|
33 | 29 | abort: pretxncommit.cr hook failed |
|
34 | 30 | [255] |
|
35 | $ hg cat f | "$PYTHON" print.py | |
|
36 | hello<LF> | |
|
37 | $ cat f | "$PYTHON" print.py | |
|
38 | hello<CR> | |
|
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.| |
General Comments 0
You need to be logged in to leave comments.
Login now