diff --git a/hgext/split.py b/hgext/split.py --- a/hgext/split.py +++ b/hgext/split.py @@ -46,6 +46,7 @@ @command('^split', [('r', 'rev', '', _("revision to split"), _('REV')), ('', 'rebase', True, _('rebase descendants after split')), + ('', 'secret', None, _('use the secret phase for committing')), ] + cmdutil.commitopts2, _('hg split [--no-rebase] [[-r] REV]')) def split(ui, repo, *revs, **opts): @@ -86,7 +87,11 @@ if ctx.phase() == phases.public: raise error.Abort(_('cannot split public changeset'), hint=_("see 'hg help phases' for details")) - opts['secret'] = ctx.phase() == phases.secret + # If the user specified --secret or --no-secret on the commandline, + # respect that; otherwise, respect the current phase of the commit + # (ignoring the phases.new-commit setting). + if opts.get('secret') is None: + opts['secret'] = ctx.phase() == phases.secret descendants = list(repo.revs('(%d::) - (%d)', rev, rev)) alloworphaned = obsolete.isenabled(repo, obsolete.allowunstableopt) diff --git a/tests/test-split.t b/tests/test-split.t --- a/tests/test-split.t +++ b/tests/test-split.t @@ -564,3 +564,32 @@ a09ad58faae3 draft e704349bd21b draft a61bcde8c529 draft + +If --secret is specified, convert draft commits to secret on split + + $ cp -R $TESTTMP/clean $TESTTMP/phases3 + $ cd $TESTTMP/phases3 + $ hg log -T '{short(node)} {phase}\n' + 1df0d5c5a3ab draft + a61bcde8c529 draft + $ runsplit --secret tip >/dev/null + $ hg log -T '{short(node)} {phase}\n' + 00eebaf8d2e2 secret + a09ad58faae3 secret + e704349bd21b secret + a61bcde8c529 draft + +If --no-secret is specified, convert secret commits to draft on split + + $ cp -R $TESTTMP/clean $TESTTMP/phases4 + $ cd $TESTTMP/phases4 + $ hg phase --secret -fr tip + $ hg log -T '{short(node)} {phase}\n' + 1df0d5c5a3ab secret + a61bcde8c529 draft + $ runsplit --no-secret tip >/dev/null + $ hg log -T '{short(node)} {phase}\n' + 00eebaf8d2e2 draft + a09ad58faae3 draft + e704349bd21b draft + a61bcde8c529 draft