Mercurial > hg > mercurial-source
comparison tests/test-eol-update.t @ 12424:1aa7ba33f6a9
tests: unify test-eol-update
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 26 Sep 2010 13:41:32 -0500 |
parents | tests/test-eol-update@0bb67503ad4b |
children | 7439ea4146f8 |
comparison
equal
deleted
inserted
replaced
12423:10c3385fa89e | 12424:1aa7ba33f6a9 |
---|---|
1 Test EOL update | |
2 | |
3 $ cat > $HGRCPATH <<EOF | |
4 > [diff] | |
5 > git = 1 | |
6 > EOF | |
7 | |
8 $ seteol () { | |
9 > if [ $1 = "LF" ]; then | |
10 > EOL='\n' | |
11 > else | |
12 > EOL='\r\n' | |
13 > fi | |
14 > } | |
15 | |
16 $ makerepo () { | |
17 > echo | |
18 > echo "# ==== setup repository ====" | |
19 > echo '% hg init' | |
20 > hg init repo | |
21 > cd repo | |
22 > | |
23 > cat > .hgeol <<EOF | |
24 > [patterns] | |
25 > **.txt = LF | |
26 > EOF | |
27 > | |
28 > printf "first\nsecond\nthird\n" > a.txt | |
29 > hg commit --addremove -m 'LF commit' | |
30 > | |
31 > cat > .hgeol <<EOF | |
32 > [patterns] | |
33 > **.txt = CRLF | |
34 > EOF | |
35 > | |
36 > printf "first\r\nsecond\r\nthird\r\n" > a.txt | |
37 > hg commit -m 'CRLF commit' | |
38 > | |
39 > cd .. | |
40 > } | |
41 | |
42 $ dotest () { | |
43 > seteol $1 | |
44 > | |
45 > echo | |
46 > echo "% hg clone repo repo-$1" | |
47 > hg clone --noupdate repo repo-$1 | |
48 > cd repo-$1 | |
49 > | |
50 > cat > .hg/hgrc <<EOF | |
51 > [extensions] | |
52 > eol = | |
53 > EOF | |
54 > | |
55 > hg update | |
56 > | |
57 > echo '% printrepr.py a.txt (before)' | |
58 > python $TESTDIR/printrepr.py < a.txt | |
59 > | |
60 > printf "first${EOL}third${EOL}" > a.txt | |
61 > | |
62 > echo '% printrepr.py a.txt (after)' | |
63 > python $TESTDIR/printrepr.py < a.txt | |
64 > echo '% hg diff' | |
65 > hg diff | python $TESTDIR/printrepr.py | |
66 > | |
67 > echo '% hg update 0' | |
68 > hg update 0 | |
69 > | |
70 > echo '% printrepr.py a.txt' | |
71 > python $TESTDIR/printrepr.py < a.txt | |
72 > echo '% hg diff' | |
73 > hg diff | python $TESTDIR/printrepr.py | |
74 > | |
75 > | |
76 > cd .. | |
77 > rm -r repo-$1 | |
78 > } | |
79 | |
80 $ makerepo | |
81 | |
82 # ==== setup repository ==== | |
83 % hg init | |
84 adding .hgeol | |
85 adding a.txt | |
86 $ dotest LF | |
87 | |
88 % hg clone repo repo-LF | |
89 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
90 % printrepr.py a.txt (before) | |
91 first\r | |
92 second\r | |
93 third\r | |
94 % printrepr.py a.txt (after) | |
95 first | |
96 third | |
97 % hg diff | |
98 diff --git a/a.txt b/a.txt | |
99 --- a/a.txt | |
100 +++ b/a.txt | |
101 @@ -1,3 +1,2 @@ | |
102 first\r | |
103 -second\r | |
104 third\r | |
105 % hg update 0 | |
106 merging a.txt | |
107 1 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
108 % printrepr.py a.txt | |
109 first | |
110 third | |
111 % hg diff | |
112 diff --git a/a.txt b/a.txt | |
113 --- a/a.txt | |
114 +++ b/a.txt | |
115 @@ -1,3 +1,2 @@ | |
116 first | |
117 -second | |
118 third | |
119 $ dotest CRLF | |
120 | |
121 % hg clone repo repo-CRLF | |
122 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
123 % printrepr.py a.txt (before) | |
124 first\r | |
125 second\r | |
126 third\r | |
127 % printrepr.py a.txt (after) | |
128 first\r | |
129 third\r | |
130 % hg diff | |
131 diff --git a/a.txt b/a.txt | |
132 --- a/a.txt | |
133 +++ b/a.txt | |
134 @@ -1,3 +1,2 @@ | |
135 first\r | |
136 -second\r | |
137 third\r | |
138 % hg update 0 | |
139 merging a.txt | |
140 1 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
141 % printrepr.py a.txt | |
142 first | |
143 third | |
144 % hg diff | |
145 diff --git a/a.txt b/a.txt | |
146 --- a/a.txt | |
147 +++ b/a.txt | |
148 @@ -1,3 +1,2 @@ | |
149 first | |
150 -second | |
151 third | |
152 $ rm -r repo |