Commit 2cf8c244 authored by Martin von Zweigbergk's avatar Martin von Zweigbergk

import: leverage cmdutil.check_incompatible_arguments()

Differential Revision: https://phab.mercurial-scm.org/D9217
parent 693da1b928af
......@@ -4041,6 +4041,10 @@ def import_(ui, repo, patch1=None, *patches, **opts):
Returns 0 on success, 1 on partial success (see --partial).
"""
cmdutil.check_incompatible_arguments(
opts, 'no_commit', ['bypass', 'secret']
)
cmdutil.check_incompatible_arguments(opts, 'exact', ['edit', 'prefix'])
opts = pycompat.byteskwargs(opts)
if not patch1:
raise error.Abort(_(b'need at least one patch to import'))
......@@ -4053,10 +4057,6 @@ def import_(ui, repo, patch1=None, *patches, **opts):
exact = opts.get(b'exact')
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:
......@@ -4065,11 +4065,6 @@ def import_(ui, repo, patch1=None, *patches, **opts):
raise error.Abort(_(b'similarity must be between 0 and 100'))
if sim and not update:
raise error.Abort(_(b'cannot use --similarity with --bypass'))
if exact:
if opts.get(b'edit'):
raise error.Abort(_(b'cannot use --exact with --edit'))
if opts.get(b'prefix'):
raise error.Abort(_(b'cannot use --exact with --prefix'))
base = opts[b"base"]
msgs = []
......
......@@ -26,7 +26,7 @@ Test importing an existing revision
and '--edit')
$ hg import --bypass --exact --edit ../test.diff
abort: cannot use --exact with --edit
abort: cannot specify both --exact and --edit
[255]
$ hg import --bypass --exact ../test.diff
applying ../test.diff
......@@ -188,13 +188,13 @@ Test --strip with --bypass
Test unsupported combinations
$ hg import --bypass --no-commit ../test.diff
abort: cannot use --no-commit with --bypass
abort: cannot specify both --no-commit and --bypass
[255]
$ hg import --bypass --similarity 50 ../test.diff
abort: cannot use --similarity with --bypass
[255]
$ hg import --exact --prefix dir/ ../test.diff
abort: cannot use --exact with --prefix
abort: cannot specify both --exact and --prefix
[255]
Test commit editor
......
......@@ -444,7 +444,7 @@ 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
abort: cannot specify both --no-commit and --secret
[255]
$ hg --cwd b import --secret ../exported-tip.patch
applying ../exported-tip.patch
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment