diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -1771,6 +1771,8 @@ def tryimportone(ui, repo, patchdata, pa overrides = {} if partial: overrides[(b'ui', b'allowemptycommit')] = True + if opts.get(b'secret'): + overrides[(b'phases', b'new-commit')] = b'secret' with repo.ui.configoverride(overrides, b'import'): n = repo.commit( message, user, date, match=m, editor=editor, extra=extra diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -4033,6 +4033,7 @@ def identify( _(b'NUM'), ), (b'b', b'base', b'', _(b'base path (DEPRECATED)'), _(b'PATH')), + (b'', b'secret', None, _(b'use the secret phase for committing')), (b'e', b'edit', False, _(b'invoke editor on commit messages')), ( b'f', @@ -4181,6 +4182,8 @@ def import_(ui, repo, patch1=None, *patc update = not opts.get(b'bypass') if not update and opts.get(b'no_commit'): raise error.Abort(_(b'cannot use --no-commit with --bypass')) + if opts.get(b'secret') and opts.get(b'no_commit'): + raise error.Abort(_(b'cannot use --no-commit with --secret')) try: sim = float(opts.get(b'similarity') or 0) except ValueError: diff --git a/tests/test-completion.t b/tests/test-completion.t --- a/tests/test-completion.t +++ b/tests/test-completion.t @@ -328,7 +328,7 @@ Show all commands + options heads: rev, topo, active, closed, style, template help: extension, command, keyword, system identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure, template - import: strip, base, edit, force, no-commit, bypass, partial, exact, prefix, import-branch, message, logfile, date, user, similarity + import: strip, base, secret, edit, force, no-commit, bypass, partial, exact, prefix, import-branch, message, logfile, date, user, similarity incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos init: ssh, remotecmd, insecure locate: rev, print0, fullpath, include, exclude diff --git a/tests/test-import.t b/tests/test-import.t --- a/tests/test-import.t +++ b/tests/test-import.t @@ -435,6 +435,49 @@ hg email --plain, should read X-Mercuria date: Thu Jan 01 00:00:00 1970 +0000 summary: second change + $ hg --cwd b phase tip + 1: draft + $ rm -r b + + +hg import --secret + + $ hg clone -r0 a b -q + $ hg --cwd b import --no-commit --secret ../exported-tip.patch + abort: cannot use --no-commit with --secret + [255] + $ hg --cwd b import --secret ../exported-tip.patch + applying ../exported-tip.patch + $ hg --cwd b diff -c . --nodates + diff -r 80971e65b431 -r 1d4bd90af0e4 a + --- a/a + +++ b/a + @@ -1,1 +1,2 @@ + line 1 + +line 2 + $ hg --cwd b phase + 1: secret + $ hg --cwd b --config extensions.strip= strip 1 --no-backup --quiet + $ HGEDITOR=cat hg --cwd b import --secret --edit ../exported-tip.patch + applying ../exported-tip.patch + second change + + + HG: Enter commit message. Lines beginning with 'HG:' are removed. + HG: Leave message empty to abort commit. + HG: -- + HG: user: someone + HG: branch 'default' + HG: changed a + $ hg --cwd b diff -c . --nodates + diff -r 80971e65b431 -r 1d4bd90af0e4 a + --- a/a + +++ b/a + @@ -1,1 +1,2 @@ + line 1 + +line 2 + $ hg --cwd b phase + 1: secret $ rm -r b