Comments
Patch
@@ -1797,7 +1797,11 @@
ph = repo.ui.config('phases', 'new-commit', phases.draft)
try:
- repo.ui.setconfig('phases', 'new-commit', old.phase())
+ if opts.get('secret'):
+ commitphase = 'secret'
+ else:
+ commitphase = old.phase()
+ repo.ui.setconfig('phases', 'new-commit', commitphase)
newid = repo.commitctx(new)
finally:
repo.ui.setconfig('phases', 'new-commit', ph)
@@ -1397,6 +1397,7 @@
if opts.get('force_editor'):
e = cmdutil.commitforceeditor
+ # commitfunc is used only for temporary amend commit by cmdutil.amend
def commitfunc(ui, repo, message, match, opts):
editor = e
# message contains text from -m or -l, if it's empty,
@@ -1404,18 +1405,12 @@
if not message:
message = old.description()
editor = cmdutil.commitforceeditor
- try:
- if opts.get('secret'):
- ui.setconfig('phases', 'new-commit', 'secret')
-
- return repo.commit(message,
- opts.get('user') or old.user(),
- opts.get('date') or old.date(),
- match,
- editor=editor,
- extra=extra)
- finally:
- ui.setconfig('phases', 'new-commit', oldcommitphase)
+ return repo.commit(message,
+ opts.get('user') or old.user(),
+ opts.get('date') or old.date(),
+ match,
+ editor=editor,
+ extra=extra)
current = repo._bookmarkcurrent
marks = old.bookmarks()
@@ -765,3 +765,14 @@
$ hg ci --close-branch -m'open and close'
abort: can only close branch heads
[255]
+
+Test that amend with --secret creates new secret changeset forcibly
+---------------------------------------------------------------------
+
+ $ hg phase '.^::.'
+ 35: draft
+ 36: draft
+ $ hg commit --amend --secret -m 'amend as secret' -q
+ $ hg phase '.^::.'
+ 35: draft
+ 38: secret