# HG changeset patch # User Anton Shestakov # Date 1665417734 -14400 # Node ID 58b856416d2e53c0e94718a71a6625c36857cebd # Parent 0c780d972350cd4267a1a8089f6781ebbd848a07 topic: use compat.StateError for aborting pushes that create new heads diff -r 0c780d972350 -r 58b856416d2e hgext3rd/topic/compat.py --- a/hgext3rd/topic/compat.py Thu Apr 07 20:42:56 2022 +0300 +++ b/hgext3rd/topic/compat.py Mon Oct 10 20:02:14 2022 +0400 @@ -58,6 +58,12 @@ # hg <= 5.6 (8d72e29ad1e0) InputError = error.Abort +if util.safehasattr(error, 'StateError'): + StateError = error.StateError +else: + # hg <= 5.6 (527ce85c2e60) + StateError = error.Abort + if util.safehasattr(cmdutil, 'check_at_most_one_arg'): def check_at_most_one_arg(opts, *args): return cmdutil.check_at_most_one_arg(opts, *args) diff -r 0c780d972350 -r 58b856416d2e hgext3rd/topic/discovery.py --- a/hgext3rd/topic/discovery.py Thu Apr 07 20:42:56 2022 +0300 +++ b/hgext3rd/topic/discovery.py Mon Oct 10 20:02:14 2022 +0400 @@ -284,7 +284,7 @@ b"push creates new heads on branch '%s': %s" % (branch, heads) ) - raise error.Abort(msg) + raise compat.StateError(msg) for branch, newnb in finalheads.items(): if 1 < len(newnb): cl = repo.changelog @@ -295,7 +295,7 @@ ) hint = _(b"merge or see 'hg help push' for details about " b"pushing new heads") - raise error.Abort(msg, hint=hint) + raise compat.StateError(msg, hint=hint) def validator(tr): _validate(tr) diff -r 0c780d972350 -r 58b856416d2e tests/test-topic-push.t --- a/tests/test-topic-push.t Thu Apr 07 20:42:56 2022 +0300 +++ b/tests/test-topic-push.t Mon Oct 10 20:02:14 2022 +0400 @@ -509,4 +509,4 @@ searching for changes no changes found abort: push creates new heads on branch 'default': bbd9d6199b88 - [255] + [20]