diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1582,8 +1582,9 @@ else: def commitfunc(ui, repo, message, match, opts): overrides = {} - if opts.get('secret'): - overrides[('phases', 'new-commit')] = 'secret' + if opts.get('secret') is not None: + overrides[('phases', 'new-commit')] = ( + 'secret' if opts.get('secret') else 'draft') baseui = repo.baseui with baseui.configoverride(overrides, 'commit'): diff --git a/tests/test-commit.t b/tests/test-commit.t --- a/tests/test-commit.t +++ b/tests/test-commit.t @@ -832,3 +832,16 @@ $ cd .. +Test that --secret/--no-secret make secret/draft commits, regardless of +phases.new-commit + + $ hg init phasetest + $ cd phasetest + $ echo foo > foo + $ hg --config phases.new-commit=secret commit -qAm 'force draft' --no-secret + $ hg phase -r . + 0: draft + $ echo foo2 >> foo + $ hg --config phases.new-commit=draft commit -qAm 'force secret' --secret + $ hg phase -r . + 1: secret