##// END OF EJS Templates
test-win32text: avoid unix2dos, printf extensions
Patrick Mezard -
r5680:963c516b default
parent child Browse files
Show More
@@ -1,56 +1,65
1 1 #!/bin/sh
2 2
3 cat > unix2dos.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\n')
9 file(path, 'wb').write(data)
10 EOF
11
3 12 hg init
4 13 echo '[hooks]' >> .hg/hgrc
5 14 echo 'pretxncommit.crlf = python:hgext.win32text.forbidcrlf' >> .hg/hgrc
6 15 echo 'pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf' >> .hg/hgrc
7 16 cat .hg/hgrc
8 17 echo
9 18
10 19 echo hello > f
11 20 hg add f
12 21 hg ci -m 1 -d'0 0'
13 22 echo
14 23
15 unix2dos f
24 python unix2dos.py f
16 25 hg ci -m 2 -d'0 0'
17 26 hg revert -a
18 27 echo
19 28
20 29 mkdir d
21 30 echo hello > d/f2
22 unix2dos d/f2
31 python unix2dos.py d/f2
23 32 hg add d/f2
24 33 hg ci -m 3 -d'0 0'
25 34 hg revert -a
26 35 rm d/f2
27 36 echo
28 37
29 38 hg rem f
30 39 hg ci -m 4 -d'0 0'
31 40 echo
32 41
33 printf 'hello\x00\x0D\x0A' > bin
42 python -c 'file("bin", "wb").write("hello\x00\x0D\x0A")'
34 43 hg add bin
35 44 hg ci -m 5 -d'0 0'
36 45 hg log -v
37 46 echo
38 47
39 48 hg clone . dupe
40 49 echo
41 50 for x in a b c d; do echo content > dupe/$x; done
42 51 hg -R dupe add
43 unix2dos dupe/b dupe/c dupe/d
52 python unix2dos.py dupe/b dupe/c dupe/d
44 53 hg -R dupe ci -m a -d'0 0' dupe/a
45 54 hg -R dupe ci -m b/c -d'0 0' dupe/[bc]
46 55 hg -R dupe ci -m d -d'0 0' dupe/d
47 56 hg -R dupe log -v
48 57 echo
49 58
50 59 hg pull dupe
51 60 echo
52 61
53 62 hg log -v
54 63 echo
55 64
56 65 # XXX missing tests for encode/decode hooks
@@ -1,157 +1,157
1 1 [hooks]
2 2 pretxncommit.crlf = python:hgext.win32text.forbidcrlf
3 3 pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf
4 4
5 5
6 6 Attempt to commit or push text file(s) using CRLF line endings
7 7 in b1aa5cde7ff4: f
8 8 transaction abort!
9 9 rollback completed
10 10 abort: pretxncommit.crlf hook failed
11 11 reverting f
12 12
13 13 Attempt to commit or push text file(s) using CRLF line endings
14 14 in 88b17af74937: d/f2
15 15 transaction abort!
16 16 rollback completed
17 17 abort: pretxncommit.crlf hook failed
18 18 forgetting d/f2
19 19
20 20
21 changeset: 2:a55cab36df04
21 changeset: 2:b67b2dae057a
22 22 tag: tip
23 23 user: test
24 24 date: Thu Jan 01 00:00:00 1970 +0000
25 25 files: bin
26 26 description:
27 27 5
28 28
29 29
30 30 changeset: 1:c72a7d1d0907
31 31 user: test
32 32 date: Thu Jan 01 00:00:00 1970 +0000
33 33 files: f
34 34 description:
35 35 4
36 36
37 37
38 38 changeset: 0:fcf06d5c4e1d
39 39 user: test
40 40 date: Thu Jan 01 00:00:00 1970 +0000
41 41 files: f
42 42 description:
43 43 1
44 44
45 45
46 46
47 47 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
48 48
49 49 adding dupe/a
50 50 adding dupe/b
51 51 adding dupe/c
52 52 adding dupe/d
53 changeset: 5:81c49ee61396
53 changeset: 5:6e8a7629ff5b
54 54 tag: tip
55 55 user: test
56 56 date: Thu Jan 01 00:00:00 1970 +0000
57 57 files: d
58 58 description:
59 59 d
60 60
61 61
62 changeset: 4:02184785bcac
62 changeset: 4:ac30a42ce8bc
63 63 user: test
64 64 date: Thu Jan 01 00:00:00 1970 +0000
65 65 files: b c
66 66 description:
67 67 b/c
68 68
69 69
70 changeset: 3:36e70ffe2c3d
70 changeset: 3:a73b85ef1fb7
71 71 user: test
72 72 date: Thu Jan 01 00:00:00 1970 +0000
73 73 files: a
74 74 description:
75 75 a
76 76
77 77
78 changeset: 2:a55cab36df04
78 changeset: 2:b67b2dae057a
79 79 user: test
80 80 date: Thu Jan 01 00:00:00 1970 +0000
81 81 files: bin
82 82 description:
83 83 5
84 84
85 85
86 86 changeset: 1:c72a7d1d0907
87 87 user: test
88 88 date: Thu Jan 01 00:00:00 1970 +0000
89 89 files: f
90 90 description:
91 91 4
92 92
93 93
94 94 changeset: 0:fcf06d5c4e1d
95 95 user: test
96 96 date: Thu Jan 01 00:00:00 1970 +0000
97 97 files: f
98 98 description:
99 99 1
100 100
101 101
102 102
103 103 pulling from dupe
104 104 searching for changes
105 105 adding changesets
106 106 adding manifests
107 107 adding file changes
108 108 added 3 changesets with 4 changes to 4 files
109 109 Attempt to commit or push text file(s) using CRLF line endings
110 in 02184785bcac: b
111 in 02184785bcac: c
112 in 81c49ee61396: d
110 in ac30a42ce8bc: b
111 in ac30a42ce8bc: c
112 in 6e8a7629ff5b: d
113 113
114 114 To prevent this mistake in your local repository,
115 115 add to Mercurial.ini or .hg/hgrc:
116 116
117 117 [hooks]
118 118 pretxncommit.crlf = python:hgext.win32text.forbidcrlf
119 119
120 120 and also consider adding:
121 121
122 122 [extensions]
123 123 hgext.win32text =
124 124 [encode]
125 125 ** = cleverencode:
126 126 [decode]
127 127 ** = cleverdecode:
128 128 transaction abort!
129 129 rollback completed
130 130 abort: pretxnchangegroup.crlf hook failed
131 131
132 changeset: 2:a55cab36df04
132 changeset: 2:b67b2dae057a
133 133 tag: tip
134 134 user: test
135 135 date: Thu Jan 01 00:00:00 1970 +0000
136 136 files: bin
137 137 description:
138 138 5
139 139
140 140
141 141 changeset: 1:c72a7d1d0907
142 142 user: test
143 143 date: Thu Jan 01 00:00:00 1970 +0000
144 144 files: f
145 145 description:
146 146 4
147 147
148 148
149 149 changeset: 0:fcf06d5c4e1d
150 150 user: test
151 151 date: Thu Jan 01 00:00:00 1970 +0000
152 152 files: f
153 153 description:
154 154 1
155 155
156 156
157 157
General Comments 0
You need to be logged in to leave comments. Login now