D2017: split: accept a --secret flag to force phase of new commits
spectral (Kyle Lippincott)
phabricator at mercurial-scm.org
Fri Feb 2 23:40:30 UTC 2018
spectral created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
This is for parity with the identically named option on the `hg commit`
(including `hg commit --amend`) command.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D2017
AFFECTED FILES
hgext/split.py
tests/test-split.t
CHANGE DETAILS
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
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)
To: spectral, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list