##// END OF EJS Templates
tests: add a test demonstrate that 'revert -i' ignores nonexistent patterns...
Denis Laxalde -
r36211:a228b2f5 default
parent child Browse files
Show More
@@ -1,423 +1,436 b''
1 Revert interactive tests
1 Revert interactive tests
2 1 add and commit file f
2 1 add and commit file f
3 2 add commit file folder1/g
3 2 add commit file folder1/g
4 3 add and commit file folder2/h
4 3 add and commit file folder2/h
5 4 add and commit file folder1/i
5 4 add and commit file folder1/i
6 5 commit change to file f
6 5 commit change to file f
7 6 commit changes to files folder1/g folder2/h
7 6 commit changes to files folder1/g folder2/h
8 7 commit changes to files folder1/g folder2/h
8 7 commit changes to files folder1/g folder2/h
9 8 revert interactive to commit id 2 (line 3 above), check that folder1/i is removed and
9 8 revert interactive to commit id 2 (line 3 above), check that folder1/i is removed and
10 9 make workdir match 7
10 9 make workdir match 7
11 10 run the same test than 8 from within folder1 and check same expectations
11 10 run the same test than 8 from within folder1 and check same expectations
12
12
13 $ cat <<EOF >> $HGRCPATH
13 $ cat <<EOF >> $HGRCPATH
14 > [ui]
14 > [ui]
15 > interactive = true
15 > interactive = true
16 > [extensions]
16 > [extensions]
17 > record =
17 > record =
18 > purge =
18 > purge =
19 > EOF
19 > EOF
20
20
21
21
22 $ mkdir -p a/folder1 a/folder2
22 $ mkdir -p a/folder1 a/folder2
23 $ cd a
23 $ cd a
24 $ hg init
24 $ hg init
25 >>> open('f', 'wb').write("1\n2\n3\n4\n5\n")
25 >>> open('f', 'wb').write("1\n2\n3\n4\n5\n")
26 $ hg add f ; hg commit -m "adding f"
26 $ hg add f ; hg commit -m "adding f"
27 $ cat f > folder1/g ; hg add folder1/g ; hg commit -m "adding folder1/g"
27 $ cat f > folder1/g ; hg add folder1/g ; hg commit -m "adding folder1/g"
28 $ cat f > folder2/h ; hg add folder2/h ; hg commit -m "adding folder2/h"
28 $ cat f > folder2/h ; hg add folder2/h ; hg commit -m "adding folder2/h"
29 $ cat f > folder1/i ; hg add folder1/i ; hg commit -m "adding folder1/i"
29 $ cat f > folder1/i ; hg add folder1/i ; hg commit -m "adding folder1/i"
30 >>> open('f', 'wb').write("a\n1\n2\n3\n4\n5\nb\n")
30 >>> open('f', 'wb').write("a\n1\n2\n3\n4\n5\nb\n")
31 $ hg commit -m "modifying f"
31 $ hg commit -m "modifying f"
32 >>> open('folder1/g', 'wb').write("c\n1\n2\n3\n4\n5\nd\n")
32 >>> open('folder1/g', 'wb').write("c\n1\n2\n3\n4\n5\nd\n")
33 $ hg commit -m "modifying folder1/g"
33 $ hg commit -m "modifying folder1/g"
34 >>> open('folder2/h', 'wb').write("e\n1\n2\n3\n4\n5\nf\n")
34 >>> open('folder2/h', 'wb').write("e\n1\n2\n3\n4\n5\nf\n")
35 $ hg commit -m "modifying folder2/h"
35 $ hg commit -m "modifying folder2/h"
36 $ hg tip
36 $ hg tip
37 changeset: 6:59dd6e4ab63a
37 changeset: 6:59dd6e4ab63a
38 tag: tip
38 tag: tip
39 user: test
39 user: test
40 date: Thu Jan 01 00:00:00 1970 +0000
40 date: Thu Jan 01 00:00:00 1970 +0000
41 summary: modifying folder2/h
41 summary: modifying folder2/h
42
42
43 $ hg revert -i -r 2 --all -- << EOF
43 $ hg revert -i -r 2 --all -- << EOF
44 > y
44 > y
45 > y
45 > y
46 > y
46 > y
47 > y
47 > y
48 > y
48 > y
49 > ?
49 > ?
50 > y
50 > y
51 > n
51 > n
52 > n
52 > n
53 > EOF
53 > EOF
54 reverting f
54 reverting f
55 reverting folder1/g
55 reverting folder1/g
56 removing folder1/i
56 removing folder1/i
57 reverting folder2/h
57 reverting folder2/h
58 remove added file folder1/i (Yn)? y
58 remove added file folder1/i (Yn)? y
59 diff --git a/f b/f
59 diff --git a/f b/f
60 2 hunks, 2 lines changed
60 2 hunks, 2 lines changed
61 examine changes to 'f'? [Ynesfdaq?] y
61 examine changes to 'f'? [Ynesfdaq?] y
62
62
63 @@ -1,6 +1,5 @@
63 @@ -1,6 +1,5 @@
64 -a
64 -a
65 1
65 1
66 2
66 2
67 3
67 3
68 4
68 4
69 5
69 5
70 apply change 1/6 to 'f'? [Ynesfdaq?] y
70 apply change 1/6 to 'f'? [Ynesfdaq?] y
71
71
72 @@ -2,6 +1,5 @@
72 @@ -2,6 +1,5 @@
73 1
73 1
74 2
74 2
75 3
75 3
76 4
76 4
77 5
77 5
78 -b
78 -b
79 apply change 2/6 to 'f'? [Ynesfdaq?] y
79 apply change 2/6 to 'f'? [Ynesfdaq?] y
80
80
81 diff --git a/folder1/g b/folder1/g
81 diff --git a/folder1/g b/folder1/g
82 2 hunks, 2 lines changed
82 2 hunks, 2 lines changed
83 examine changes to 'folder1/g'? [Ynesfdaq?] y
83 examine changes to 'folder1/g'? [Ynesfdaq?] y
84
84
85 @@ -1,6 +1,5 @@
85 @@ -1,6 +1,5 @@
86 -c
86 -c
87 1
87 1
88 2
88 2
89 3
89 3
90 4
90 4
91 5
91 5
92 apply change 3/6 to 'folder1/g'? [Ynesfdaq?] ?
92 apply change 3/6 to 'folder1/g'? [Ynesfdaq?] ?
93
93
94 y - yes, apply this change
94 y - yes, apply this change
95 n - no, skip this change
95 n - no, skip this change
96 e - edit this change manually
96 e - edit this change manually
97 s - skip remaining changes to this file
97 s - skip remaining changes to this file
98 f - apply remaining changes to this file
98 f - apply remaining changes to this file
99 d - done, skip remaining changes and files
99 d - done, skip remaining changes and files
100 a - apply all changes to all remaining files
100 a - apply all changes to all remaining files
101 q - quit, applying no changes
101 q - quit, applying no changes
102 ? - ? (display help)
102 ? - ? (display help)
103 apply change 3/6 to 'folder1/g'? [Ynesfdaq?] y
103 apply change 3/6 to 'folder1/g'? [Ynesfdaq?] y
104
104
105 @@ -2,6 +1,5 @@
105 @@ -2,6 +1,5 @@
106 1
106 1
107 2
107 2
108 3
108 3
109 4
109 4
110 5
110 5
111 -d
111 -d
112 apply change 4/6 to 'folder1/g'? [Ynesfdaq?] n
112 apply change 4/6 to 'folder1/g'? [Ynesfdaq?] n
113
113
114 diff --git a/folder2/h b/folder2/h
114 diff --git a/folder2/h b/folder2/h
115 2 hunks, 2 lines changed
115 2 hunks, 2 lines changed
116 examine changes to 'folder2/h'? [Ynesfdaq?] n
116 examine changes to 'folder2/h'? [Ynesfdaq?] n
117
117
118 $ cat f
118 $ cat f
119 1
119 1
120 2
120 2
121 3
121 3
122 4
122 4
123 5
123 5
124 $ cat folder1/g
124 $ cat folder1/g
125 1
125 1
126 2
126 2
127 3
127 3
128 4
128 4
129 5
129 5
130 d
130 d
131 $ cat folder2/h
131 $ cat folder2/h
132 e
132 e
133 1
133 1
134 2
134 2
135 3
135 3
136 4
136 4
137 5
137 5
138 f
138 f
139
139
140 Test that --interactive lift the need for --all
140 Test that --interactive lift the need for --all
141
141
142 $ echo q | hg revert -i -r 2
142 $ echo q | hg revert -i -r 2
143 reverting folder1/g
143 reverting folder1/g
144 reverting folder2/h
144 reverting folder2/h
145 diff --git a/folder1/g b/folder1/g
145 diff --git a/folder1/g b/folder1/g
146 1 hunks, 1 lines changed
146 1 hunks, 1 lines changed
147 examine changes to 'folder1/g'? [Ynesfdaq?] q
147 examine changes to 'folder1/g'? [Ynesfdaq?] q
148
148
149 abort: user quit
149 abort: user quit
150 [255]
150 [255]
151 $ ls folder1/
151 $ ls folder1/
152 g
152 g
153
153
154 Test that a noop revert doesn't do an unnecessary backup
154 Test that a noop revert doesn't do an unnecessary backup
155 $ (echo y; echo n) | hg revert -i -r 2 folder1/g
155 $ (echo y; echo n) | hg revert -i -r 2 folder1/g
156 diff --git a/folder1/g b/folder1/g
156 diff --git a/folder1/g b/folder1/g
157 1 hunks, 1 lines changed
157 1 hunks, 1 lines changed
158 examine changes to 'folder1/g'? [Ynesfdaq?] y
158 examine changes to 'folder1/g'? [Ynesfdaq?] y
159
159
160 @@ -3,4 +3,3 @@
160 @@ -3,4 +3,3 @@
161 3
161 3
162 4
162 4
163 5
163 5
164 -d
164 -d
165 apply this change to 'folder1/g'? [Ynesfdaq?] n
165 apply this change to 'folder1/g'? [Ynesfdaq?] n
166
166
167 $ ls folder1/
167 $ ls folder1/
168 g
168 g
169
169
170 Test --no-backup
170 Test --no-backup
171 $ (echo y; echo y) | hg revert -i -C -r 2 folder1/g
171 $ (echo y; echo y) | hg revert -i -C -r 2 folder1/g
172 diff --git a/folder1/g b/folder1/g
172 diff --git a/folder1/g b/folder1/g
173 1 hunks, 1 lines changed
173 1 hunks, 1 lines changed
174 examine changes to 'folder1/g'? [Ynesfdaq?] y
174 examine changes to 'folder1/g'? [Ynesfdaq?] y
175
175
176 @@ -3,4 +3,3 @@
176 @@ -3,4 +3,3 @@
177 3
177 3
178 4
178 4
179 5
179 5
180 -d
180 -d
181 apply this change to 'folder1/g'? [Ynesfdaq?] y
181 apply this change to 'folder1/g'? [Ynesfdaq?] y
182
182
183 $ ls folder1/
183 $ ls folder1/
184 g
184 g
185 >>> open('folder1/g', 'wb').write("1\n2\n3\n4\n5\nd\n")
185 >>> open('folder1/g', 'wb').write("1\n2\n3\n4\n5\nd\n")
186
186
187
187
188 $ hg update -C 6
188 $ hg update -C 6
189 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
189 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
190 $ hg revert -i -r 2 --all -- << EOF
190 $ hg revert -i -r 2 --all -- << EOF
191 > n
191 > n
192 > y
192 > y
193 > y
193 > y
194 > y
194 > y
195 > y
195 > y
196 > y
196 > y
197 > n
197 > n
198 > n
198 > n
199 > EOF
199 > EOF
200 reverting f
200 reverting f
201 reverting folder1/g
201 reverting folder1/g
202 removing folder1/i
202 removing folder1/i
203 reverting folder2/h
203 reverting folder2/h
204 remove added file folder1/i (Yn)? n
204 remove added file folder1/i (Yn)? n
205 diff --git a/f b/f
205 diff --git a/f b/f
206 2 hunks, 2 lines changed
206 2 hunks, 2 lines changed
207 examine changes to 'f'? [Ynesfdaq?] y
207 examine changes to 'f'? [Ynesfdaq?] y
208
208
209 @@ -1,6 +1,5 @@
209 @@ -1,6 +1,5 @@
210 -a
210 -a
211 1
211 1
212 2
212 2
213 3
213 3
214 4
214 4
215 5
215 5
216 apply change 1/6 to 'f'? [Ynesfdaq?] y
216 apply change 1/6 to 'f'? [Ynesfdaq?] y
217
217
218 @@ -2,6 +1,5 @@
218 @@ -2,6 +1,5 @@
219 1
219 1
220 2
220 2
221 3
221 3
222 4
222 4
223 5
223 5
224 -b
224 -b
225 apply change 2/6 to 'f'? [Ynesfdaq?] y
225 apply change 2/6 to 'f'? [Ynesfdaq?] y
226
226
227 diff --git a/folder1/g b/folder1/g
227 diff --git a/folder1/g b/folder1/g
228 2 hunks, 2 lines changed
228 2 hunks, 2 lines changed
229 examine changes to 'folder1/g'? [Ynesfdaq?] y
229 examine changes to 'folder1/g'? [Ynesfdaq?] y
230
230
231 @@ -1,6 +1,5 @@
231 @@ -1,6 +1,5 @@
232 -c
232 -c
233 1
233 1
234 2
234 2
235 3
235 3
236 4
236 4
237 5
237 5
238 apply change 3/6 to 'folder1/g'? [Ynesfdaq?] y
238 apply change 3/6 to 'folder1/g'? [Ynesfdaq?] y
239
239
240 @@ -2,6 +1,5 @@
240 @@ -2,6 +1,5 @@
241 1
241 1
242 2
242 2
243 3
243 3
244 4
244 4
245 5
245 5
246 -d
246 -d
247 apply change 4/6 to 'folder1/g'? [Ynesfdaq?] n
247 apply change 4/6 to 'folder1/g'? [Ynesfdaq?] n
248
248
249 diff --git a/folder2/h b/folder2/h
249 diff --git a/folder2/h b/folder2/h
250 2 hunks, 2 lines changed
250 2 hunks, 2 lines changed
251 examine changes to 'folder2/h'? [Ynesfdaq?] n
251 examine changes to 'folder2/h'? [Ynesfdaq?] n
252
252
253 $ cat f
253 $ cat f
254 1
254 1
255 2
255 2
256 3
256 3
257 4
257 4
258 5
258 5
259 $ cat folder1/g
259 $ cat folder1/g
260 1
260 1
261 2
261 2
262 3
262 3
263 4
263 4
264 5
264 5
265 d
265 d
266 $ cat folder2/h
266 $ cat folder2/h
267 e
267 e
268 1
268 1
269 2
269 2
270 3
270 3
271 4
271 4
272 5
272 5
273 f
273 f
274 $ hg st
274 $ hg st
275 M f
275 M f
276 M folder1/g
276 M folder1/g
277 $ hg revert --interactive f << EOF
277 $ hg revert --interactive f << EOF
278 > y
278 > y
279 > ?
279 > ?
280 > y
280 > y
281 > n
281 > n
282 > n
282 > n
283 > EOF
283 > EOF
284 diff --git a/f b/f
284 diff --git a/f b/f
285 2 hunks, 2 lines changed
285 2 hunks, 2 lines changed
286 examine changes to 'f'? [Ynesfdaq?] y
286 examine changes to 'f'? [Ynesfdaq?] y
287
287
288 @@ -1,6 +1,5 @@
288 @@ -1,6 +1,5 @@
289 -a
289 -a
290 1
290 1
291 2
291 2
292 3
292 3
293 4
293 4
294 5
294 5
295 discard change 1/2 to 'f'? [Ynesfdaq?] ?
295 discard change 1/2 to 'f'? [Ynesfdaq?] ?
296
296
297 y - yes, discard this change
297 y - yes, discard this change
298 n - no, skip this change
298 n - no, skip this change
299 e - edit this change manually
299 e - edit this change manually
300 s - skip remaining changes to this file
300 s - skip remaining changes to this file
301 f - discard remaining changes to this file
301 f - discard remaining changes to this file
302 d - done, skip remaining changes and files
302 d - done, skip remaining changes and files
303 a - discard all changes to all remaining files
303 a - discard all changes to all remaining files
304 q - quit, discarding no changes
304 q - quit, discarding no changes
305 ? - ? (display help)
305 ? - ? (display help)
306 discard change 1/2 to 'f'? [Ynesfdaq?] y
306 discard change 1/2 to 'f'? [Ynesfdaq?] y
307
307
308 @@ -2,6 +1,5 @@
308 @@ -2,6 +1,5 @@
309 1
309 1
310 2
310 2
311 3
311 3
312 4
312 4
313 5
313 5
314 -b
314 -b
315 discard change 2/2 to 'f'? [Ynesfdaq?] n
315 discard change 2/2 to 'f'? [Ynesfdaq?] n
316
316
317 $ hg st
317 $ hg st
318 M f
318 M f
319 M folder1/g
319 M folder1/g
320 ? f.orig
320 ? f.orig
321 $ cat f
321 $ cat f
322 a
322 a
323 1
323 1
324 2
324 2
325 3
325 3
326 4
326 4
327 5
327 5
328 $ cat f.orig
328 $ cat f.orig
329 1
329 1
330 2
330 2
331 3
331 3
332 4
332 4
333 5
333 5
334 $ rm f.orig
334 $ rm f.orig
335 $ hg update -C .
335 $ hg update -C .
336 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
336 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
337
337
338 Check editing files newly added by a revert
338 Check editing files newly added by a revert
339
339
340 1) Create a dummy editor changing 1 to 42
340 1) Create a dummy editor changing 1 to 42
341 $ cat > $TESTTMP/editor.sh << '__EOF__'
341 $ cat > $TESTTMP/editor.sh << '__EOF__'
342 > cat "$1" | sed "s/1/42/g" > tt
342 > cat "$1" | sed "s/1/42/g" > tt
343 > mv tt "$1"
343 > mv tt "$1"
344 > __EOF__
344 > __EOF__
345
345
346 2) Add k
346 2) Add k
347 $ printf "1\n" > k
347 $ printf "1\n" > k
348 $ hg add k
348 $ hg add k
349 $ hg commit -m "add k"
349 $ hg commit -m "add k"
350
350
351 3) Use interactive revert with editing (replacing +1 with +42):
351 3) Use interactive revert with editing (replacing +1 with +42):
352 $ printf "0\n2\n" > k
352 $ printf "0\n2\n" > k
353 $ HGEDITOR="\"sh\" \"${TESTTMP}/editor.sh\"" hg revert -i <<EOF
353 $ HGEDITOR="\"sh\" \"${TESTTMP}/editor.sh\"" hg revert -i <<EOF
354 > y
354 > y
355 > e
355 > e
356 > EOF
356 > EOF
357 reverting k
357 reverting k
358 diff --git a/k b/k
358 diff --git a/k b/k
359 1 hunks, 2 lines changed
359 1 hunks, 2 lines changed
360 examine changes to 'k'? [Ynesfdaq?] y
360 examine changes to 'k'? [Ynesfdaq?] y
361
361
362 @@ -1,1 +1,2 @@
362 @@ -1,1 +1,2 @@
363 -1
363 -1
364 +0
364 +0
365 +2
365 +2
366 discard this change to 'k'? [Ynesfdaq?] e
366 discard this change to 'k'? [Ynesfdaq?] e
367
367
368 $ cat k
368 $ cat k
369 42
369 42
370
370
371 $ hg update -C .
371 $ hg update -C .
372 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
372 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
373 $ hg purge
373 $ hg purge
374 $ touch newfile
374 $ touch newfile
375 $ hg add newfile
375 $ hg add newfile
376 $ hg status
376 $ hg status
377 A newfile
377 A newfile
378 $ hg revert -i <<EOF
378 $ hg revert -i <<EOF
379 > n
379 > n
380 > EOF
380 > EOF
381 forgetting newfile
381 forgetting newfile
382 forget added file newfile (Yn)? n
382 forget added file newfile (Yn)? n
383 $ hg status
383 $ hg status
384 A newfile
384 A newfile
385 $ hg revert -i <<EOF
385 $ hg revert -i <<EOF
386 > y
386 > y
387 > EOF
387 > EOF
388 forgetting newfile
388 forgetting newfile
389 forget added file newfile (Yn)? y
389 forget added file newfile (Yn)? y
390 $ hg status
390 $ hg status
391 ? newfile
391 ? newfile
392
392
393 When a line without EOL is selected during "revert -i" (issue5651)
393 When a line without EOL is selected during "revert -i" (issue5651)
394
394
395 $ hg init $TESTTMP/revert-i-eol
395 $ hg init $TESTTMP/revert-i-eol
396 $ cd $TESTTMP/revert-i-eol
396 $ cd $TESTTMP/revert-i-eol
397 $ echo 0 > a
397 $ echo 0 > a
398 $ hg ci -qAm 0
398 $ hg ci -qAm 0
399 $ printf 1 >> a
399 $ printf 1 >> a
400 $ hg ci -qAm 1
400 $ hg ci -qAm 1
401 $ cat a
401 $ cat a
402 0
402 0
403 1 (no-eol)
403 1 (no-eol)
404
404
405 $ hg revert -ir'.^' <<EOF
405 $ hg revert -ir'.^' <<EOF
406 > y
406 > y
407 > y
407 > y
408 > EOF
408 > EOF
409 reverting a
409 reverting a
410 diff --git a/a b/a
410 diff --git a/a b/a
411 1 hunks, 1 lines changed
411 1 hunks, 1 lines changed
412 examine changes to 'a'? [Ynesfdaq?] y
412 examine changes to 'a'? [Ynesfdaq?] y
413
413
414 @@ -1,2 +1,1 @@
414 @@ -1,2 +1,1 @@
415 0
415 0
416 -1
416 -1
417 \ No newline at end of file
417 \ No newline at end of file
418 apply this change to 'a'? [Ynesfdaq?] y
418 apply this change to 'a'? [Ynesfdaq?] y
419
419
420 $ cat a
420 $ cat a
421 0
421 0
422
422
423 When specified pattern does not exist, we should exit early (issue5789).
424
425 $ hg files
426 a
427 $ hg rev b
428 b: no such file in rev b40d1912accf
429 $ hg rev -i b
430 b: no such file in rev b40d1912accf
431 diff --git a/a b/a
432 1 hunks, 1 lines changed
433 examine changes to 'a'? [Ynesfdaq?] abort: response expected
434 [255]
435
423 $ cd ..
436 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now