There are people who wants to do hg uncommit on dirty working directory, so
this patch adds a config which can be used to the achieve that.
Adds tests for the same.
durin42 |
hg-reviewers |
There are people who wants to do hg uncommit on dirty working directory, so
this patch adds a config which can be used to the achieve that.
Adds tests for the same.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
Path | Packages | |||
---|---|---|---|---|
M | hgext/uncommit.py (3 lines) | |||
M | tests/test-uncommit.t (49 lines) |
abort: uncommitted changes | abort: uncommitted changes | ||||
[255] | [255] | ||||
$ hg uncommit files | $ hg uncommit files | ||||
$ cat files | $ cat files | ||||
abcde | abcde | ||||
foo | foo | ||||
$ hg commit -m "files abcde + foo" | $ hg commit -m "files abcde + foo" | ||||
Testing the 'experimental.uncommitondirtywdir' config | |||||
$ echo "bar" >> files | |||||
$ hg uncommit | |||||
abort: uncommitted changes | |||||
[255] | |||||
$ hg uncommit --config experimental.uncommitondirtywdir=True | |||||
$ hg commit -m "files abcde + foo" | |||||
Uncommit in the middle of a stack, does not move bookmark | Uncommit in the middle of a stack, does not move bookmark | ||||
$ hg checkout '.^^^' | $ hg checkout '.^^^' | ||||
1 files updated, 0 files merged, 2 files removed, 0 files unresolved | 1 files updated, 0 files merged, 2 files removed, 0 files unresolved | ||||
(leaving bookmark foo) | (leaving bookmark foo) | ||||
$ hg log -r . -p -T '{rev}:{node} {desc}' | $ hg log -r . -p -T '{rev}:{node} {desc}' | ||||
2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abcdiff -r 69a232e754b0 -r abf2df566fc1 file-abc | 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abcdiff -r 69a232e754b0 -r abf2df566fc1 file-abc | ||||
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | ||||
+++ b/file-abc Thu Jan 01 00:00:00 1970 +0000 | +++ b/file-abc Thu Jan 01 00:00:00 1970 +0000 | ||||
@@ -0,0 +1,1 @@ | @@ -0,0 +1,1 @@ | ||||
+abc | +abc | ||||
diff -r 69a232e754b0 -r abf2df566fc1 files | diff -r 69a232e754b0 -r abf2df566fc1 files | ||||
--- a/files Thu Jan 01 00:00:00 1970 +0000 | --- a/files Thu Jan 01 00:00:00 1970 +0000 | ||||
+++ b/files Thu Jan 01 00:00:00 1970 +0000 | +++ b/files Thu Jan 01 00:00:00 1970 +0000 | ||||
@@ -1,1 +1,1 @@ | @@ -1,1 +1,1 @@ | ||||
-ab | -ab | ||||
+abc | +abc | ||||
$ hg bookmark | $ hg bookmark | ||||
foo 8:83815831694b | foo 9:48e5bd7cd583 | ||||
$ hg uncommit | $ hg uncommit | ||||
$ hg status | $ hg status | ||||
M files | M files | ||||
A file-abc | A file-abc | ||||
$ hg heads -T '{rev}:{node} {desc}' | $ hg heads -T '{rev}:{node} {desc}' | ||||
8:83815831694b1271e9f207cb1b79b2b19275edcb files abcde + foo (no-eol) | 9:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo (no-eol) | ||||
$ hg bookmark | $ hg bookmark | ||||
foo 8:83815831694b | foo 9:48e5bd7cd583 | ||||
$ hg commit -m 'new abc' | $ hg commit -m 'new abc' | ||||
created new head | created new head | ||||
Partial uncommit in the middle, does not move bookmark | Partial uncommit in the middle, does not move bookmark | ||||
$ hg checkout '.^' | $ hg checkout '.^' | ||||
1 files updated, 0 files merged, 1 files removed, 0 files unresolved | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved | ||||
$ hg log -r . -p -T '{rev}:{node} {desc}' | $ hg log -r . -p -T '{rev}:{node} {desc}' | ||||
1:69a232e754b08d568c4899475faf2eb44b857802 added file-abdiff -r 3004d2d9b508 -r 69a232e754b0 file-ab | 1:69a232e754b08d568c4899475faf2eb44b857802 added file-abdiff -r 3004d2d9b508 -r 69a232e754b0 file-ab | ||||
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | ||||
+++ b/file-ab Thu Jan 01 00:00:00 1970 +0000 | +++ b/file-ab Thu Jan 01 00:00:00 1970 +0000 | ||||
@@ -0,0 +1,1 @@ | @@ -0,0 +1,1 @@ | ||||
+ab | +ab | ||||
diff -r 3004d2d9b508 -r 69a232e754b0 files | diff -r 3004d2d9b508 -r 69a232e754b0 files | ||||
--- a/files Thu Jan 01 00:00:00 1970 +0000 | --- a/files Thu Jan 01 00:00:00 1970 +0000 | ||||
+++ b/files Thu Jan 01 00:00:00 1970 +0000 | +++ b/files Thu Jan 01 00:00:00 1970 +0000 | ||||
@@ -1,1 +1,1 @@ | @@ -1,1 +1,1 @@ | ||||
-a | -a | ||||
+ab | +ab | ||||
$ hg bookmark | $ hg bookmark | ||||
foo 8:83815831694b | foo 9:48e5bd7cd583 | ||||
$ hg uncommit file-ab | $ hg uncommit file-ab | ||||
$ hg status | $ hg status | ||||
A file-ab | A file-ab | ||||
$ hg heads -T '{rev}:{node} {desc}\n' | $ hg heads -T '{rev}:{node} {desc}\n' | ||||
10:8eb87968f2edb7f27f27fe676316e179de65fff6 added file-ab | 11:8eb87968f2edb7f27f27fe676316e179de65fff6 added file-ab | ||||
9:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc | 10:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc | ||||
8:83815831694b1271e9f207cb1b79b2b19275edcb files abcde + foo | 9:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo | ||||
$ hg bookmark | $ hg bookmark | ||||
foo 8:83815831694b | foo 9:48e5bd7cd583 | ||||
$ hg commit -m 'update ab' | $ hg commit -m 'update ab' | ||||
$ hg status | $ hg status | ||||
$ hg heads -T '{rev}:{node} {desc}\n' | $ hg heads -T '{rev}:{node} {desc}\n' | ||||
11:f21039c59242b085491bb58f591afc4ed1c04c09 update ab | 12:f21039c59242b085491bb58f591afc4ed1c04c09 update ab | ||||
9:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc | 10:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc | ||||
8:83815831694b1271e9f207cb1b79b2b19275edcb files abcde + foo | 9:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo | ||||
$ hg log -G -T '{rev}:{node} {desc}' --hidden | $ hg log -G -T '{rev}:{node} {desc}' --hidden | ||||
@ 11:f21039c59242b085491bb58f591afc4ed1c04c09 update ab | @ 12:f21039c59242b085491bb58f591afc4ed1c04c09 update ab | ||||
| | | | ||||
o 10:8eb87968f2edb7f27f27fe676316e179de65fff6 added file-ab | o 11:8eb87968f2edb7f27f27fe676316e179de65fff6 added file-ab | ||||
| | | | ||||
| o 9:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc | | o 10:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc | ||||
| | | | | | ||||
| | o 8:83815831694b1271e9f207cb1b79b2b19275edcb files abcde + foo | | | o 9:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo | ||||
| | | | | | | | ||||
| | | x 8:83815831694b1271e9f207cb1b79b2b19275edcb files abcde + foo | |||||
| | |/ | |||||
| | | x 7:0977fa602c2fd7d8427ed4e7ee15ea13b84c9173 update files for abcde | | | | x 7:0977fa602c2fd7d8427ed4e7ee15ea13b84c9173 update files for abcde | ||||
| | |/ | | | |/ | ||||
| | o 6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcde | | | o 6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcde | ||||
| | | | | | | | ||||
| | | x 5:0c07a3ccda771b25f1cb1edbd02e683723344ef1 new change abcde | | | | x 5:0c07a3ccda771b25f1cb1edbd02e683723344ef1 new change abcde | ||||
| | |/ | | | |/ | ||||
| | | x 4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde | | | | x 4:6c4fd43ed714e7fcd8adbaa7b16c953c2e985b60 added file-abcde | ||||
| | |/ | | | |/ | ||||
| | o 3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd | | | o 3:6db330d65db434145c0b59d291853e9a84719b24 added file-abcd | ||||
| | | | | | | | ||||
| | x 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc | | | x 2:abf2df566fc193b3ac34d946e63c1583e4d4732b added file-abc | ||||
| |/ | | |/ | ||||
| x 1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab | | x 1:69a232e754b08d568c4899475faf2eb44b857802 added file-ab | ||||
|/ | |/ | ||||
o 0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a | o 0:3004d2d9b50883c1538fc754a3aeb55f1b4084f6 added file-a | ||||
Uncommit with draft parent | Uncommit with draft parent | ||||
$ hg uncommit | $ hg uncommit | ||||
$ hg phase -r . | $ hg phase -r . | ||||
10: draft | 11: draft | ||||
$ hg commit -m 'update ab again' | $ hg commit -m 'update ab again' | ||||
Uncommit with public parent | Uncommit with public parent | ||||
$ hg phase -p "::.^" | $ hg phase -p "::.^" | ||||
$ hg uncommit | $ hg uncommit | ||||
$ hg phase -r . | $ hg phase -r . | ||||
10: public | 11: public | ||||
Partial uncommit with public parent | Partial uncommit with public parent | ||||
$ echo xyz > xyz | $ echo xyz > xyz | ||||
$ hg add xyz | $ hg add xyz | ||||
$ hg commit -m "update ab and add xyz" | $ hg commit -m "update ab and add xyz" | ||||
$ hg uncommit xyz | $ hg uncommit xyz | ||||
$ hg status | $ hg status | ||||
A xyz | A xyz | ||||
$ hg phase -r . | $ hg phase -r . | ||||
14: draft | 15: draft | ||||
$ hg phase -r ".^" | $ hg phase -r ".^" | ||||
10: public | 11: public | ||||
Uncommit leaving an empty changeset | Uncommit leaving an empty changeset | ||||
$ cd $TESTTMP | $ cd $TESTTMP | ||||
$ hg init repo1 | $ hg init repo1 | ||||
$ cd repo1 | $ cd repo1 | ||||
$ hg debugdrawdag <<'EOS' | $ hg debugdrawdag <<'EOS' | ||||
> Q | > Q |
Perhaps we should test this case, dirtyuncommit & merge.