# HG changeset patch # User Anton Shestakov # Date 1649350965 -10800 # Node ID 3e488afe62f54dc5bce68ae1d2317357e4a53c69 # Parent 53d63b6082303038b987e91e6c556d4093b5e58e topic: use compat.InputError for conflicting CLI flags diff -r 53d63b608230 -r 3e488afe62f5 hgext3rd/topic/__init__.py --- a/hgext3rd/topic/__init__.py Fri Oct 07 20:32:14 2022 -0400 +++ b/hgext3rd/topic/__init__.py Thu Apr 07 20:02:45 2022 +0300 @@ -192,6 +192,7 @@ from . import ( common, + compat, constants, destination, discovery, @@ -886,13 +887,13 @@ age = opts.get('age') if current and topic: - raise error.Abort(_(b"cannot use --current when setting a topic")) + raise compat.InputError(_(b"cannot use --current when setting a topic")) if current and clear: - raise error.Abort(_(b"cannot use --current and --clear")) + raise compat.InputError(_(b"cannot use --current and --clear")) if clear and topic: - raise error.Abort(_(b"cannot use --clear when setting a topic")) + raise compat.InputError(_(b"cannot use --clear when setting a topic")) if age and topic: - raise error.Abort(_(b"cannot use --age while setting a topic")) + raise compat.InputError(_(b"cannot use --age while setting a topic")) touchedrevs = set() if rev: diff -r 53d63b608230 -r 3e488afe62f5 hgext3rd/topic/compat.py --- a/hgext3rd/topic/compat.py Fri Oct 07 20:32:14 2022 -0400 +++ b/hgext3rd/topic/compat.py Thu Apr 07 20:02:45 2022 +0300 @@ -9,6 +9,7 @@ from mercurial import ( cmdutil, + error, extensions, pycompat, util, @@ -49,3 +50,9 @@ return orig(repo, node, branch, bheads=bheads, opts=opts) return overridefn(_orig, repo, node, branch, bheads=bheads, tip=None, opts=opts) extensions.wrapfunction(cmdutil, 'commitstatus', _override) + +if util.safehasattr(error, 'InputError'): + InputError = error.InputError +else: + # hg <= 5.6 (8d72e29ad1e0) + InputError = error.Abort diff -r 53d63b608230 -r 3e488afe62f5 tests/test-topic.t --- a/tests/test-topic.t Fri Oct 07 20:32:14 2022 -0400 +++ b/tests/test-topic.t Thu Apr 07 20:02:45 2022 +0300 @@ -254,13 +254,13 @@ [1] $ hg topics --current somerandomtopic abort: cannot use --current when setting a topic - [255] + [10] $ hg topics --current --clear abort: cannot use --current and --clear - [255] + [10] $ hg topics --clear somerandomtopic abort: cannot use --clear when setting a topic - [255] + [10] Trying some invalid topicnames @@ -1154,7 +1154,7 @@ $ hg topics --age random abort: cannot use --age while setting a topic - [255] + [10] $ cd .. Test that topics doesn't confuse branchheads checking logic