##// END OF EJS Templates
tests: unify test-qimport-eol
Nicolas Dumazet -
r11808:3f6cf4cb default
parent child Browse files
Show More
@@ -1,85 +1,121 b''
1 #!/bin/sh
1 $ cat > makepatch.py <<EOF
2 > f = file('eol.diff', 'wb')
3 > w = f.write
4 > w('test message\n')
5 > w('diff --git a/a b/a\n')
6 > w('--- a/a\n')
7 > w('+++ b/a\n')
8 > w('@@ -1,5 +1,5 @@\n')
9 > w(' a\n')
10 > w('-bbb\r\n')
11 > w('+yyyy\r\n')
12 > w(' cc\r\n')
13 > w(' \n')
14 > w(' d\n')
15 > w('-e\n')
16 > w('\ No newline at end of file\n')
17 > w('+z\r\n')
18 > w('\ No newline at end of file\r\n')
19 > EOF
20
21 $ hg init repo
22 $ cd repo
23 $ echo '\.diff' > .hgignore
24
25
26 Test different --eol values
2
27
3 cat > makepatch.py <<EOF
28 $ python -c 'file("a", "wb").write("a\nbbb\ncc\n\nd\ne")'
4 f = file('eol.diff', 'wb')
29 $ hg ci -Am adda
5 w = f.write
30 adding .hgignore
6 w('test message\n')
31 adding a
7 w('diff --git a/a b/a\n')
32 $ python ../makepatch.py
8 w('--- a/a\n')
33
9 w('+++ b/a\n')
34
10 w('@@ -1,5 +1,5 @@\n')
35 invalid eol
11 w(' a\n')
36
12 w('-bbb\r\n')
37 $ hg --config patch.eol='LFCR' import eol.diff
13 w('+yyyy\r\n')
38 applying eol.diff
14 w(' cc\r\n')
39 abort: Unsupported line endings type: LFCR
15 w(' \n')
40 $ hg revert -a
16 w(' d\n')
41
17 w('-e\n')
42
18 w('\ No newline at end of file\n')
43 force LF
19 w('+z\r\n')
20 w('\ No newline at end of file\r\n')
21 EOF
22
44
23 hg init repo
45 $ hg --traceback --config patch.eol='LF' import eol.diff
24 cd repo
46 applying eol.diff
25 echo '\.diff' > .hgignore
47 $ python -c 'print repr(file("a","rb").read())'
48 'a\nyyyy\ncc\n\nd\ne'
49 $ hg st
26
50
27 # Test different --eol values
28 python -c 'file("a", "wb").write("a\nbbb\ncc\n\nd\ne")'
29 hg ci -Am adda
30 python ../makepatch.py
31
51
32 echo % invalid eol
52 force CRLF
33 hg --config patch.eol='LFCR' import eol.diff
34 hg revert -a
35
53
36 echo % force LF
54 $ hg up -C 0
37 hg --traceback --config patch.eol='LF' import eol.diff
55 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
38 python -c 'print repr(file("a","rb").read())'
56 $ hg --traceback --config patch.eol='CRLF' import eol.diff
39 hg st
57 applying eol.diff
58 $ python -c 'print repr(file("a","rb").read())'
59 'a\r\nyyyy\r\ncc\r\n\r\nd\r\ne'
60 $ hg st
40
61
41 echo % force CRLF
62
42 hg up -C 0
63 auto EOL on LF file
43 hg --traceback --config patch.eol='CRLF' import eol.diff
64
44 python -c 'print repr(file("a","rb").read())'
65 $ hg up -C 0
45 hg st
66 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
67 $ hg --traceback --config patch.eol='auto' import eol.diff
68 applying eol.diff
69 $ python -c 'print repr(file("a","rb").read())'
70 'a\nyyyy\ncc\n\nd\ne'
71 $ hg st
72
46
73
47 echo % auto EOL on LF file
74 auto EOL on CRLF file
48 hg up -C 0
49 hg --traceback --config patch.eol='auto' import eol.diff
50 python -c 'print repr(file("a","rb").read())'
51 hg st
52
75
53 echo % auto EOL on CRLF file
76 $ python -c 'file("a", "wb").write("a\r\nbbb\r\ncc\r\n\r\nd\r\ne")'
54 python -c 'file("a", "wb").write("a\r\nbbb\r\ncc\r\n\r\nd\r\ne")'
77 $ hg commit -m 'switch EOLs in a'
55 hg commit -m 'switch EOLs in a'
78 $ hg --traceback --config patch.eol='auto' import eol.diff
56 hg --traceback --config patch.eol='auto' import eol.diff
79 applying eol.diff
57 python -c 'print repr(file("a","rb").read())'
80 $ python -c 'print repr(file("a","rb").read())'
58 hg st
81 'a\r\nyyyy\r\ncc\r\n\r\nd\r\ne'
82 $ hg st
83
84
85 auto EOL on new file or source without any EOL
59
86
60 echo % auto EOL on new file or source without any EOL
87 $ python -c 'file("noeol", "wb").write("noeol")'
61 python -c 'file("noeol", "wb").write("noeol")'
88 $ hg add noeol
62 hg add noeol
89 $ hg commit -m 'add noeol'
63 hg commit -m 'add noeol'
90 $ python -c 'file("noeol", "wb").write("noeol\r\nnoeol\n")'
64 python -c 'file("noeol", "wb").write("noeol\r\nnoeol\n")'
91 $ python -c 'file("neweol", "wb").write("neweol\nneweol\r\n")'
65 python -c 'file("neweol", "wb").write("neweol\nneweol\r\n")'
92 $ hg add neweol
66 hg add neweol
93 $ hg diff --git > noeol.diff
67 hg diff --git > noeol.diff
94 $ hg revert --no-backup noeol neweol
68 hg revert --no-backup noeol neweol
95 $ rm neweol
69 rm neweol
96 $ hg --traceback --config patch.eol='auto' import -m noeol noeol.diff
70 hg --traceback --config patch.eol='auto' import -m noeol noeol.diff
97 applying noeol.diff
71 python -c 'print repr(file("noeol","rb").read())'
98 $ python -c 'print repr(file("noeol","rb").read())'
72 python -c 'print repr(file("neweol","rb").read())'
99 'noeol\r\nnoeol\n'
73 hg st
100 $ python -c 'print repr(file("neweol","rb").read())'
101 'neweol\nneweol\r\n'
102 $ hg st
103
74
104
75 # Test --eol and binary patches
105 Test --eol and binary patches
76 python -c 'file("b", "wb").write("a\x00\nb\r\nd")'
106
77 hg ci -Am addb
107 $ python -c 'file("b", "wb").write("a\x00\nb\r\nd")'
78 python -c 'file("b", "wb").write("a\x00\nc\r\nd")'
108 $ hg ci -Am addb
79 hg diff --git > bin.diff
109 adding b
80 hg revert --no-backup b
110 $ python -c 'file("b", "wb").write("a\x00\nc\r\nd")'
81 echo % binary patch with --eol
111 $ hg diff --git > bin.diff
82 hg import --config patch.eol='CRLF' -m changeb bin.diff
112 $ hg revert --no-backup b
83 python -c 'print repr(file("b","rb").read())'
113
84 hg st
114 binary patch with --eol
85 cd ..
115
116 $ hg import --config patch.eol='CRLF' -m changeb bin.diff
117 applying bin.diff
118 $ python -c 'print repr(file("b","rb").read())'
119 'a\x00\nc\r\nd'
120 $ hg st
121 $ cd ..
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now