diff mercurial/commands.py @ 45740:d1cabce5ef05

import: leverage cmdutil.check_incompatible_arguments() Differential Revision: https://phab.mercurial-scm.org/D9217
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 15 Oct 2020 21:48:43 -0700
parents 693da1b928af
children 4f7309fdfb60
line wrap: on
line diff
--- a/mercurial/commands.py	Thu Oct 15 21:44:03 2020 -0700
+++ b/mercurial/commands.py	Thu Oct 15 21:48:43 2020 -0700
@@ -4041,6 +4041,10 @@
     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 @@
 
     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 @@
         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 = []