comparison 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
comparison
equal deleted inserted replaced
45739:693da1b928af 45740:d1cabce5ef05
4039 hg import --config ui.fuzz=7 fuzz.patch 4039 hg import --config ui.fuzz=7 fuzz.patch
4040 4040
4041 Returns 0 on success, 1 on partial success (see --partial). 4041 Returns 0 on success, 1 on partial success (see --partial).
4042 """ 4042 """
4043 4043
4044 cmdutil.check_incompatible_arguments(
4045 opts, 'no_commit', ['bypass', 'secret']
4046 )
4047 cmdutil.check_incompatible_arguments(opts, 'exact', ['edit', 'prefix'])
4044 opts = pycompat.byteskwargs(opts) 4048 opts = pycompat.byteskwargs(opts)
4045 if not patch1: 4049 if not patch1:
4046 raise error.Abort(_(b'need at least one patch to import')) 4050 raise error.Abort(_(b'need at least one patch to import'))
4047 4051
4048 patches = (patch1,) + patches 4052 patches = (patch1,) + patches
4051 if date: 4055 if date:
4052 opts[b'date'] = dateutil.parsedate(date) 4056 opts[b'date'] = dateutil.parsedate(date)
4053 4057
4054 exact = opts.get(b'exact') 4058 exact = opts.get(b'exact')
4055 update = not opts.get(b'bypass') 4059 update = not opts.get(b'bypass')
4056 if not update and opts.get(b'no_commit'):
4057 raise error.Abort(_(b'cannot use --no-commit with --bypass'))
4058 if opts.get(b'secret') and opts.get(b'no_commit'):
4059 raise error.Abort(_(b'cannot use --no-commit with --secret'))
4060 try: 4060 try:
4061 sim = float(opts.get(b'similarity') or 0) 4061 sim = float(opts.get(b'similarity') or 0)
4062 except ValueError: 4062 except ValueError:
4063 raise error.Abort(_(b'similarity must be a number')) 4063 raise error.Abort(_(b'similarity must be a number'))
4064 if sim < 0 or sim > 100: 4064 if sim < 0 or sim > 100:
4065 raise error.Abort(_(b'similarity must be between 0 and 100')) 4065 raise error.Abort(_(b'similarity must be between 0 and 100'))
4066 if sim and not update: 4066 if sim and not update:
4067 raise error.Abort(_(b'cannot use --similarity with --bypass')) 4067 raise error.Abort(_(b'cannot use --similarity with --bypass'))
4068 if exact:
4069 if opts.get(b'edit'):
4070 raise error.Abort(_(b'cannot use --exact with --edit'))
4071 if opts.get(b'prefix'):
4072 raise error.Abort(_(b'cannot use --exact with --prefix'))
4073 4068
4074 base = opts[b"base"] 4069 base = opts[b"base"]
4075 msgs = [] 4070 msgs = []
4076 ret = 0 4071 ret = 0
4077 4072