##// END OF EJS Templates
tests: clarify test setup test in test-uncommit.t...
Martin von Zweigbergk -
r42054:6a944bf4 default
parent child Browse files
Show More
@@ -1,515 +1,515
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 uncommiting
38 38 --allow-dirty-working-copy allow uncommit with outstanding changes
39 39 -I --include PATTERN [+] include names matching the given patterns
40 40 -X --exclude PATTERN [+] exclude names matching the given patterns
41 41
42 42 (some details hidden, use --verbose to show complete help)
43 43
44 44 Uncommit with no commits should fail
45 45
46 46 $ hg uncommit
47 47 abort: cannot uncommit null changeset
48 48 (no changeset checked out)
49 49 [255]
50 50
51 51 Create some commits
52 52
53 53 $ touch files
54 54 $ hg add files
55 55 $ 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
56 56 $ ls
57 57 file-a
58 58 file-ab
59 59 file-abc
60 60 file-abcd
61 61 file-abcde
62 62 files
63 63
64 64 $ hg log -G -T '{rev}:{node} {desc}' --hidden
65 65 @ 4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde
66 66 |
67 67 o 3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd
68 68 |
69 69 o 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc
70 70 |
71 71 o 1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab
72 72 |
73 73 o 0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a
74 74
75 75 Simple uncommit off the top, also moves bookmark
76 76
77 77 $ hg bookmark
78 78 * foo 4:6c4fd43ed714
79 79 $ hg uncommit
80 80 $ hg status
81 81 M files
82 82 A file-abcde
83 83 $ hg bookmark
84 84 * foo 3:6db330d65db4
85 85
86 86 $ hg log -G -T '{rev}:{node} {desc}' --hidden
87 87 x 4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde
88 88 |
89 89 @ 3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd
90 90 |
91 91 o 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc
92 92 |
93 93 o 1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab
94 94 |
95 95 o 0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a
96 96
97 97
98 98 Recommit
99 99
100 100 $ hg commit -m 'new change abcde'
101 101 $ hg status
102 102 $ hg heads -T '{rev}:{node} {desc}'
103 103 5:0c07a3ccda771b25f1cb1edbd02e683723344ef1 new change abcde (no-eol)
104 104
105 105 Uncommit of non-existent and unchanged files has no effect
106 106 $ hg uncommit nothinghere
107 107 nothing to uncommit
108 108 [1]
109 109 $ hg status
110 110 $ hg uncommit file-abc
111 111 nothing to uncommit
112 112 [1]
113 113 $ hg status
114 114
115 115 Try partial uncommit, also moves bookmark
116 116
117 117 $ hg bookmark
118 118 * foo 5:0c07a3ccda77
119 119 $ hg uncommit files
120 120 $ hg status
121 121 M files
122 122 $ hg bookmark
123 123 * foo 6:3727deee06f7
124 124 $ hg heads -T '{rev}:{node} {desc}'
125 125 6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcde (no-eol)
126 126 $ hg log -r . -p -T '{rev}:{node} {desc}'
127 127 6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcdediff -r 6db330d65db4 -r 3727deee06f7 file-abcde
128 128 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
129 129 +++ b/file-abcde Thu Jan 01 00:00:00 1970 +0000
130 130 @@ -0,0 +1,1 @@
131 131 +abcde
132 132
133 133 $ hg log -G -T '{rev}:{node} {desc}' --hidden
134 134 @ 6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcde
135 135 |
136 136 | x 5:0c07a3ccda771b25f1cb1edbd02e683723344ef1 new change abcde
137 137 |/
138 138 | x 4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde
139 139 |/
140 140 o 3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd
141 141 |
142 142 o 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc
143 143 |
144 144 o 1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab
145 145 |
146 146 o 0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a
147 147
148 148 $ hg commit -m 'update files for abcde'
149 149
150 150 Uncommit with dirty state
151 151
152 152 $ echo "foo" >> files
153 153 $ cat files
154 154 abcde
155 155 foo
156 156 $ hg status
157 157 M files
158 158 $ hg uncommit
159 159 abort: uncommitted changes
160 160 (requires --allow-dirty-working-copy to uncommit)
161 161 [255]
162 162 $ hg uncommit files
163 163 abort: uncommitted changes
164 164 (requires --allow-dirty-working-copy to uncommit)
165 165 [255]
166 166 $ cat files
167 167 abcde
168 168 foo
169 169 $ hg commit --amend -m "files abcde + foo"
170 170
171 171 Testing the 'experimental.uncommitondirtywdir' config
172 172
173 173 $ echo "bar" >> files
174 174 $ hg uncommit
175 175 abort: uncommitted changes
176 176 (requires --allow-dirty-working-copy to uncommit)
177 177 [255]
178 178 $ hg uncommit --config experimental.uncommitondirtywdir=True
179 179 $ hg commit -m "files abcde + foo"
180 180
181 181 Uncommit in the middle of a stack, does not move bookmark
182 182
183 183 $ hg checkout '.^^^'
184 184 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
185 185 (leaving bookmark foo)
186 186 $ hg log -r . -p -T '{rev}:{node} {desc}'
187 187 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abcdiff -r 69a232e754b0 -r abf2df566fc1 file-abc
188 188 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
189 189 +++ b/file-abc Thu Jan 01 00:00:00 1970 +0000
190 190 @@ -0,0 +1,1 @@
191 191 +abc
192 192 diff -r 69a232e754b0 -r abf2df566fc1 files
193 193 --- a/files Thu Jan 01 00:00:00 1970 +0000
194 194 +++ b/files Thu Jan 01 00:00:00 1970 +0000
195 195 @@ -1,1 +1,1 @@
196 196 -ab
197 197 +abc
198 198
199 199 $ hg bookmark
200 200 foo 9:48e5bd7cd583
201 201 $ hg uncommit
202 202 3 new orphan changesets
203 203 $ hg status
204 204 M files
205 205 A file-abc
206 206 $ hg heads -T '{rev}:{node} {desc}'
207 207 9:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo (no-eol)
208 208 $ hg bookmark
209 209 foo 9:48e5bd7cd583
210 210 $ hg commit -m 'new abc'
211 211 created new head
212 212
213 213 Partial uncommit in the middle, does not move bookmark
214 214
215 215 $ hg checkout '.^'
216 216 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
217 217 $ hg log -r . -p -T '{rev}:{node} {desc}'
218 218 1:69a232e754b08d568c4899475faf2eb44b857802 added file-abdiff -r 3004d2d9b508 -r 69a232e754b0 file-ab
219 219 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
220 220 +++ b/file-ab Thu Jan 01 00:00:00 1970 +0000
221 221 @@ -0,0 +1,1 @@
222 222 +ab
223 223 diff -r 3004d2d9b508 -r 69a232e754b0 files
224 224 --- a/files Thu Jan 01 00:00:00 1970 +0000
225 225 +++ b/files Thu Jan 01 00:00:00 1970 +0000
226 226 @@ -1,1 +1,1 @@
227 227 -a
228 228 +ab
229 229
230 230 $ hg bookmark
231 231 foo 9:48e5bd7cd583
232 232 $ hg uncommit file-ab
233 233 1 new orphan changesets
234 234 $ hg status
235 235 A file-ab
236 236
237 237 $ hg heads -T '{rev}:{node} {desc}\n'
238 238 11:8eb87968f2edb7f27f27fe676316e179de65fff6 added file-ab
239 239 10:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc
240 240 9:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo
241 241
242 242 $ hg bookmark
243 243 foo 9:48e5bd7cd583
244 244 $ hg commit -m 'update ab'
245 245 $ hg status
246 246 $ hg heads -T '{rev}:{node} {desc}\n'
247 247 12:f21039c59242b085491bb58f591afc4ed1c04c09 update ab
248 248 10:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc
249 249 9:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo
250 250
251 251 $ hg log -G -T '{rev}:{node} {desc}' --hidden
252 252 @ 12:f21039c59242b085491bb58f591afc4ed1c04c09 update ab
253 253 |
254 254 o 11:8eb87968f2edb7f27f27fe676316e179de65fff6 added file-ab
255 255 |
256 256 | * 10:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc
257 257 | |
258 258 | | * 9:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo
259 259 | | |
260 260 | | | x 8:84beeba0ac30e19521c036e4d2dd3a5fa02586ff files abcde + foo
261 261 | | |/
262 262 | | | x 7:0977fa602c2fd7d8427ed4e7ee15ea13b84c9173 update files for abcde
263 263 | | |/
264 264 | | * 6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcde
265 265 | | |
266 266 | | | x 5:0c07a3ccda771b25f1cb1edbd02e683723344ef1 new change abcde
267 267 | | |/
268 268 | | | x 4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde
269 269 | | |/
270 270 | | * 3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd
271 271 | | |
272 272 | | x 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc
273 273 | |/
274 274 | x 1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab
275 275 |/
276 276 o 0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a
277 277
278 278 Uncommit with draft parent
279 279
280 280 $ hg uncommit
281 281 $ hg phase -r .
282 282 11: draft
283 283 $ hg commit -m 'update ab again'
284 284
285 285 Phase is preserved
286 286
287 287 $ hg uncommit --keep --config phases.new-commit=secret
288 288 note: keeping empty commit
289 289 $ hg phase -r .
290 290 14: draft
291 291 $ hg commit --amend -m 'update ab again'
292 292
293 293 Uncommit with public parent
294 294
295 295 $ hg phase -p "::.^"
296 296 $ hg uncommit
297 297 $ hg phase -r .
298 298 11: public
299 299
300 300 Partial uncommit with public parent
301 301
302 302 $ echo xyz > xyz
303 303 $ hg add xyz
304 304 $ hg commit -m "update ab and add xyz"
305 305 $ hg uncommit xyz
306 306 $ hg status
307 307 A xyz
308 308 $ hg phase -r .
309 309 17: draft
310 310 $ hg phase -r ".^"
311 311 11: public
312 312
313 313 Uncommit with --keep or experimental.uncommit.keep leaves an empty changeset
314 314
315 315 $ cd $TESTTMP
316 316 $ hg init repo1
317 317 $ cd repo1
318 318 $ hg debugdrawdag <<'EOS'
319 319 > Q
320 320 > |
321 321 > P
322 322 > EOS
323 323 $ hg up Q -q
324 324 $ hg uncommit --keep
325 325 note: keeping empty commit
326 326 $ hg log -G -T '{desc} FILES: {files}'
327 327 @ Q FILES:
328 328 |
329 329 | x Q FILES: Q
330 330 |/
331 331 o P FILES: P
332 332
333 333 $ cat >> .hg/hgrc <<EOF
334 334 > [experimental]
335 335 > uncommit.keep=True
336 336 > EOF
337 337 $ hg ci --amend
338 338 $ hg uncommit
339 339 note: keeping empty commit
340 340 $ hg log -G -T '{desc} FILES: {files}'
341 341 @ Q FILES:
342 342 |
343 343 | x Q FILES: Q
344 344 |/
345 345 o P FILES: P
346 346
347 347 $ hg status
348 348 A Q
349 349 $ hg ci --amend
350 350 $ hg uncommit --no-keep
351 351 $ hg log -G -T '{desc} FILES: {files}'
352 352 x Q FILES: Q
353 353 |
354 354 @ P FILES: P
355 355
356 356 $ hg status
357 357 A Q
358 358 $ cd ..
359 359 $ rm -rf repo1
360 360
361 361 Testing uncommit while merge
362 362
363 363 $ hg init repo2
364 364 $ cd repo2
365 365
366 366 Create some history
367 367
368 368 $ touch a
369 369 $ hg add a
370 370 $ for i in 1 2 3; do echo $i > a; hg commit -m "a $i"; done
371 371 $ hg checkout 0
372 372 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
373 373 $ touch b
374 374 $ hg add b
375 375 $ for i in 1 2 3; do echo $i > b; hg commit -m "b $i"; done
376 376 created new head
377 377 $ hg log -G -T '{rev}:{node} {desc}' --hidden
378 378 @ 5:2cd56cdde163ded2fbb16ba2f918c96046ab0bf2 b 3
379 379 |
380 380 o 4:c3a0d5bb3b15834ffd2ef9ef603e93ec65cf2037 b 2
381 381 |
382 382 o 3:49bb009ca26078726b8870f1edb29fae8f7618f5 b 1
383 383 |
384 384 | o 2:990982b7384266e691f1bc08ca36177adcd1c8a9 a 3
385 385 | |
386 386 | o 1:24d38e3cf160c7b6f5ffe82179332229886a6d34 a 2
387 387 |/
388 388 o 0:ea4e33293d4d274a2ba73150733c2612231f398c a 1
389 389
390 390
391 391 Add and expect uncommit to fail on both merge working dir and merge changeset
392 392
393 393 $ hg merge 2
394 394 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
395 395 (branch merge, don't forget to commit)
396 396
397 397 $ hg uncommit
398 398 abort: outstanding uncommitted merge
399 399 (requires --allow-dirty-working-copy to uncommit)
400 400 [255]
401 401
402 402 $ hg uncommit --config experimental.uncommitondirtywdir=True
403 403 abort: cannot uncommit while merging
404 404 [255]
405 405
406 406 $ hg status
407 407 M a
408 408 $ hg commit -m 'merge a and b'
409 409
410 410 $ hg uncommit
411 411 abort: cannot uncommit merge changeset
412 412 [255]
413 413
414 414 $ hg status
415 415 $ hg log -G -T '{rev}:{node} {desc}' --hidden
416 416 @ 6:c03b9c37bc67bf504d4912061cfb527b47a63c6e merge a and b
417 417 |\
418 418 | o 5:2cd56cdde163ded2fbb16ba2f918c96046ab0bf2 b 3
419 419 | |
420 420 | o 4:c3a0d5bb3b15834ffd2ef9ef603e93ec65cf2037 b 2
421 421 | |
422 422 | o 3:49bb009ca26078726b8870f1edb29fae8f7618f5 b 1
423 423 | |
424 424 o | 2:990982b7384266e691f1bc08ca36177adcd1c8a9 a 3
425 425 | |
426 426 o | 1:24d38e3cf160c7b6f5ffe82179332229886a6d34 a 2
427 427 |/
428 428 o 0:ea4e33293d4d274a2ba73150733c2612231f398c a 1
429 429
430 430
431 431 Rename a->b, then remove b in working copy. Result should remove a.
432 432
433 433 $ hg co -q 0
434 434 $ hg mv a b
435 435 $ hg ci -qm 'move a to b'
436 436 $ hg rm b
437 437 $ hg uncommit --config experimental.uncommitondirtywdir=True
438 438 $ hg st --copies
439 439 R a
440 440 $ hg revert a
441 441
442 442 Rename a->b, then rename b->c in working copy. Result should rename a->c.
443 443
444 444 $ hg co -q 0
445 445 $ hg mv a b
446 446 $ hg ci -qm 'move a to b'
447 447 $ hg mv b c
448 448 $ hg uncommit --config experimental.uncommitondirtywdir=True
449 449 $ hg st --copies
450 450 A c
451 451 a
452 452 R a
453 453 $ hg revert a
454 454 $ hg forget c
455 455 $ rm c
456 456
457 457 Copy a->b1 and a->b2, then rename b1->c in working copy. Result should copy a->b2 and a->c.
458 458
459 459 $ hg co -q 0
460 460 $ hg cp a b1
461 461 $ hg cp a b2
462 462 $ hg ci -qm 'move a to b1 and b2'
463 463 $ hg mv b1 c
464 464 $ hg uncommit --config experimental.uncommitondirtywdir=True
465 465 $ hg st --copies
466 466 A b2
467 467 a
468 468 A c
469 469 a
470 470 $ cd ..
471 471
472 472 --allow-dirty-working-copy should also work on a dirty PATH
473 473
474 474 $ hg init issue5977
475 475 $ cd issue5977
476 476 $ echo 'super critical info!' > a
477 477 $ hg ci -Am 'add a'
478 478 adding a
479 479 $ echo 'foo' > b
480 480 $ hg add b
481 481 $ hg status
482 482 A b
483 483 $ hg unc a
484 484 note: keeping empty commit
485 $ hg unc b
486 abort: uncommitted changes
487 (requires --allow-dirty-working-copy to uncommit)
488 [255]
489 485 $ cat a
490 486 super critical info!
491 487 $ hg log
492 488 changeset: 1:656ba143d384
493 489 tag: tip
494 490 parent: -1:000000000000
495 491 user: test
496 492 date: Thu Jan 01 00:00:00 1970 +0000
497 493 summary: add a
498 494
499 495 $ hg ci -Am 'add b'
500 496 $ echo 'foo bar' > b
497 $ hg unc b
498 abort: uncommitted changes
499 (requires --allow-dirty-working-copy to uncommit)
500 [255]
501 501 $ hg unc --allow-dirty-working-copy b
502 502 $ hg log
503 503 changeset: 3:30fa958635b2
504 504 tag: tip
505 505 parent: 1:656ba143d384
506 506 user: test
507 507 date: Thu Jan 01 00:00:00 1970 +0000
508 508 summary: add b
509 509
510 510 changeset: 1:656ba143d384
511 511 parent: -1:000000000000
512 512 user: test
513 513 date: Thu Jan 01 00:00:00 1970 +0000
514 514 summary: add a
515 515
General Comments 0
You need to be logged in to leave comments. Login now