# HG changeset patch # User Anton Shestakov # Date 1646577993 -10800 # Node ID 1e7190adffcad08328616f276c8926d67e39ae48 # Parent e58e4af1a730694a727f1fa952b014f7bc8d8493 fixup: use compat.InputError for invalid user input diff -r e58e4af1a730 -r 1e7190adffca hgext3rd/evolve/cmdrewrite.py --- a/hgext3rd/evolve/cmdrewrite.py Mon Mar 07 13:33:57 2022 +0300 +++ b/hgext3rd/evolve/cmdrewrite.py Sun Mar 06 17:46:33 2022 +0300 @@ -1485,9 +1485,9 @@ abortopt = opts.get('abort') if node or opts.get('rev'): if contopt: - raise error.Abort(_(b'cannot specify a revision with --continue')) + raise compat.InputError(_(b'cannot specify a revision with --continue')) if abortopt: - raise error.Abort(_(b'cannot specify a revision with --abort')) + raise compat.InputError(_(b'cannot specify a revision with --abort')) # state file for --continue/--abort cases fixup_state = state.cmdstate(repo, b'fixup-state') if contopt: @@ -1502,11 +1502,11 @@ return abortfixup(ui, repo, fixup_state) if node and opts.get('rev'): - raise error.Abort(_(b'please specify just one revision')) + raise compat.InputError(_(b'please specify just one revision')) if not node: node = opts.get('rev') if not node: - raise error.Abort(_(b'please specify a revision to fixup')) + raise compat.InputError(_(b'please specify a revision to fixup')) target_ctx = scmutil.revsingle(repo, node) fixup_state[b'startnode'] = repo[b'.'].node() diff -r e58e4af1a730 -r 1e7190adffca hgext3rd/evolve/compat.py --- a/hgext3rd/evolve/compat.py Mon Mar 07 13:33:57 2022 +0300 +++ b/hgext3rd/evolve/compat.py Sun Mar 06 17:46:33 2022 +0300 @@ -424,17 +424,12 @@ def to_display(name): return pycompat.sysbytes(name).replace(b'_', b'-') - if util.safehasattr(error, 'InputError'): - err = error.InputError - else: - # hg <= 5.6 (8d72e29ad1e0) - err = error.Abort previous = None for x in args: if opts.get(x): if previous: - raise err(_(b'cannot specify both --%s and --%s') - % (to_display(previous), to_display(x))) + raise InputError(_(b'cannot specify both --%s and --%s') + % (to_display(previous), to_display(x))) previous = x return previous @@ -570,3 +565,9 @@ # hg <= 5.9 (dcd97b082b3b) def dirchanges(dirstate): return [f for f in dirstate if dirstate[f] != b'n'] + +if util.safehasattr(error, 'InputError'): + InputError = error.InputError +else: + # hg <= 5.6 (8d72e29ad1e0) + InputError = error.Abort diff -r e58e4af1a730 -r 1e7190adffca tests/test-fixup.t --- a/tests/test-fixup.t Mon Mar 07 13:33:57 2022 +0300 +++ b/tests/test-fixup.t Sun Mar 06 17:46:33 2022 +0300 @@ -307,15 +307,15 @@ $ hg fixup tip --abort abort: cannot specify a revision with --abort - [255] + [10] $ hg fixup -r tip --continue abort: cannot specify a revision with --continue - [255] + [10] $ hg fixup abort: please specify a revision to fixup - [255] + [10] $ hg fixup tip nothing changed @@ -342,7 +342,7 @@ $ hg fixup :10 -r 5 abort: please specify just one revision - [255] + [10] $ cd ..