##// END OF EJS Templates
py3: use sys.stdout instead of print in test-mq-qpush-fail.t...
Pulkit Goyal -
r37542:5d81f1b7 default
parent child Browse files
Show More
@@ -1,471 +1,471 b''
1 1 Test that qpush cleans things up if it doesn't complete
2 2
3 3 $ echo "[extensions]" >> $HGRCPATH
4 4 $ echo "mq=" >> $HGRCPATH
5 5 $ hg init repo
6 6 $ cd repo
7 7 $ echo foo > foo
8 8 $ hg ci -Am 'add foo'
9 9 adding foo
10 10 $ touch untracked-file
11 11 $ echo 'syntax: glob' > .hgignore
12 12 $ echo '.hgignore' >> .hgignore
13 13 $ hg qinit
14 14
15 15 test qpush on empty series
16 16
17 17 $ hg qpush
18 18 no patches in series
19 19 $ hg qnew patch1
20 20 $ echo >> foo
21 21 $ hg qrefresh -m 'patch 1'
22 22 $ hg qnew patch2
23 23 $ echo bar > bar
24 24 $ hg add bar
25 25 $ hg qrefresh -m 'patch 2'
26 26 $ hg qnew --config 'mq.plain=true' -U bad-patch
27 27 $ echo >> foo
28 28 $ hg qrefresh
29 29 $ hg qpop -a
30 30 popping bad-patch
31 31 popping patch2
32 32 popping patch1
33 33 patch queue now empty
34 $ $PYTHON -c 'print "\xe9"' > message
34 $ $PYTHON -c 'import sys; getattr(sys.stdout, "buffer", sys.stdout).write(b"\xe9\n")' > message
35 35 $ cat .hg/patches/bad-patch >> message
36 36 $ mv message .hg/patches/bad-patch
37 37 $ cat > $TESTTMP/wrapplayback.py <<EOF
38 38 > import os
39 39 > from mercurial import extensions, transaction
40 40 > def wrapplayback(orig,
41 41 > journal, report, opener, vfsmap, entries, backupentries,
42 42 > unlink=True, checkambigfiles=None):
43 43 > orig(journal, report, opener, vfsmap, entries, backupentries, unlink,
44 44 > checkambigfiles)
45 45 > # Touching files truncated at "transaction.abort" causes
46 46 > # forcible re-loading invalidated filecache properties
47 47 > # (including repo.changelog)
48 48 > for f, o, _ignore in entries:
49 49 > if o or not unlink:
50 50 > os.utime(opener.join(f), (0.0, 0.0))
51 51 > def extsetup(ui):
52 52 > extensions.wrapfunction(transaction, '_playback', wrapplayback)
53 53 > EOF
54 54 $ hg qpush -a --config extensions.wrapplayback=$TESTTMP/wrapplayback.py && echo 'qpush succeeded?!'
55 55 applying patch1
56 56 applying patch2
57 57 applying bad-patch
58 58 transaction abort!
59 59 rollback completed
60 60 cleaning up working directory...
61 61 reverting foo
62 62 done
63 63 abort: decoding near '\xe9': 'ascii' codec can't decode byte 0xe9 in position 0: ordinal not in range(128)! (esc)
64 64 [255]
65 65 $ hg parents
66 66 changeset: 0:bbd179dfa0a7
67 67 tag: tip
68 68 user: test
69 69 date: Thu Jan 01 00:00:00 1970 +0000
70 70 summary: add foo
71 71
72 72
73 73 test corrupt status file
74 74 $ hg qpush
75 75 applying patch1
76 76 now at: patch1
77 77 $ cp .hg/patches/status .hg/patches/status.orig
78 78 $ hg qpop
79 79 popping patch1
80 80 patch queue now empty
81 81 $ cp .hg/patches/status.orig .hg/patches/status
82 82 $ hg qpush
83 83 abort: working directory revision is not qtip
84 84 [255]
85 85 $ rm .hg/patches/status .hg/patches/status.orig
86 86
87 87
88 88 bar should be gone; other unknown/ignored files should still be around
89 89
90 90 $ hg status -A
91 91 ? untracked-file
92 92 I .hgignore
93 93 C foo
94 94
95 95 preparing qpush of a missing patch
96 96
97 97 $ hg qpop -a
98 98 no patches applied
99 99 $ hg qpush
100 100 applying patch1
101 101 now at: patch1
102 102 $ rm .hg/patches/patch2
103 103
104 104 now we expect the push to fail, but it should NOT complain about patch1
105 105
106 106 $ hg qpush
107 107 applying patch2
108 108 unable to read patch2
109 109 now at: patch1
110 110 [1]
111 111
112 112 preparing qpush of missing patch with no patch applied
113 113
114 114 $ hg qpop -a
115 115 popping patch1
116 116 patch queue now empty
117 117 $ rm .hg/patches/patch1
118 118
119 119 qpush should fail the same way as below
120 120
121 121 $ hg qpush
122 122 applying patch1
123 123 unable to read patch1
124 124 [1]
125 125
126 126 Test qpush to a patch below the currently applied patch.
127 127
128 128 $ hg qq -c guardedseriesorder
129 129 $ hg qnew a
130 130 $ hg qguard +block
131 131 $ hg qnew b
132 132 $ hg qnew c
133 133
134 134 $ hg qpop -a
135 135 popping c
136 136 popping b
137 137 popping a
138 138 patch queue now empty
139 139
140 140 try to push and pop while a is guarded
141 141
142 142 $ hg qpush a
143 143 cannot push 'a' - guarded by '+block'
144 144 [1]
145 145 $ hg qpush -a
146 146 applying b
147 147 patch b is empty
148 148 applying c
149 149 patch c is empty
150 150 now at: c
151 151
152 152 now try it when a is unguarded, and we're at the top of the queue
153 153
154 154 $ hg qapplied -v
155 155 0 G a
156 156 1 A b
157 157 2 A c
158 158 $ hg qsel block
159 159 $ hg qpush b
160 160 abort: cannot push to a previous patch: b
161 161 [255]
162 162 $ hg qpush a
163 163 abort: cannot push to a previous patch: a
164 164 [255]
165 165
166 166 and now we try it one more time with a unguarded, while we're not at the top of the queue
167 167
168 168 $ hg qpop b
169 169 popping c
170 170 now at: b
171 171 $ hg qpush a
172 172 abort: cannot push to a previous patch: a
173 173 [255]
174 174
175 175 test qpop --force and backup files
176 176
177 177 $ hg qpop -a
178 178 popping b
179 179 patch queue now empty
180 180 $ hg qq --create force
181 181 $ echo a > a
182 182 $ echo b > b
183 183 $ echo c > c
184 184 $ hg ci -Am add a b c
185 185 $ echo a >> a
186 186 $ hg rm b
187 187 $ hg rm c
188 188 $ hg qnew p1
189 189 $ echo a >> a
190 190 $ echo bb > b
191 191 $ hg add b
192 192 $ echo cc > c
193 193 $ hg add c
194 194 $ hg qpop --force --verbose
195 195 saving current version of a as a.orig
196 196 saving current version of b as b.orig
197 197 saving current version of c as c.orig
198 198 popping p1
199 199 patch queue now empty
200 200 $ hg st
201 201 ? a.orig
202 202 ? b.orig
203 203 ? c.orig
204 204 ? untracked-file
205 205 $ cat a.orig
206 206 a
207 207 a
208 208 a
209 209 $ cat b.orig
210 210 bb
211 211 $ cat c.orig
212 212 cc
213 213
214 214 test qpop --force --no-backup
215 215
216 216 $ hg qpush
217 217 applying p1
218 218 now at: p1
219 219 $ rm a.orig
220 220 $ echo a >> a
221 221 $ hg qpop --force --no-backup --verbose
222 222 popping p1
223 223 patch queue now empty
224 224 $ test -f a.orig && echo 'error: backup with --no-backup'
225 225 [1]
226 226
227 227 test qpop --keep-changes
228 228
229 229 $ hg qpush
230 230 applying p1
231 231 now at: p1
232 232 $ hg qpop --keep-changes --force
233 233 abort: cannot use both --force and --keep-changes
234 234 [255]
235 235 $ echo a >> a
236 236 $ hg qpop --keep-changes
237 237 abort: local changes found, qrefresh first
238 238 [255]
239 239 $ hg revert -qa a
240 240 $ rm a
241 241 $ hg qpop --keep-changes
242 242 abort: local changes found, qrefresh first
243 243 [255]
244 244 $ hg rm -A a
245 245 $ hg qpop --keep-changes
246 246 abort: local changes found, qrefresh first
247 247 [255]
248 248 $ hg revert -qa a
249 249 $ echo b > b
250 250 $ hg add b
251 251 $ hg qpop --keep-changes
252 252 abort: local changes found, qrefresh first
253 253 [255]
254 254 $ hg forget b
255 255 $ echo d > d
256 256 $ hg add d
257 257 $ hg qpop --keep-changes
258 258 popping p1
259 259 patch queue now empty
260 260 $ hg forget d
261 261 $ rm d
262 262
263 263 test qpush --force and backup files
264 264
265 265 $ echo a >> a
266 266 $ hg qnew p2
267 267 $ echo b >> b
268 268 $ echo d > d
269 269 $ echo e > e
270 270 $ hg add d e
271 271 $ hg rm c
272 272 $ hg qnew p3
273 273 $ hg qpop -a
274 274 popping p3
275 275 popping p2
276 276 patch queue now empty
277 277 $ echo a >> a
278 278 $ echo b1 >> b
279 279 $ echo d1 > d
280 280 $ hg add d
281 281 $ echo e1 > e
282 282 $ hg qpush -a --force --verbose
283 283 applying p2
284 284 saving current version of a as a.orig
285 285 patching file a
286 286 committing files:
287 287 a
288 288 committing manifest
289 289 committing changelog
290 290 applying p3
291 291 saving current version of b as b.orig
292 292 saving current version of d as d.orig
293 293 patching file b
294 294 patching file c
295 295 patching file d
296 296 file d already exists
297 297 1 out of 1 hunks FAILED -- saving rejects to file d.rej
298 298 patching file e
299 299 file e already exists
300 300 1 out of 1 hunks FAILED -- saving rejects to file e.rej
301 301 patch failed to apply
302 302 committing files:
303 303 b
304 304 committing manifest
305 305 committing changelog
306 306 patch failed, rejects left in working directory
307 307 errors during apply, please fix and qrefresh p3
308 308 [2]
309 309 $ cat a.orig
310 310 a
311 311 a
312 312 $ cat b.orig
313 313 b
314 314 b1
315 315 $ cat d.orig
316 316 d1
317 317
318 318 test qpush --force --no-backup
319 319
320 320 $ hg revert -qa
321 321 $ hg qpop -a
322 322 popping p3
323 323 popping p2
324 324 patch queue now empty
325 325 $ echo a >> a
326 326 $ rm a.orig
327 327 $ hg qpush --force --no-backup --verbose
328 328 applying p2
329 329 patching file a
330 330 committing files:
331 331 a
332 332 committing manifest
333 333 committing changelog
334 334 now at: p2
335 335 $ test -f a.orig && echo 'error: backup with --no-backup'
336 336 [1]
337 337
338 338 test qgoto --force --no-backup
339 339
340 340 $ hg qpop
341 341 popping p2
342 342 patch queue now empty
343 343 $ echo a >> a
344 344 $ hg qgoto --force --no-backup p2 --verbose
345 345 applying p2
346 346 patching file a
347 347 committing files:
348 348 a
349 349 committing manifest
350 350 committing changelog
351 351 now at: p2
352 352 $ test -f a.orig && echo 'error: backup with --no-backup'
353 353 [1]
354 354
355 355 test qpush --keep-changes
356 356
357 357 $ hg qpush --keep-changes --force
358 358 abort: cannot use both --force and --keep-changes
359 359 [255]
360 360 $ hg qpush --keep-changes --exact
361 361 abort: cannot use --exact and --keep-changes together
362 362 [255]
363 363 $ echo b >> b
364 364 $ hg qpush --keep-changes
365 365 applying p3
366 366 abort: conflicting local changes found
367 367 (did you forget to qrefresh?)
368 368 [255]
369 369 $ rm b
370 370 $ hg qpush --keep-changes
371 371 applying p3
372 372 abort: conflicting local changes found
373 373 (did you forget to qrefresh?)
374 374 [255]
375 375 $ hg rm -A b
376 376 $ hg qpush --keep-changes
377 377 applying p3
378 378 abort: conflicting local changes found
379 379 (did you forget to qrefresh?)
380 380 [255]
381 381 $ hg revert -aq b
382 382 $ echo d > d
383 383 $ hg add d
384 384 $ hg qpush --keep-changes
385 385 applying p3
386 386 abort: conflicting local changes found
387 387 (did you forget to qrefresh?)
388 388 [255]
389 389 $ hg forget d
390 390 $ rm d
391 391 $ hg qpop
392 392 popping p2
393 393 patch queue now empty
394 394 $ echo b >> b
395 395 $ hg qpush -a --keep-changes
396 396 applying p2
397 397 applying p3
398 398 abort: conflicting local changes found
399 399 (did you forget to qrefresh?)
400 400 [255]
401 401 $ hg qtop
402 402 p2
403 403 $ hg parents --template "{rev} {desc}\n"
404 404 2 imported patch p2
405 405 $ hg st b
406 406 M b
407 407 $ cat b
408 408 b
409 409 b
410 410
411 411 test qgoto --keep-changes
412 412
413 413 $ hg revert -aq b
414 414 $ rm e
415 415 $ hg qgoto --keep-changes --force p3
416 416 abort: cannot use both --force and --keep-changes
417 417 [255]
418 418 $ echo a >> a
419 419 $ hg qgoto --keep-changes p3
420 420 applying p3
421 421 now at: p3
422 422 $ hg st a
423 423 M a
424 424 $ hg qgoto --keep-changes p2
425 425 popping p3
426 426 now at: p2
427 427 $ hg st a
428 428 M a
429 429
430 430 test mq.keepchanges setting
431 431
432 432 $ hg --config mq.keepchanges=1 qpush
433 433 applying p3
434 434 now at: p3
435 435 $ hg st a
436 436 M a
437 437 $ hg --config mq.keepchanges=1 qpop
438 438 popping p3
439 439 now at: p2
440 440 $ hg st a
441 441 M a
442 442 $ hg --config mq.keepchanges=1 qgoto p3
443 443 applying p3
444 444 now at: p3
445 445 $ hg st a
446 446 M a
447 447 $ echo b >> b
448 448 $ hg --config mq.keepchanges=1 qpop --force --config 'ui.origbackuppath=.hg/origbackups'
449 449 popping p3
450 450 now at: p2
451 451 $ hg st b
452 452 $ hg --config mq.keepchanges=1 qpush --exact
453 453 abort: local changes found, qrefresh first
454 454 [255]
455 455 $ hg revert -qa a
456 456 $ hg qpop
457 457 popping p2
458 458 patch queue now empty
459 459 $ echo a >> a
460 460 $ hg --config mq.keepchanges=1 qpush --force
461 461 applying p2
462 462 now at: p2
463 463 $ hg st a
464 464
465 465 test previous qpop (with --force and --config) saved .orig files to where user
466 466 wants them
467 467 $ ls .hg/origbackups
468 468 b
469 469 $ rm -rf .hg/origbackups
470 470
471 471 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now