author | Idan Kamara <idankk86@gmail.com> |
Mon, 01 Aug 2011 19:53:00 +0300 | |
branch | stable |
changeset 15000 | 68b5d7005cca |
parent 12458 | 9446bd059da3 |
child 15243 | 1e9451476bf8 |
permissions | -rw-r--r-- |
6481
e837dded56c7
win32text: Add macencode/macdecode
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
1 |
|
12458 | 2 |
$ cat > unix2mac.py <<EOF |
3 |
> import sys |
|
4 |
> |
|
5 |
> for path in sys.argv[1:]: |
|
6 |
> data = file(path, 'rb').read() |
|
7 |
> data = data.replace('\n', '\r') |
|
8 |
> file(path, 'wb').write(data) |
|
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 |
$ hg init |
|
15 |
$ echo '[hooks]' >> .hg/hgrc |
|
16 |
$ echo 'pretxncommit.cr = python:hgext.win32text.forbidcr' >> .hg/hgrc |
|
17 |
$ echo 'pretxnchangegroup.cr = python:hgext.win32text.forbidcr' >> .hg/hgrc |
|
18 |
$ cat .hg/hgrc |
|
19 |
[hooks] |
|
20 |
pretxncommit.cr = python:hgext.win32text.forbidcr |
|
21 |
pretxnchangegroup.cr = python:hgext.win32text.forbidcr |
|
22 |
$ echo |
|
23 |
||
24 |
$ echo hello > f |
|
25 |
$ hg add f |
|
26 |
$ hg ci -m 1 |
|
27 |
$ echo |
|
28 |
||
29 |
$ python unix2mac.py f |
|
30 |
$ hg ci -m 2 |
|
31 |
Attempt to commit or push text file(s) using CR line endings |
|
32 |
in dea860dc51ec: f |
|
33 |
transaction abort! |
|
34 |
rollback completed |
|
35 |
abort: pretxncommit.cr hook failed |
|
36 |
[255] |
|
37 |
$ hg cat f | python print.py |
|
38 |
hello<LF> |
|
39 |
$ cat f | python print.py |
|
40 |
hello<CR> |