##// END OF EJS Templates
revert: change a test to make the change of direction of revert -i easier...
Laurent Charignon -
r25656:88d244f4 default
parent child Browse files
Show More
@@ -1,393 +1,379 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 > EOF
18 > EOF
19
19
20
20
21 $ mkdir -p a/folder1 a/folder2
21 $ mkdir -p a/folder1 a/folder2
22 $ cd a
22 $ cd a
23 $ hg init
23 $ hg init
24 >>> open('f', 'wb').write("1\n2\n3\n4\n5\n")
24 >>> open('f', 'wb').write("1\n2\n3\n4\n5\n")
25 $ hg add f ; hg commit -m "adding f"
25 $ hg add f ; hg commit -m "adding f"
26 $ cat f > folder1/g ; hg add folder1/g ; hg commit -m "adding folder1/g"
26 $ cat f > folder1/g ; hg add folder1/g ; hg commit -m "adding folder1/g"
27 $ cat f > folder2/h ; hg add folder2/h ; hg commit -m "adding folder2/h"
27 $ cat f > folder2/h ; hg add folder2/h ; hg commit -m "adding folder2/h"
28 $ cat f > folder1/i ; hg add folder1/i ; hg commit -m "adding folder1/i"
28 $ cat f > folder1/i ; hg add folder1/i ; hg commit -m "adding folder1/i"
29 >>> open('f', 'wb').write("a\n1\n2\n3\n4\n5\nb\n")
29 >>> open('f', 'wb').write("a\n1\n2\n3\n4\n5\nb\n")
30 $ hg commit -m "modifying f"
30 $ hg commit -m "modifying f"
31 >>> open('folder1/g', 'wb').write("c\n1\n2\n3\n4\n5\nd\n")
31 >>> open('folder1/g', 'wb').write("c\n1\n2\n3\n4\n5\nd\n")
32 $ hg commit -m "modifying folder1/g"
32 $ hg commit -m "modifying folder1/g"
33 >>> open('folder2/h', 'wb').write("e\n1\n2\n3\n4\n5\nf\n")
33 >>> open('folder2/h', 'wb').write("e\n1\n2\n3\n4\n5\nf\n")
34 $ hg commit -m "modifying folder2/h"
34 $ hg commit -m "modifying folder2/h"
35 $ hg tip
35 $ hg tip
36 changeset: 6:59dd6e4ab63a
36 changeset: 6:59dd6e4ab63a
37 tag: tip
37 tag: tip
38 user: test
38 user: test
39 date: Thu Jan 01 00:00:00 1970 +0000
39 date: Thu Jan 01 00:00:00 1970 +0000
40 summary: modifying folder2/h
40 summary: modifying folder2/h
41
41
42 $ hg revert -i -r 2 --all -- << EOF
42 $ hg revert -i -r 2 --all -- << EOF
43 > y
43 > y
44 > y
44 > y
45 > y
45 > y
46 > y
46 > y
47 > y
47 > y
48 > n
48 > n
49 > n
49 > n
50 > EOF
50 > EOF
51 reverting f
51 reverting f
52 reverting folder1/g (glob)
52 reverting folder1/g (glob)
53 removing folder1/i (glob)
53 removing folder1/i (glob)
54 reverting folder2/h (glob)
54 reverting folder2/h (glob)
55 diff --git a/f b/f
55 diff --git a/f b/f
56 2 hunks, 2 lines changed
56 2 hunks, 2 lines changed
57 examine changes to 'f'? [Ynesfdaq?] y
57 examine changes to 'f'? [Ynesfdaq?] y
58
58
59 @@ -1,6 +1,5 @@
59 @@ -1,6 +1,5 @@
60 -a
60 -a
61 1
61 1
62 2
62 2
63 3
63 3
64 4
64 4
65 5
65 5
66 record change 1/6 to 'f'? [Ynesfdaq?] y
66 record change 1/6 to 'f'? [Ynesfdaq?] y
67
67
68 @@ -2,6 +1,5 @@
68 @@ -2,6 +1,5 @@
69 1
69 1
70 2
70 2
71 3
71 3
72 4
72 4
73 5
73 5
74 -b
74 -b
75 record change 2/6 to 'f'? [Ynesfdaq?] y
75 record change 2/6 to 'f'? [Ynesfdaq?] y
76
76
77 diff --git a/folder1/g b/folder1/g
77 diff --git a/folder1/g b/folder1/g
78 2 hunks, 2 lines changed
78 2 hunks, 2 lines changed
79 examine changes to 'folder1/g'? [Ynesfdaq?] y
79 examine changes to 'folder1/g'? [Ynesfdaq?] y
80
80
81 @@ -1,6 +1,5 @@
81 @@ -1,6 +1,5 @@
82 -c
82 -c
83 1
83 1
84 2
84 2
85 3
85 3
86 4
86 4
87 5
87 5
88 record change 3/6 to 'folder1/g'? [Ynesfdaq?] y
88 record change 3/6 to 'folder1/g'? [Ynesfdaq?] y
89
89
90 @@ -2,6 +1,5 @@
90 @@ -2,6 +1,5 @@
91 1
91 1
92 2
92 2
93 3
93 3
94 4
94 4
95 5
95 5
96 -d
96 -d
97 record change 4/6 to 'folder1/g'? [Ynesfdaq?] n
97 record change 4/6 to 'folder1/g'? [Ynesfdaq?] n
98
98
99 diff --git a/folder2/h b/folder2/h
99 diff --git a/folder2/h b/folder2/h
100 2 hunks, 2 lines changed
100 2 hunks, 2 lines changed
101 examine changes to 'folder2/h'? [Ynesfdaq?] n
101 examine changes to 'folder2/h'? [Ynesfdaq?] n
102
102
103 $ cat f
103 $ cat f
104 1
104 1
105 2
105 2
106 3
106 3
107 4
107 4
108 5
108 5
109 $ cat folder1/g
109 $ cat folder1/g
110 1
110 1
111 2
111 2
112 3
112 3
113 4
113 4
114 5
114 5
115 d
115 d
116 $ cat folder2/h
116 $ cat folder2/h
117 e
117 e
118 1
118 1
119 2
119 2
120 3
120 3
121 4
121 4
122 5
122 5
123 f
123 f
124
124
125 Test that --interactive lift the need for --all
125 Test that --interactive lift the need for --all
126
126
127 $ echo q | hg revert -i -r 2
127 $ echo q | hg revert -i -r 2
128 reverting folder1/g (glob)
128 reverting folder1/g (glob)
129 reverting folder2/h (glob)
129 reverting folder2/h (glob)
130 diff --git a/folder1/g b/folder1/g
130 diff --git a/folder1/g b/folder1/g
131 1 hunks, 1 lines changed
131 1 hunks, 1 lines changed
132 examine changes to 'folder1/g'? [Ynesfdaq?] q
132 examine changes to 'folder1/g'? [Ynesfdaq?] q
133
133
134 abort: user quit
134 abort: user quit
135 [255]
135 [255]
136 $ rm folder1/g.orig
136 $ rm folder1/g.orig
137
137
138
138
139 $ hg update -C 6
139 $ hg update -C 6
140 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
140 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
141 $ hg revert -i -r 2 --all -- << EOF
141 $ hg revert -i -r 2 --all -- << EOF
142 > y
142 > y
143 > y
143 > y
144 > y
144 > y
145 > y
145 > y
146 > y
146 > y
147 > n
147 > n
148 > n
148 > n
149 > EOF
149 > EOF
150 reverting f
150 reverting f
151 reverting folder1/g (glob)
151 reverting folder1/g (glob)
152 removing folder1/i (glob)
152 removing folder1/i (glob)
153 reverting folder2/h (glob)
153 reverting folder2/h (glob)
154 diff --git a/f b/f
154 diff --git a/f b/f
155 2 hunks, 2 lines changed
155 2 hunks, 2 lines changed
156 examine changes to 'f'? [Ynesfdaq?] y
156 examine changes to 'f'? [Ynesfdaq?] y
157
157
158 @@ -1,6 +1,5 @@
158 @@ -1,6 +1,5 @@
159 -a
159 -a
160 1
160 1
161 2
161 2
162 3
162 3
163 4
163 4
164 5
164 5
165 record change 1/6 to 'f'? [Ynesfdaq?] y
165 record change 1/6 to 'f'? [Ynesfdaq?] y
166
166
167 @@ -2,6 +1,5 @@
167 @@ -2,6 +1,5 @@
168 1
168 1
169 2
169 2
170 3
170 3
171 4
171 4
172 5
172 5
173 -b
173 -b
174 record change 2/6 to 'f'? [Ynesfdaq?] y
174 record change 2/6 to 'f'? [Ynesfdaq?] y
175
175
176 diff --git a/folder1/g b/folder1/g
176 diff --git a/folder1/g b/folder1/g
177 2 hunks, 2 lines changed
177 2 hunks, 2 lines changed
178 examine changes to 'folder1/g'? [Ynesfdaq?] y
178 examine changes to 'folder1/g'? [Ynesfdaq?] y
179
179
180 @@ -1,6 +1,5 @@
180 @@ -1,6 +1,5 @@
181 -c
181 -c
182 1
182 1
183 2
183 2
184 3
184 3
185 4
185 4
186 5
186 5
187 record change 3/6 to 'folder1/g'? [Ynesfdaq?] y
187 record change 3/6 to 'folder1/g'? [Ynesfdaq?] y
188
188
189 @@ -2,6 +1,5 @@
189 @@ -2,6 +1,5 @@
190 1
190 1
191 2
191 2
192 3
192 3
193 4
193 4
194 5
194 5
195 -d
195 -d
196 record change 4/6 to 'folder1/g'? [Ynesfdaq?] n
196 record change 4/6 to 'folder1/g'? [Ynesfdaq?] n
197
197
198 diff --git a/folder2/h b/folder2/h
198 diff --git a/folder2/h b/folder2/h
199 2 hunks, 2 lines changed
199 2 hunks, 2 lines changed
200 examine changes to 'folder2/h'? [Ynesfdaq?] n
200 examine changes to 'folder2/h'? [Ynesfdaq?] n
201
201
202 $ cat f
202 $ cat f
203 1
203 1
204 2
204 2
205 3
205 3
206 4
206 4
207 5
207 5
208 $ cat folder1/g
208 $ cat folder1/g
209 1
209 1
210 2
210 2
211 3
211 3
212 4
212 4
213 5
213 5
214 d
214 d
215 $ cat folder2/h
215 $ cat folder2/h
216 e
216 e
217 1
217 1
218 2
218 2
219 3
219 3
220 4
220 4
221 5
221 5
222 f
222 f
223 $ hg st
223 $ hg st
224 M f
224 M f
225 M folder1/g
225 M folder1/g
226 R folder1/i
226 R folder1/i
227 $ hg revert --interactive f << EOF
227 $ hg revert --interactive f << EOF
228 > y
228 > y
229 > y
229 > y
230 > n
230 > n
231 > n
231 > n
232 > EOF
232 > EOF
233 diff --git a/f b/f
233 diff --git a/f b/f
234 2 hunks, 2 lines changed
234 2 hunks, 2 lines changed
235 examine changes to 'f'? [Ynesfdaq?] y
235 examine changes to 'f'? [Ynesfdaq?] y
236
236
237 @@ -1,5 +1,6 @@
237 @@ -1,5 +1,6 @@
238 +a
238 +a
239 1
239 1
240 2
240 2
241 3
241 3
242 4
242 4
243 5
243 5
244 record change 1/2 to 'f'? [Ynesfdaq?] y
244 record change 1/2 to 'f'? [Ynesfdaq?] y
245
245
246 @@ -1,5 +2,6 @@
246 @@ -1,5 +2,6 @@
247 1
247 1
248 2
248 2
249 3
249 3
250 4
250 4
251 5
251 5
252 +b
252 +b
253 record change 2/2 to 'f'? [Ynesfdaq?] n
253 record change 2/2 to 'f'? [Ynesfdaq?] n
254
254
255 $ hg st
255 $ hg st
256 M f
256 M f
257 M folder1/g
257 M folder1/g
258 R folder1/i
258 R folder1/i
259 ? f.orig
259 ? f.orig
260 $ cat f
260 $ cat f
261 a
261 a
262 1
262 1
263 2
263 2
264 3
264 3
265 4
265 4
266 5
266 5
267 $ cat f.orig
267 $ cat f.orig
268 1
268 1
269 2
269 2
270 3
270 3
271 4
271 4
272 5
272 5
273 $ rm f.orig
273 $ rm f.orig
274 $ hg update -C .
274 $ hg update -C .
275 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
275 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
276
276
277 Check editing files newly added by a revert
277 Check editing files newly added by a revert
278
278
279 1) Create a dummy editor changing 1 to 42
279 1) Create a dummy editor changing 1 to 42
280 $ cat > $TESTTMP/editor.sh << '__EOF__'
280 $ cat > $TESTTMP/editor.sh << '__EOF__'
281 > cat "$1" | sed "s/1/42/g" > tt
281 > cat "$1" | sed "s/1/42/g" > tt
282 > mv tt "$1"
282 > mv tt "$1"
283 > __EOF__
283 > __EOF__
284
284
285 2) Remove f
285 2) Add k
286 $ hg rm f
286 $ printf "1\n" > k
287 $ hg commit -m "remove f"
287 $ hg add k
288 $ hg commit -m "add k"
288
289
289 3) Do another commit on top
290 3) Use interactive revert with editing (replacing +1 with +42):
290 $ touch k; hg add k
291 $ printf "0\n2\n" > k
291 $ hg commit -m "add k"
292 $ HGEDITOR="\"sh\" \"${TESTTMP}/editor.sh\"" hg revert -i <<EOF
292 $ hg st
293
294 4) Use interactive revert to recover f and change it on the fly
295 $ HGEDITOR="\"sh\" \"${TESTTMP}/editor.sh\"" hg revert -i -r ".^^" <<EOF
296 > y
293 > y
297 > e
294 > e
298 > EOF
295 > EOF
299 adding f
296 reverting k
300 removing k
297 diff --git a/k b/k
301 diff --git a/f b/f
298 1 hunks, 2 lines changed
302 new file mode 100644
299 examine changes to 'k'? [Ynesfdaq?] y
303 examine changes to 'f'? [Ynesfdaq?] y
304
300
305 @@ -0,0 +1,7 @@
301 @@ -1,2 +1,1 @@
306 +a
302 -0
303 -2
307 +1
304 +1
308 +2
305 record this change to 'k'? [Ynesfdaq?] e
309 +3
310 +4
311 +5
312 +b
313 record this change to 'f'? [Ynesfdaq?] e
314
306
315 $ cat f
307 $ cat k
316 a
317 42
308 42
318 2
319 3
320 4
321 5
322 b
323
309
324 Check the experimental config to invert the selection:
310 Check the experimental config to invert the selection:
325 $ cat <<EOF >> $HGRCPATH
311 $ cat <<EOF >> $HGRCPATH
326 > [experimental]
312 > [experimental]
327 > revertalternateinteractivemode=True
313 > revertalternateinteractivemode=True
328 > EOF
314 > EOF
329
315
330
316
331 $ hg up -C .
317 $ hg up -C .
332 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
318 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
333 $ printf 'firstline\nc\n1\n2\n3\n 3\n5\nd\nlastline\n' > folder1/g
319 $ printf 'firstline\nc\n1\n2\n3\n 3\n5\nd\nlastline\n' > folder1/g
334 $ hg diff --nodates
320 $ hg diff --nodates
335 diff -r 5a858e056dc0 folder1/g
321 diff -r a3d963a027aa folder1/g
336 --- a/folder1/g
322 --- a/folder1/g
337 +++ b/folder1/g
323 +++ b/folder1/g
338 @@ -1,7 +1,9 @@
324 @@ -1,7 +1,9 @@
339 +firstline
325 +firstline
340 c
326 c
341 1
327 1
342 2
328 2
343 3
329 3
344 -4
330 -4
345 + 3
331 + 3
346 5
332 5
347 d
333 d
348 +lastline
334 +lastline
349 $ hg revert -i <<EOF
335 $ hg revert -i <<EOF
350 > y
336 > y
351 > y
337 > y
352 > y
338 > y
353 > n
339 > n
354 > EOF
340 > EOF
355 reverting folder1/g (glob)
341 reverting folder1/g (glob)
356 diff --git a/folder1/g b/folder1/g
342 diff --git a/folder1/g b/folder1/g
357 3 hunks, 3 lines changed
343 3 hunks, 3 lines changed
358 examine changes to 'folder1/g'? [Ynesfdaq?] y
344 examine changes to 'folder1/g'? [Ynesfdaq?] y
359
345
360 @@ -1,4 +1,5 @@
346 @@ -1,4 +1,5 @@
361 +firstline
347 +firstline
362 c
348 c
363 1
349 1
364 2
350 2
365 3
351 3
366 record change 1/3 to 'folder1/g'? [Ynesfdaq?] y
352 record change 1/3 to 'folder1/g'? [Ynesfdaq?] y
367
353
368 @@ -1,7 +2,7 @@
354 @@ -1,7 +2,7 @@
369 c
355 c
370 1
356 1
371 2
357 2
372 3
358 3
373 -4
359 -4
374 + 3
360 + 3
375 5
361 5
376 d
362 d
377 record change 2/3 to 'folder1/g'? [Ynesfdaq?] y
363 record change 2/3 to 'folder1/g'? [Ynesfdaq?] y
378
364
379 @@ -6,2 +7,3 @@
365 @@ -6,2 +7,3 @@
380 5
366 5
381 d
367 d
382 +lastline
368 +lastline
383 record change 3/3 to 'folder1/g'? [Ynesfdaq?] n
369 record change 3/3 to 'folder1/g'? [Ynesfdaq?] n
384
370
385 $ hg diff --nodates
371 $ hg diff --nodates
386 diff -r 5a858e056dc0 folder1/g
372 diff -r a3d963a027aa folder1/g
387 --- a/folder1/g
373 --- a/folder1/g
388 +++ b/folder1/g
374 +++ b/folder1/g
389 @@ -5,3 +5,4 @@
375 @@ -5,3 +5,4 @@
390 4
376 4
391 5
377 5
392 d
378 d
393 +lastline
379 +lastline
General Comments 0
You need to be logged in to leave comments. Login now