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