changeset 49772:e78a41686464

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.
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 29 Nov 2022 15:41:28 -0800
parents f0e9dda408b3
children 5d9725182d8d
files hgext/amend.py mercurial/cmdutil.py tests/test-amend.t
diffstat 3 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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():
--- 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()
 
--- 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: