##// END OF EJS Templates
tests: unify test-mq-eol
Nicolas Dumazet -
r11895:78e3a70c default
parent child Browse files
Show More
@@ -1,66 +1,141 b''
1 #!/bin/sh
1
2 Test interactions between mq and patch.eol
3
2 4
3 # Test interactions between mq and patch.eol
5 $ echo "[extensions]" >> $HGRCPATH
6 $ echo "mq=" >> $HGRCPATH
7 $ echo "[diff]" >> $HGRCPATH
8 $ echo "nodates=1" >> $HGRCPATH
4 9
5 echo "[extensions]" >> $HGRCPATH
6 echo "mq=" >> $HGRCPATH
7 echo "[diff]" >> $HGRCPATH
8 echo "nodates=1" >> $HGRCPATH
10 $ cat > makepatch.py <<EOF
11 > f = file('eol.diff', 'wb')
12 > w = f.write
13 > w('test message\n')
14 > w('diff --git a/a b/a\n')
15 > w('--- a/a\n')
16 > w('+++ b/a\n')
17 > w('@@ -1,5 +1,5 @@\n')
18 > w(' a\n')
19 > w('-b\r\n')
20 > w('+y\r\n')
21 > w(' c\r\n')
22 > w(' d\n')
23 > w('-e\n')
24 > w('\ No newline at end of file\n')
25 > w('+z\r\n')
26 > w('\ No newline at end of file\r\n')
27 > EOF
9 28
10 cat > makepatch.py <<EOF
11 f = file('eol.diff', 'wb')
12 w = f.write
13 w('test message\n')
14 w('diff --git a/a b/a\n')
15 w('--- a/a\n')
16 w('+++ b/a\n')
17 w('@@ -1,5 +1,5 @@\n')
18 w(' a\n')
19 w('-b\r\n')
20 w('+y\r\n')
21 w(' c\r\n')
22 w(' d\n')
23 w('-e\n')
24 w('\ No newline at end of file\n')
25 w('+z\r\n')
26 w('\ No newline at end of file\r\n')
27 EOF
29 $ cat > cateol.py <<EOF
30 > import sys
31 > for line in file(sys.argv[1], 'rb'):
32 > line = line.replace('\r', '<CR>')
33 > line = line.replace('\n', '<LF>')
34 > print line
35 > EOF
36
37 $ hg init repo
38 $ cd repo
39 $ echo '\.diff' > .hgignore
40 $ echo '\.rej' >> .hgignore
41
42
43 Test different --eol values
44
45 $ python -c 'file("a", "wb").write("a\nb\nc\nd\ne")'
46 $ hg ci -Am adda
47 adding .hgignore
48 adding a
49 $ python ../makepatch.py
50 $ hg qimport eol.diff
51 adding eol.diff to series file
52
53 should fail in strict mode
54
55 $ hg qpush
56 applying eol.diff
57 patching file a
58 Hunk #1 FAILED at 0
59 1 out of 1 hunks FAILED -- saving rejects to file a.rej
60 patch failed, unable to continue (try -v)
61 patch failed, rejects left in working dir
62 errors during apply, please fix and refresh eol.diff
63 $ hg qpop
64 popping eol.diff
65 patch queue now empty
66
67 invalid eol
28 68
29 cat > cateol.py <<EOF
30 import sys
31 for line in file(sys.argv[1], 'rb'):
32 line = line.replace('\r', '<CR>')
33 line = line.replace('\n', '<LF>')
34 print line
35 EOF
69 $ hg --config patch.eol='LFCR' qpush
70 applying eol.diff
71 patch failed, unable to continue (try -v)
72 patch failed, rejects left in working dir
73 errors during apply, please fix and refresh eol.diff
74 $ hg qpop
75 popping eol.diff
76 patch queue now empty
36 77
37 hg init repo
38 cd repo
39 echo '\.diff' > .hgignore
40 echo '\.rej' >> .hgignore
78 force LF
41 79
42 # Test different --eol values
43 python -c 'file("a", "wb").write("a\nb\nc\nd\ne")'
44 hg ci -Am adda
45 python ../makepatch.py
46 hg qimport eol.diff
47 echo % should fail in strict mode
48 hg qpush
49 hg qpop
50 echo % invalid eol
51 hg --config patch.eol='LFCR' qpush
52 hg qpop
53 echo % force LF
54 hg --config patch.eol='CRLF' qpush
55 hg qrefresh
56 python ../cateol.py .hg/patches/eol.diff
57 python ../cateol.py a
58 hg qpop
59 echo % push again forcing LF and compare revisions
60 hg --config patch.eol='CRLF' qpush
61 python ../cateol.py a
62 hg qpop
63 echo % push again without LF and compare revisions
64 hg qpush
65 python ../cateol.py a
66 hg qpop
80 $ hg --config patch.eol='CRLF' qpush
81 applying eol.diff
82 now at: eol.diff
83 $ hg qrefresh
84 $ python ../cateol.py .hg/patches/eol.diff
85 test message<LF>
86 <LF>
87 diff -r 0d0bf99a8b7a a<LF>
88 --- a/a<LF>
89 +++ b/a<LF>
90 @@ -1,5 +1,5 @@<LF>
91 -a<LF>
92 -b<LF>
93 -c<LF>
94 -d<LF>
95 -e<LF>
96 \ No newline at end of file<LF>
97 +a<CR><LF>
98 +y<CR><LF>
99 +c<CR><LF>
100 +d<CR><LF>
101 +z<LF>
102 \ No newline at end of file<LF>
103 $ python ../cateol.py a
104 a<CR><LF>
105 y<CR><LF>
106 c<CR><LF>
107 d<CR><LF>
108 z
109 $ hg qpop
110 popping eol.diff
111 patch queue now empty
112
113 push again forcing LF and compare revisions
114
115 $ hg --config patch.eol='CRLF' qpush
116 applying eol.diff
117 now at: eol.diff
118 $ python ../cateol.py a
119 a<CR><LF>
120 y<CR><LF>
121 c<CR><LF>
122 d<CR><LF>
123 z
124 $ hg qpop
125 popping eol.diff
126 patch queue now empty
127
128 push again without LF and compare revisions
129
130 $ hg qpush
131 applying eol.diff
132 now at: eol.diff
133 $ python ../cateol.py a
134 a<CR><LF>
135 y<CR><LF>
136 c<CR><LF>
137 d<CR><LF>
138 z
139 $ hg qpop
140 popping eol.diff
141 patch queue now empty
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now