comparison tests/test-mactext @ 6481:e837dded56c7

win32text: Add macencode/macdecode
author OHASHI Hideya <ohachige@gmail.com>
date Thu, 03 Apr 2008 20:41:31 +0900
parents
children 529d7887ecfe
comparison
equal deleted inserted replaced
6472:8c4cd80afd3e 6481:e837dded56c7
1 #!/bin/sh
2
3 cat > unix2mac.py <<EOF
4 import sys
5
6 for path in sys.argv[1:]:
7 data = file(path, 'rb').read()
8 data = data.replace('\n', '\r')
9 file(path, 'wb').write(data)
10 EOF
11
12 cat > print.py <<EOF
13 import sys
14 print(sys.stdin.read().replace('\n', '<LF>').replace('\r', '<CR>').replace('\0', '<NUL>'))
15 EOF
16
17 hg init
18 echo '[hooks]' >> .hg/hgrc
19 echo 'pretxncommit.cr = python:hgext.win32text.forbidcr' >> .hg/hgrc
20 echo 'pretxnchangegroup.cr = python:hgext.win32text.forbidcr' >> .hg/hgrc
21 cat .hg/hgrc
22 echo
23
24 echo hello > f
25 hg add f
26 hg ci -m 1 -d'0 0'
27 echo
28
29 python unix2mac.py f
30 hg ci -m 2 -d'0 0'
31 hg revert -a
32 echo
33
34 mkdir d
35 echo hello > d/f2
36 python unix2mac.py d/f2
37 hg add d/f2
38 hg ci -m 3 -d'0 0'
39 hg revert -a
40 rm d/f2
41 echo
42
43 hg rem f
44 hg ci -m 4 -d'0 0'
45 echo
46
47 python -c 'file("bin", "wb").write("hello\x00\x0D")'
48 hg add bin
49 hg ci -m 5 -d'0 0'
50 hg log -v
51 echo
52
53 hg clone . dupe
54 echo
55 for x in a b c d; do echo content > dupe/$x; done
56 hg -R dupe add
57 python unix2mac.py dupe/b dupe/c dupe/d
58 hg -R dupe ci -m a -d'0 0' dupe/a
59 hg -R dupe ci -m b/c -d'0 0' dupe/[bc]
60 hg -R dupe ci -m d -d'0 0' dupe/d
61 hg -R dupe log -v
62 echo
63
64 hg pull dupe
65 echo
66
67 hg log -v
68 echo
69
70 rm .hg/hgrc
71 (echo some; echo text) > f3
72 python -c 'file("f4.bat", "wb").write("rem empty\x0D")'
73 hg add f3 f4.bat
74 hg ci -m 6 -d'0 0'
75
76 python print.py < bin
77 python print.py < f3
78 python print.py < f4.bat
79 echo
80
81 echo '[extensions]' >> .hg/hgrc
82 echo 'win32text = ' >> .hg/hgrc
83 echo '[decode]' >> .hg/hgrc
84 echo '** = macdecode:' >> .hg/hgrc
85 echo '[encode]' >> .hg/hgrc
86 echo '** = macencode:' >> .hg/hgrc
87 cat .hg/hgrc
88 echo
89
90 rm f3 f4.bat bin
91 hg co 2>&1 | python -c 'import sys, os; sys.stdout.write(sys.stdin.read().replace(os.getcwd(), "...."))'
92 python print.py < bin
93 python print.py < f3
94 python print.py < f4.bat
95 echo
96
97 python -c 'file("f5.sh", "wb").write("# empty\x0D")'
98 hg add f5.sh
99 hg ci -m 7 -d'0 0'
100 python print.py < f5.sh
101 hg cat f5.sh | python print.py
102
103 echo '% just linefeed' > linefeed
104 hg ci -qAm 8 linefeed
105 python print.py < linefeed
106 hg cat linefeed | python print.py
107 hg st -q
108 hg revert -a linefeed
109 python print.py < linefeed
110 hg st -q
111 echo modified >> linefeed
112 hg st -q
113 hg revert -a
114 hg st -q
115 python print.py < linefeed