Skip to content

Commit eccfc5d

Browse files
Liu Yangfacebook-github-bot
authored andcommitted
No undo-uncommit-unamend hint when --keep is provided
Summary: #193 Reviewed By: quark-zju Differential Revision: D74723404 fbshipit-source-id: 7a193f12319899d50b799efd9022e0a411fdaa0a
1 parent d68bcab commit eccfc5d

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

eden/scm/sapling/ext/undo.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,8 @@ def _undoto(ui, repo, reverseindex, keep=False, branch=None):
11501150
command = "amend"
11511151
oldcommithash = _readnode(repo, "workingparent.i", nodedict["workingparent"])
11521152
shorthash = short(bin(oldcommithash))
1153-
hintutil.trigger("undo-uncommit-unamend", command, shorthash)
1153+
if not keep:
1154+
hintutil.trigger("undo-uncommit-unamend", command, shorthash)
11541155
repo.ui.status(uimessage)
11551156

11561157

eden/scm/tests/test-undo.t

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,35 @@
3838

3939
undo to *, before commit -Aqm initial commit (glob)
4040

41-
$ hg undo
41+
$ hg undo --keep
4242
undone to *, before commit -Aqm initial commit (glob)
43+
44+
$ hg log -r 'olddraft(0)'
45+
commit: 79344ac2ab8b
46+
user: test
47+
date: Thu Jan 01 00:00:00 1970 +0000
48+
summary: initial commit
49+
50+
$ hg status
51+
M file
52+
53+
$ hg commit -Aqm "recommit after undo --keep"
54+
$ hg log -r 'olddraft(0)'
55+
commit: 79344ac2ab8b
56+
user: test
57+
date: Thu Jan 01 00:00:00 1970 +0000
58+
summary: initial commit
59+
60+
commit: 0109d94c2173
61+
user: test
62+
date: Thu Jan 01 00:00:00 1970 +0000
63+
summary: recommit after undo --keep
64+
65+
66+
$ hg undo
67+
undone to *, before commit -Aqm recommit after undo --keep (glob)
4368
hint[undo-uncommit-unamend]: undoing commits discards their changes.
44-
to restore the changes to the working copy, run 'hg revert -r f5a897cc70a1 --all'
69+
to restore the changes to the working copy, run 'hg revert -r 0109d94c2173 --all'
4570
in the future, you can use 'hg uncommit' instead of 'hg undo' to keep changes
4671
hint[hint-ack]: use 'hg hint --ack undo-uncommit-unamend' to silence these hints
4772

0 commit comments

Comments
 (0)