D2014: amend: --no-secret overrides phases.new-commit and previous phase
spectral (Kyle Lippincott)
phabricator at mercurial-scm.org
Fri Feb 2 23:40:41 UTC 2018
spectral created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
Previously, commit --amend would keep the phase of the commit that's being
amended, and commit --amend --secret would force it to secret. There was no
mechanism to forcibly change a secret commit to draft in one step.
This change is being made mostly for parity with what users likely expect based
on the new behavior of `commit --no-secret` overriding phases.new-commit=secret;
it was confusing when writing the tests that `commit --amend --no-secret` didn't
operate the same.
Like with `commit --no-secret`, if the parent is secret, this will silently
ignore the --no-secret option and the new commit will be secret.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D2014
AFFECTED FILES
mercurial/cmdutil.py
tests/test-commit-amend.t
CHANGE DETAILS
diff --git a/tests/test-commit-amend.t b/tests/test-commit-amend.t
--- a/tests/test-commit-amend.t
+++ b/tests/test-commit-amend.t
@@ -879,11 +879,24 @@
29: draft
31: secret
+Test that amend with --no-secret creates new draft changeset forcibly
+(ignoring both the existing phase and phases.new-commit=secret)
+---------------------------------------------------------------------
+
+ $ hg phase '.^::.'
+ 29: draft
+ 31: secret
+ $ hg --config phases.new-commit=secret \
+ > commit --amend --no-secret -m 'amend as no-secret' -q
+ $ hg phase '.^::.'
+ 29: draft
+ 32: draft
+
Test that amend with --edit invokes editor forcibly
---------------------------------------------------
$ hg parents --template "{desc}\n"
- amend as secret
+ amend as no-secret
$ HGEDITOR=cat hg commit --amend -m "editor should be suppressed"
$ hg parents --template "{desc}\n"
editor should be suppressed
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3302,8 +3302,8 @@
# This not what we expect from amend.
return old.node()
- if opts.get('secret'):
- commitphase = 'secret'
+ if opts.get('secret') is not None:
+ commitphase = 'secret' if opts.get('secret') else 'draft'
else:
commitphase = old.phase()
overrides = {('phases', 'new-commit'): commitphase}
To: spectral, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list