Debian Codegraph @

tests/test-eol-update.t

raw
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 > printf "f\r\n" > f
30 > hg commit --addremove -m 'LF commit'
31 >
32 > cat > .hgeol <<EOF
33 > [patterns]
34 > **.txt = CRLF
35 > f = LF
36 > EOF
37 >
38 > printf "first\r\nsecond\r\nthird\r\n" > a.txt
39 > printf "f\n" > f
40 > hg commit -m 'CRLF commit'
41 >
42 > cd ..
43 > }
44
45 $ dotest () {
46 > seteol $1
47 >
48 > echo
49 > echo "% hg clone repo repo-$1"
50 > hg clone --noupdate repo repo-$1
51 > cd repo-$1
52 >
53 > cat > .hg/hgrc <<EOF
54 > [extensions]
55 > eol =
56 > EOF
57 >
58 > hg update
59 >
60 > echo '% a.txt (before)'
61 > cat a.txt
62 >
63 > printf "first${EOL}third${EOL}" > a.txt
64 >
65 > echo '% a.txt (after)'
66 > cat a.txt
67 > echo '% hg diff'
68 > hg diff
69 >
70 > echo '% hg update 0'
71 > hg update 0
72 >
73 > echo '% a.txt'
74 > cat a.txt
75 > echo '% hg diff'
76 > hg diff
77 >
78 >
79 > cd ..
80 > rm -r repo-$1
81 > }
82
83 $ makerepo
84
85 # ==== setup repository ====
86 % hg init
87 adding .hgeol
88 adding a.txt
89 adding f
90 $ dotest LF
91
92 % hg clone repo repo-LF
93 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
94 % a.txt (before)
95 first\r (esc)
96 second\r (esc)
97 third\r (esc)
98 % a.txt (after)
99 first
100 third
101 % hg diff
102 diff --git a/a.txt b/a.txt
103 --- a/a.txt
104 +++ b/a.txt
105 @@ -1,3 +1,2 @@
106 first\r (esc)
107 -second\r (esc)
108 third\r (esc)
109 % hg update 0
110 merging a.txt
111 2 files updated, 1 files merged, 0 files removed, 0 files unresolved
112 % a.txt
113 first
114 third
115 % hg diff
116 diff --git a/a.txt b/a.txt
117 --- a/a.txt
118 +++ b/a.txt
119 @@ -1,3 +1,2 @@
120 first
121 -second
122 third
123 $ dotest CRLF
124
125 % hg clone repo repo-CRLF
126 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
127 % a.txt (before)
128 first\r (esc)
129 second\r (esc)
130 third\r (esc)
131 % a.txt (after)
132 first\r (esc)
133 third\r (esc)
134 % hg diff
135 diff --git a/a.txt b/a.txt
136 --- a/a.txt
137 +++ b/a.txt
138 @@ -1,3 +1,2 @@
139 first\r (esc)
140 -second\r (esc)
141 third\r (esc)
142 % hg update 0
143 merging a.txt
144 2 files updated, 1 files merged, 0 files removed, 0 files unresolved
145 % a.txt
146 first
147 third
148 % hg diff
149 diff --git a/a.txt b/a.txt
150 --- a/a.txt
151 +++ b/a.txt
152 @@ -1,3 +1,2 @@
153 first
154 -second
155 third
156
157 Test in repo using eol extension, while keeping an eye on how filters are
158 applied:
159
160 $ cd repo
161
162 $ hg up -q -c -r null
163 $ cat > .hg/hgrc <<EOF
164 > [extensions]
165 > eol =
166 > EOF
167
168 Update to revision 0 which has no .hgeol, shouldn't use any filters, and
169 obviously should leave things as tidy as they were before the clean update.
170
171 $ hg up -c -r 0 -v --debug
172 resolving manifests
173 branchmerge: False, force: False, partial: False
174 ancestor: 000000000000, local: 000000000000+, remote: 15cbdf8ca3db
175 calling hook preupdate.eol: hgext.eol.preupdate
176 .hgeol: remote created -> g
177 getting .hgeol
178 filtering .hgeol through isbinary
179 a.txt: remote created -> g
180 getting a.txt
181 filtering a.txt through tolf
182 f: remote created -> g
183 getting f
184 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
185 $ hg st
186
187 $ hg branch b
188 marked working directory as branch b
189 (branches are permanent and global, did you want a bookmark?)
190 $ hg ci -m b
191
192 Merge changes that apply a filter to f:
193
194 $ hg merge 1
195 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
196 (branch merge, don't forget to commit)
197 $ hg st
198 M .hgeol
199 M a.txt
200 M f
201 $ hg diff
202 diff --git a/.hgeol b/.hgeol
203 --- a/.hgeol
204 +++ b/.hgeol
205 @@ -1,2 +1,3 @@
206 [patterns]
207 -**.txt = LF
208 +**.txt = CRLF
209 +f = LF
210 diff --git a/a.txt b/a.txt
211 --- a/a.txt
212 +++ b/a.txt
213 @@ -1,3 +1,3 @@
214 -first
215 -second
216 -third
217 +first\r (esc)
218 +second\r (esc)
219 +third\r (esc)
220 diff --git a/f b/f
221 --- a/f
222 +++ b/f
223 @@ -1,1 +1,1 @@
224 -f\r (esc)
225 +f
226
227 Abort the merge with up -C to revision 0.
228 Note that files are filtered correctly for revision 0: f is not filtered, a.txt
229 is filtered with tolf, and everything is left tidy.
230
231 $ touch .hgeol * # ensure consistent dirtyness checks ignoring dirstate
232 $ hg up -C -r 0 -v --debug
233 eol: detected change in .hgeol
234 resolving manifests
235 branchmerge: False, force: True, partial: False
236 ancestor: 1db78bdd3bd6+, local: 1db78bdd3bd6+, remote: 15cbdf8ca3db
237 calling hook preupdate.eol: hgext.eol.preupdate
238 .hgeol: remote is newer -> g
239 getting .hgeol
240 filtering .hgeol through isbinary
241 a.txt: remote is newer -> g
242 getting a.txt
243 filtering a.txt through tolf
244 f: remote is newer -> g
245 getting f
246 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
247
248 $ touch .hgeol *
249 $ hg st --debug
250 eol: detected change in .hgeol
251 filtering .hgeol through isbinary
252 filtering a.txt through tolf
253 skip updating dirstate: identity mismatch (?)
254 $ hg diff
255
256 Things were clean, and updating again will not change anything:
257
258 $ touch .hgeol *
259 $ hg up -C -r 0 -v --debug
260 eol: detected change in .hgeol
261 filtering .hgeol through isbinary
262 filtering a.txt through tolf
263 resolving manifests
264 branchmerge: False, force: True, partial: False
265 ancestor: 15cbdf8ca3db+, local: 15cbdf8ca3db+, remote: 15cbdf8ca3db
266 calling hook preupdate.eol: hgext.eol.preupdate
267 starting 4 threads for background file closing (?)
268 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
269
270 $ touch .hgeol *
271 $ hg st --debug
272 eol: detected change in .hgeol
273 filtering .hgeol through isbinary
274 filtering a.txt through tolf
275 skip updating dirstate: identity mismatch (?)
276
277 $ cd ..
278
279 $ rm -r repo