Mercurial > hg
comparison tests/test-import-eol.t @ 11808:3f6cf4cb3dca
tests: unify test-qimport-eol
author | Nicolas Dumazet <nicdumz.commits@gmail.com> |
---|---|
date | Thu, 12 Aug 2010 22:57:06 +0900 |
parents | tests/test-import-eol@7936cd261dc9 |
children | fddacca3202e |
comparison
equal
deleted
inserted
replaced
11807:887e9f487b7a | 11808:3f6cf4cb3dca |
---|---|
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 | |
27 | |
28 $ python -c 'file("a", "wb").write("a\nbbb\ncc\n\nd\ne")' | |
29 $ hg ci -Am adda | |
30 adding .hgignore | |
31 adding a | |
32 $ python ../makepatch.py | |
33 | |
34 | |
35 invalid eol | |
36 | |
37 $ hg --config patch.eol='LFCR' import eol.diff | |
38 applying eol.diff | |
39 abort: Unsupported line endings type: LFCR | |
40 $ hg revert -a | |
41 | |
42 | |
43 force LF | |
44 | |
45 $ hg --traceback --config patch.eol='LF' import eol.diff | |
46 applying eol.diff | |
47 $ python -c 'print repr(file("a","rb").read())' | |
48 'a\nyyyy\ncc\n\nd\ne' | |
49 $ hg st | |
50 | |
51 | |
52 force CRLF | |
53 | |
54 $ hg up -C 0 | |
55 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
56 $ hg --traceback --config patch.eol='CRLF' import eol.diff | |
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 | |
61 | |
62 | |
63 auto EOL on LF file | |
64 | |
65 $ hg up -C 0 | |
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 | |
73 | |
74 auto EOL on CRLF file | |
75 | |
76 $ 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' | |
78 $ hg --traceback --config patch.eol='auto' import eol.diff | |
79 applying eol.diff | |
80 $ python -c 'print repr(file("a","rb").read())' | |
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 | |
86 | |
87 $ python -c 'file("noeol", "wb").write("noeol")' | |
88 $ hg add noeol | |
89 $ hg commit -m 'add noeol' | |
90 $ python -c 'file("noeol", "wb").write("noeol\r\nnoeol\n")' | |
91 $ python -c 'file("neweol", "wb").write("neweol\nneweol\r\n")' | |
92 $ hg add neweol | |
93 $ hg diff --git > noeol.diff | |
94 $ hg revert --no-backup noeol neweol | |
95 $ rm neweol | |
96 $ hg --traceback --config patch.eol='auto' import -m noeol noeol.diff | |
97 applying noeol.diff | |
98 $ python -c 'print repr(file("noeol","rb").read())' | |
99 'noeol\r\nnoeol\n' | |
100 $ python -c 'print repr(file("neweol","rb").read())' | |
101 'neweol\nneweol\r\n' | |
102 $ hg st | |
103 | |
104 | |
105 Test --eol and binary patches | |
106 | |
107 $ python -c 'file("b", "wb").write("a\x00\nb\r\nd")' | |
108 $ hg ci -Am addb | |
109 adding b | |
110 $ python -c 'file("b", "wb").write("a\x00\nc\r\nd")' | |
111 $ hg diff --git > bin.diff | |
112 $ hg revert --no-backup b | |
113 | |
114 binary patch with --eol | |
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 .. |