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