##// END OF EJS Templates
tests: use full `uncommit` command name in tests...
Martin von Zweigbergk -
r44694:5323cdb8 default
parent child Browse files
Show More
@@ -1,595 +1,595 b''
1 1 Test uncommit - set up the config
2 2
3 3 $ cat >> $HGRCPATH <<EOF
4 4 > [experimental]
5 5 > evolution.createmarkers=True
6 6 > evolution.allowunstable=True
7 7 > [extensions]
8 8 > uncommit =
9 9 > drawdag=$TESTDIR/drawdag.py
10 10 > EOF
11 11
12 12 Build up a repo
13 13
14 14 $ hg init repo
15 15 $ cd repo
16 16 $ hg bookmark foo
17 17
18 18 Help for uncommit
19 19
20 20 $ hg help uncommit
21 21 hg uncommit [OPTION]... [FILE]...
22 22
23 23 uncommit part or all of a local changeset
24 24
25 25 This command undoes the effect of a local commit, returning the affected
26 26 files to their uncommitted state. This means that files modified or
27 27 deleted in the changeset will be left unchanged, and so will remain
28 28 modified in the working directory.
29 29
30 30 If no files are specified, the commit will be pruned, unless --keep is
31 31 given.
32 32
33 33 (use 'hg help -e uncommit' to show help for the uncommit extension)
34 34
35 35 options ([+] can be repeated):
36 36
37 37 --keep allow an empty commit after uncommitting
38 38 --allow-dirty-working-copy allow uncommit with outstanding changes
39 39 -n --note TEXT store a note on uncommit
40 40 -I --include PATTERN [+] include names matching the given patterns
41 41 -X --exclude PATTERN [+] exclude names matching the given patterns
42 42 -m --message TEXT use text as commit message
43 43 -l --logfile FILE read commit message from file
44 44 -d --date DATE record the specified date as commit date
45 45 -u --user USER record the specified user as committer
46 46 -D --currentdate record the current date as commit date
47 47 -U --currentuser record the current user as committer
48 48
49 49 (some details hidden, use --verbose to show complete help)
50 50
51 51 Uncommit with no commits should fail
52 52
53 53 $ hg uncommit
54 54 abort: cannot uncommit null changeset
55 55 (no changeset checked out)
56 56 [255]
57 57
58 58 Create some commits
59 59
60 60 $ touch files
61 61 $ hg add files
62 62 $ for i in a ab abc abcd abcde; do echo $i > files; echo $i > file-$i; hg add file-$i; hg commit -m "added file-$i"; done
63 63 $ ls
64 64 file-a
65 65 file-ab
66 66 file-abc
67 67 file-abcd
68 68 file-abcde
69 69 files
70 70
71 71 $ hg log -G -T '{rev}:{node} {desc}' --hidden
72 72 @ 4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde
73 73 |
74 74 o 3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd
75 75 |
76 76 o 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc
77 77 |
78 78 o 1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab
79 79 |
80 80 o 0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a
81 81
82 82 Simple uncommit off the top, also moves bookmark
83 83
84 84 $ hg bookmark
85 85 * foo 4:6c4fd43ed714
86 86 $ hg uncommit
87 87 $ hg status
88 88 M files
89 89 A file-abcde
90 90 $ hg bookmark
91 91 * foo 3:6db330d65db4
92 92
93 93 $ hg log -G -T '{rev}:{node} {desc}' --hidden
94 94 x 4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde
95 95 |
96 96 @ 3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd
97 97 |
98 98 o 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc
99 99 |
100 100 o 1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab
101 101 |
102 102 o 0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a
103 103
104 104
105 105 Recommit
106 106
107 107 $ hg commit -m 'new change abcde'
108 108 $ hg status
109 109 $ hg heads -T '{rev}:{node} {desc}'
110 110 5:0c07a3ccda771b25f1cb1edbd02e683723344ef1 new change abcde (no-eol)
111 111
112 112 Uncommit of non-existent and unchanged files aborts
113 113 $ hg uncommit nothinghere
114 114 abort: cannot uncommit "nothinghere"
115 115 (file does not exist)
116 116 [255]
117 117 $ hg status
118 118 $ hg uncommit file-abc
119 119 abort: cannot uncommit "file-abc"
120 120 (file was not changed in working directory parent)
121 121 [255]
122 122 $ hg status
123 123
124 124 Try partial uncommit, also moves bookmark
125 125
126 126 $ hg bookmark
127 127 * foo 5:0c07a3ccda77
128 128 $ hg uncommit files
129 129 $ hg status
130 130 M files
131 131 $ hg bookmark
132 132 * foo 6:3727deee06f7
133 133 $ hg heads -T '{rev}:{node} {desc}'
134 134 6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcde (no-eol)
135 135 $ hg log -r . -p -T '{rev}:{node} {desc}'
136 136 6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcdediff -r 6db330d65db4 -r 3727deee06f7 file-abcde
137 137 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
138 138 +++ b/file-abcde Thu Jan 01 00:00:00 1970 +0000
139 139 @@ -0,0 +1,1 @@
140 140 +abcde
141 141
142 142 $ hg log -G -T '{rev}:{node} {desc}' --hidden
143 143 @ 6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcde
144 144 |
145 145 | x 5:0c07a3ccda771b25f1cb1edbd02e683723344ef1 new change abcde
146 146 |/
147 147 | x 4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde
148 148 |/
149 149 o 3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd
150 150 |
151 151 o 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc
152 152 |
153 153 o 1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab
154 154 |
155 155 o 0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a
156 156
157 157 $ hg commit -m 'update files for abcde'
158 158
159 159 Uncommit with dirty state
160 160
161 161 $ echo "foo" >> files
162 162 $ cat files
163 163 abcde
164 164 foo
165 165 $ hg status
166 166 M files
167 167 $ hg uncommit
168 168 abort: uncommitted changes
169 169 (requires --allow-dirty-working-copy to uncommit)
170 170 [255]
171 171 $ hg uncommit files
172 172 abort: uncommitted changes
173 173 (requires --allow-dirty-working-copy to uncommit)
174 174 [255]
175 175 $ cat files
176 176 abcde
177 177 foo
178 178 $ hg commit --amend -m "files abcde + foo"
179 179
180 180 Testing the 'experimental.uncommitondirtywdir' config
181 181
182 182 $ echo "bar" >> files
183 183 $ hg uncommit
184 184 abort: uncommitted changes
185 185 (requires --allow-dirty-working-copy to uncommit)
186 186 [255]
187 187 $ hg uncommit --config experimental.uncommitondirtywdir=True
188 188 $ hg commit -m "files abcde + foo"
189 189
190 190 Uncommit in the middle of a stack, does not move bookmark
191 191
192 192 $ hg checkout '.^^^'
193 193 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
194 194 (leaving bookmark foo)
195 195 $ hg log -r . -p -T '{rev}:{node} {desc}'
196 196 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abcdiff -r 69a232e754b0 -r abf2df566fc1 file-abc
197 197 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
198 198 +++ b/file-abc Thu Jan 01 00:00:00 1970 +0000
199 199 @@ -0,0 +1,1 @@
200 200 +abc
201 201 diff -r 69a232e754b0 -r abf2df566fc1 files
202 202 --- a/files Thu Jan 01 00:00:00 1970 +0000
203 203 +++ b/files Thu Jan 01 00:00:00 1970 +0000
204 204 @@ -1,1 +1,1 @@
205 205 -ab
206 206 +abc
207 207
208 208 $ hg bookmark
209 209 foo 9:48e5bd7cd583
210 210 $ hg uncommit
211 211 3 new orphan changesets
212 212 $ hg status
213 213 M files
214 214 A file-abc
215 215 $ hg heads -T '{rev}:{node} {desc}'
216 216 9:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo (no-eol)
217 217 $ hg bookmark
218 218 foo 9:48e5bd7cd583
219 219 $ hg commit -m 'new abc'
220 220 created new head
221 221
222 222 Partial uncommit in the middle, does not move bookmark
223 223
224 224 $ hg checkout '.^'
225 225 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
226 226 $ hg log -r . -p -T '{rev}:{node} {desc}'
227 227 1:69a232e754b08d568c4899475faf2eb44b857802 added file-abdiff -r 3004d2d9b508 -r 69a232e754b0 file-ab
228 228 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
229 229 +++ b/file-ab Thu Jan 01 00:00:00 1970 +0000
230 230 @@ -0,0 +1,1 @@
231 231 +ab
232 232 diff -r 3004d2d9b508 -r 69a232e754b0 files
233 233 --- a/files Thu Jan 01 00:00:00 1970 +0000
234 234 +++ b/files Thu Jan 01 00:00:00 1970 +0000
235 235 @@ -1,1 +1,1 @@
236 236 -a
237 237 +ab
238 238
239 239 $ hg bookmark
240 240 foo 9:48e5bd7cd583
241 241 $ hg uncommit file-ab
242 242 1 new orphan changesets
243 243 $ hg status
244 244 A file-ab
245 245
246 246 $ hg heads -T '{rev}:{node} {desc}\n'
247 247 11:8eb87968f2edb7f27f27fe676316e179de65fff6 added file-ab
248 248 10:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc
249 249 9:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo
250 250
251 251 $ hg bookmark
252 252 foo 9:48e5bd7cd583
253 253 $ hg commit -m 'update ab'
254 254 $ hg status
255 255 $ hg heads -T '{rev}:{node} {desc}\n'
256 256 12:f21039c59242b085491bb58f591afc4ed1c04c09 update ab
257 257 10:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc
258 258 9:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo
259 259
260 260 $ hg log -G -T '{rev}:{node} {desc}' --hidden
261 261 @ 12:f21039c59242b085491bb58f591afc4ed1c04c09 update ab
262 262 |
263 263 o 11:8eb87968f2edb7f27f27fe676316e179de65fff6 added file-ab
264 264 |
265 265 | * 10:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc
266 266 | |
267 267 | | * 9:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo
268 268 | | |
269 269 | | | x 8:84beeba0ac30e19521c036e4d2dd3a5fa02586ff files abcde + foo
270 270 | | |/
271 271 | | | x 7:0977fa602c2fd7d8427ed4e7ee15ea13b84c9173 update files for abcde
272 272 | | |/
273 273 | | * 6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcde
274 274 | | |
275 275 | | | x 5:0c07a3ccda771b25f1cb1edbd02e683723344ef1 new change abcde
276 276 | | |/
277 277 | | | x 4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde
278 278 | | |/
279 279 | | * 3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd
280 280 | | |
281 281 | | x 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc
282 282 | |/
283 283 | x 1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab
284 284 |/
285 285 o 0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a
286 286
287 287 Uncommit with draft parent
288 288
289 289 $ hg uncommit
290 290 $ hg phase -r .
291 291 11: draft
292 292 $ hg commit -m 'update ab again'
293 293
294 294 Phase is preserved
295 295
296 296 $ hg uncommit --keep --config phases.new-commit=secret
297 297 note: keeping empty commit
298 298 $ hg phase -r .
299 299 14: draft
300 300 $ hg commit --amend -m 'update ab again'
301 301
302 302 Uncommit with public parent
303 303
304 304 $ hg phase -p "::.^"
305 305 $ hg uncommit
306 306 $ hg phase -r .
307 307 11: public
308 308
309 309 Partial uncommit with public parent
310 310
311 311 $ echo xyz > xyz
312 312 $ hg add xyz
313 313 $ hg commit -m "update ab and add xyz"
314 314 $ hg uncommit xyz
315 315 $ hg status
316 316 A xyz
317 317 $ hg phase -r .
318 318 17: draft
319 319 $ hg phase -r ".^"
320 320 11: public
321 321
322 322 Uncommit with --keep or experimental.uncommit.keep leaves an empty changeset
323 323
324 324 $ cd $TESTTMP
325 325 $ hg init repo1
326 326 $ cd repo1
327 327 $ hg debugdrawdag <<'EOS'
328 328 > Q
329 329 > |
330 330 > P
331 331 > EOS
332 332 $ hg up Q -q
333 333 $ hg uncommit --keep
334 334 note: keeping empty commit
335 335 $ hg log -G -T '{desc} FILES: {files}'
336 336 @ Q FILES:
337 337 |
338 338 | x Q FILES: Q
339 339 |/
340 340 o P FILES: P
341 341
342 342 $ cat >> .hg/hgrc <<EOF
343 343 > [experimental]
344 344 > uncommit.keep=True
345 345 > EOF
346 346 $ hg ci --amend
347 347 $ hg uncommit
348 348 note: keeping empty commit
349 349 $ hg log -G -T '{desc} FILES: {files}'
350 350 @ Q FILES:
351 351 |
352 352 | x Q FILES: Q
353 353 |/
354 354 o P FILES: P
355 355
356 356 $ hg status
357 357 A Q
358 358 $ hg ci --amend
359 359 $ hg uncommit --no-keep
360 360 $ hg log -G -T '{desc} FILES: {files}'
361 361 x Q FILES: Q
362 362 |
363 363 @ P FILES: P
364 364
365 365 $ hg status
366 366 A Q
367 367 $ cd ..
368 368 $ rm -rf repo1
369 369
370 370 Testing uncommit while merge
371 371
372 372 $ hg init repo2
373 373 $ cd repo2
374 374
375 375 Create some history
376 376
377 377 $ touch a
378 378 $ hg add a
379 379 $ for i in 1 2 3; do echo $i > a; hg commit -m "a $i"; done
380 380 $ hg checkout 0
381 381 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
382 382 $ touch b
383 383 $ hg add b
384 384 $ for i in 1 2 3; do echo $i > b; hg commit -m "b $i"; done
385 385 created new head
386 386 $ hg log -G -T '{rev}:{node} {desc}' --hidden
387 387 @ 5:2cd56cdde163ded2fbb16ba2f918c96046ab0bf2 b 3
388 388 |
389 389 o 4:c3a0d5bb3b15834ffd2ef9ef603e93ec65cf2037 b 2
390 390 |
391 391 o 3:49bb009ca26078726b8870f1edb29fae8f7618f5 b 1
392 392 |
393 393 | o 2:990982b7384266e691f1bc08ca36177adcd1c8a9 a 3
394 394 | |
395 395 | o 1:24d38e3cf160c7b6f5ffe82179332229886a6d34 a 2
396 396 |/
397 397 o 0:ea4e33293d4d274a2ba73150733c2612231f398c a 1
398 398
399 399
400 400 Add and expect uncommit to fail on both merge working dir and merge changeset
401 401
402 402 $ hg merge 2
403 403 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
404 404 (branch merge, don't forget to commit)
405 405
406 406 $ hg uncommit
407 407 abort: outstanding uncommitted merge
408 408 (requires --allow-dirty-working-copy to uncommit)
409 409 [255]
410 410
411 411 $ hg uncommit --config experimental.uncommitondirtywdir=True
412 412 abort: cannot uncommit while merging
413 413 [255]
414 414
415 415 $ hg status
416 416 M a
417 417 $ hg commit -m 'merge a and b'
418 418
419 419 $ hg uncommit
420 420 abort: cannot uncommit merge changeset
421 421 [255]
422 422
423 423 $ hg status
424 424 $ hg log -G -T '{rev}:{node} {desc}' --hidden
425 425 @ 6:c03b9c37bc67bf504d4912061cfb527b47a63c6e merge a and b
426 426 |\
427 427 | o 5:2cd56cdde163ded2fbb16ba2f918c96046ab0bf2 b 3
428 428 | |
429 429 | o 4:c3a0d5bb3b15834ffd2ef9ef603e93ec65cf2037 b 2
430 430 | |
431 431 | o 3:49bb009ca26078726b8870f1edb29fae8f7618f5 b 1
432 432 | |
433 433 o | 2:990982b7384266e691f1bc08ca36177adcd1c8a9 a 3
434 434 | |
435 435 o | 1:24d38e3cf160c7b6f5ffe82179332229886a6d34 a 2
436 436 |/
437 437 o 0:ea4e33293d4d274a2ba73150733c2612231f398c a 1
438 438
439 439
440 440 Rename a->b, then remove b in working copy. Result should remove a.
441 441
442 442 $ hg co -q 0
443 443 $ hg mv a b
444 444 $ hg ci -qm 'move a to b'
445 445 $ hg rm b
446 446 $ hg uncommit --config experimental.uncommitondirtywdir=True
447 447 $ hg st --copies
448 448 R a
449 449 $ hg revert a
450 450
451 451 Rename a->b, then rename b->c in working copy. Result should rename a->c.
452 452
453 453 $ hg co -q 0
454 454 $ hg mv a b
455 455 $ hg ci -qm 'move a to b'
456 456 $ hg mv b c
457 457 $ hg uncommit --config experimental.uncommitondirtywdir=True
458 458 $ hg st --copies
459 459 A c
460 460 a
461 461 R a
462 462 $ hg revert a
463 463 $ hg forget c
464 464 $ rm c
465 465
466 466 Copy a->b1 and a->b2, then rename b1->c in working copy. Result should copy a->b2 and a->c.
467 467
468 468 $ hg co -q 0
469 469 $ hg cp a b1
470 470 $ hg cp a b2
471 471 $ hg ci -qm 'move a to b1 and b2'
472 472 $ hg mv b1 c
473 473 $ hg uncommit --config experimental.uncommitondirtywdir=True
474 474 $ hg st --copies
475 475 A b2
476 476 a
477 477 A c
478 478 a
479 479 $ cd ..
480 480
481 481 --allow-dirty-working-copy should also work on a dirty PATH
482 482
483 483 $ hg init issue5977
484 484 $ cd issue5977
485 485 $ echo 'super critical info!' > a
486 486 $ hg ci -Am 'add a'
487 487 adding a
488 488 $ echo 'foo' > b
489 489 $ hg add b
490 490 $ hg status
491 491 A b
492 $ hg unc a
492 $ hg uncommit a
493 493 note: keeping empty commit
494 494 $ cat a
495 495 super critical info!
496 496 $ hg log
497 497 changeset: 1:656ba143d384
498 498 tag: tip
499 499 parent: -1:000000000000
500 500 user: test
501 501 date: Thu Jan 01 00:00:00 1970 +0000
502 502 summary: add a
503 503
504 504 $ hg ci -Am 'add b'
505 505 $ echo 'foo bar' > b
506 $ hg unc b
506 $ hg uncommit b
507 507 abort: uncommitted changes
508 508 (requires --allow-dirty-working-copy to uncommit)
509 509 [255]
510 $ hg unc --allow-dirty-working-copy b
510 $ hg uncommit --allow-dirty-working-copy b
511 511 $ hg log
512 512 changeset: 3:30fa958635b2
513 513 tag: tip
514 514 parent: 1:656ba143d384
515 515 user: test
516 516 date: Thu Jan 01 00:00:00 1970 +0000
517 517 summary: add b
518 518
519 519 changeset: 1:656ba143d384
520 520 parent: -1:000000000000
521 521 user: test
522 522 date: Thu Jan 01 00:00:00 1970 +0000
523 523 summary: add a
524 524
525 525 Removes can be uncommitted
526 526
527 527 $ hg ci -m 'modified b'
528 528 $ hg rm b
529 529 $ hg ci -m 'remove b'
530 530 $ hg uncommit b
531 531 note: keeping empty commit
532 532 $ hg status
533 533 R b
534 534
535 535 Uncommitting a directory won't run afoul of the checks that an explicit file
536 536 can be uncommitted.
537 537
538 538 $ mkdir dir
539 539 $ echo 1 > dir/file.txt
540 540 $ hg ci -Aqm 'add file in directory'
541 541 $ hg uncommit dir -m 'uncommit with message' -u 'different user' \
542 542 > -d 'Jun 30 12:12:12 1980 +0000'
543 543 $ hg status
544 544 A dir/file.txt
545 545 $ hg log -r .
546 546 changeset: 8:b4dd26dc42e0
547 547 tag: tip
548 548 parent: 6:2278a4c24330
549 549 user: different user
550 550 date: Mon Jun 30 12:12:12 1980 +0000
551 551 summary: uncommit with message
552 552
553 553 Bad option combinations
554 554
555 555 $ hg rollback -q --config ui.rollback=True
556 556 $ hg uncommit -U --user 'user'
557 557 abort: cannot specify both --user and --currentuser
558 558 [255]
559 559 $ hg uncommit -D --date today
560 560 abort: cannot specify both --date and --currentdate
561 561 [255]
562 562
563 563 `uncommit <dir>` and `cd <dir> && uncommit .` behave the same...
564 564
565 565 $ echo 2 > dir/file2.txt
566 566 $ hg ci -Aqm 'add file2 in directory'
567 567 $ hg uncommit dir
568 568 note: keeping empty commit
569 569 $ hg status
570 570 A dir/file2.txt
571 571
572 572 $ hg rollback -q --config ui.rollback=True
573 573 $ cd dir
574 574 $ hg uncommit . -n 'this is a note'
575 575 note: keeping empty commit
576 576 $ hg status
577 577 A dir/file2.txt
578 578 $ cd ..
579 579
580 580 ... and errors out the same way when nothing can be uncommitted
581 581
582 582 $ hg rollback -q --config ui.rollback=True
583 583 $ mkdir emptydir
584 584 $ hg uncommit emptydir
585 585 abort: cannot uncommit "emptydir"
586 586 (file was untracked in working directory parent)
587 587 [255]
588 588
589 589 $ cd emptydir
590 590 $ hg uncommit .
591 591 abort: cannot uncommit "emptydir"
592 592 (file was untracked in working directory parent)
593 593 [255]
594 594 $ hg status
595 595 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now