# HG changeset patch # User Martin von Zweigbergk # Date 1669765288 28800 # Node ID e78a4168646426c7f9b9364d9d19cabc24cad9ea # Parent f0e9dda408b31eb73df52423d48ba719ff7e9151 amend: add a --draft option to set phase to draft Some users create commits in secret phase by default and then want to make them draft so they can be uploaded. This patch adds a --draft option for that. We already have a flag for changing the phase to secret, so it seems consistent to have one for draft. diff -r f0e9dda408b3 -r e78a41686464 hgext/amend.py --- a/hgext/amend.py Tue Nov 29 13:07:16 2022 -0800 +++ b/hgext/amend.py Tue Nov 29 15:41:28 2022 -0800 @@ -46,6 +46,7 @@ _(b'mark a branch as closed, hiding it from the branch list'), ), (b's', b'secret', None, _(b'use the secret phase for committing')), + (b'', b'draft', None, _(b'use the draft phase for committing')), (b'n', b'note', b'', _(b'store a note on the amend')), ] + cmdutil.walkopts @@ -64,6 +65,7 @@ See :hg:`help commit` for more details. """ + cmdutil.check_at_most_one_arg(opts, 'draft', 'secret') cmdutil.check_note_size(opts) with repo.wlock(), repo.lock(): diff -r f0e9dda408b3 -r e78a41686464 mercurial/cmdutil.py --- a/mercurial/cmdutil.py Tue Nov 29 13:07:16 2022 -0800 +++ b/mercurial/cmdutil.py Tue Nov 29 15:41:28 2022 -0800 @@ -3019,6 +3019,8 @@ commitphase = None if opts.get(b'secret'): commitphase = phases.secret + elif opts.get(b'draft'): + commitphase = phases.draft newid = repo.commitctx(new) ms.reset() diff -r f0e9dda408b3 -r e78a41686464 tests/test-amend.t --- a/tests/test-amend.t Tue Nov 29 13:07:16 2022 -0800 +++ b/tests/test-amend.t Tue Nov 29 15:41:28 2022 -0800 @@ -560,6 +560,12 @@ close=1 phase=secret +`hg amend --draft` sets phase to draft + + $ hg amend --draft -m declassified + $ hg log --limit 1 -T 'phase={phase}\n' + phase=draft + $ cd .. Corner case of amend from issue6157: