# HG changeset patch # User Martin von Zweigbergk # Date 2020-11-16 23:11:51 # Node ID b4694ef45db5f3cb2f253948265d3e7c64b4df35 # Parent b56feaa9b520413c36593af4b1f7e85498c22a29 errors: raise more specific errors from rewriteutil Differential Revision: https://phab.mercurial-scm.org/D9330 diff --git a/mercurial/rewriteutil.py b/mercurial/rewriteutil.py --- a/mercurial/rewriteutil.py +++ b/mercurial/rewriteutil.py @@ -33,20 +33,20 @@ def precheck(repo, revs, action=b'rewrit if node.nullrev in revs: msg = _(b"cannot %s null changeset") % action hint = _(b"no changeset checked out") - raise error.Abort(msg, hint=hint) + raise error.InputError(msg, hint=hint) if len(repo[None].parents()) > 1: - raise error.Abort(_(b"cannot %s while merging") % action) + raise error.StateError(_(b"cannot %s while merging") % action) publicrevs = repo.revs(b'%ld and public()', revs) if publicrevs: msg = _(b"cannot %s public changesets") % action hint = _(b"see 'hg help phases' for details") - raise error.Abort(msg, hint=hint) + raise error.InputError(msg, hint=hint) newunstable = disallowednewunstable(repo, revs) if newunstable: - raise error.Abort(_(b"cannot %s changeset with children") % action) + raise error.InputError(_(b"cannot %s changeset with children") % action) def disallowednewunstable(repo, revs): diff --git a/tests/test-amend.t b/tests/test-amend.t --- a/tests/test-amend.t +++ b/tests/test-amend.t @@ -197,7 +197,7 @@ Amend in the middle of a stack $ echo 2 >> B $ hg amend abort: cannot amend changeset with children - [255] + [10] #if obsstore-on @@ -240,7 +240,7 @@ Cannot amend public changeset $ hg amend -m AMEND abort: cannot amend public changesets (see 'hg help phases' for details) - [255] + [10] Amend a merge changeset diff --git a/tests/test-branch-change.t b/tests/test-branch-change.t --- a/tests/test-branch-change.t +++ b/tests/test-branch-change.t @@ -58,7 +58,7 @@ Change in middle of the stack (linear co $ hg branch -r 1::3 foo abort: cannot change branch of changeset with children - [255] + [10] Change with dirty working directory @@ -129,7 +129,7 @@ Changing on a branch head which is not t $ hg branch -r 2 stable abort: cannot change branch of changeset with children - [255] + [10] Enabling the allowunstable config and trying to change branch on a branch head which is not a topological head @@ -368,7 +368,7 @@ Changing branch on public changeset $ hg branch -r . def abort: cannot change branch of public changesets (see 'hg help phases' for details) - [255] + [10] Merge commit with conflicts, with evolution and without diff --git a/tests/test-commit-amend.t b/tests/test-commit-amend.t --- a/tests/test-commit-amend.t +++ b/tests/test-commit-amend.t @@ -12,7 +12,7 @@ Refuse to amend public csets: $ hg ci --amend abort: cannot amend public changesets (see 'hg help phases' for details) - [255] + [10] $ hg phase -r . -f -d $ echo a >> a @@ -407,7 +407,7 @@ Refuse to amend during a merge: (branch merge, don't forget to commit) $ hg ci --amend abort: cannot amend while merging - [255] + [20] $ hg ci -m 'merge' Refuse to amend if there is a merge conflict (issue5805): diff --git a/tests/test-fix.t b/tests/test-fix.t --- a/tests/test-fix.t +++ b/tests/test-fix.t @@ -266,11 +266,11 @@ nothing happens, even to the working dir $ hg fix -r 0 abort: cannot fix public changesets (see 'hg help phases' for details) - [255] + [10] $ hg fix -r 0 --working-dir abort: cannot fix public changesets (see 'hg help phases' for details) - [255] + [10] $ hg cat -r tip hello.whole hello $ cat hello.whole @@ -1174,7 +1174,7 @@ an orphan. We must respect experimental. $ hg commit -m "second" $ hg --config experimental.evolution.allowunstable=False fix -r '.^' abort: cannot fix changeset with children - [255] + [10] $ hg fix -r '.^' 1 new orphan changesets $ hg cat -r 2 foo.whole diff --git a/tests/test-histedit-obsolete.t b/tests/test-histedit-obsolete.t --- a/tests/test-histedit-obsolete.t +++ b/tests/test-histedit-obsolete.t @@ -309,7 +309,7 @@ Check that histedit respect immutability $ hg histedit -r '.~2' abort: cannot edit public changesets (see 'hg help phases' for details) - [255] + [10] Prepare further testing diff --git a/tests/test-rebase-collapse.t b/tests/test-rebase-collapse.t --- a/tests/test-rebase-collapse.t +++ b/tests/test-rebase-collapse.t @@ -551,7 +551,7 @@ Test collapsing a middle revision in-pla $ hg rebase --collapse -r 1 -d 0 abort: cannot rebase changeset with children (use --keep to keep original changesets) - [255] + [10] Test collapsing in place diff --git a/tests/test-rebase-scenario-global.t b/tests/test-rebase-scenario-global.t --- a/tests/test-rebase-scenario-global.t +++ b/tests/test-rebase-scenario-global.t @@ -327,15 +327,15 @@ Check rebasing public changeset $ hg rebase -d 0 -b 6 abort: cannot rebase public changesets (see 'hg help phases' for details) - [255] + [10] $ hg rebase -d 5 -b 6 abort: cannot rebase public changesets (see 'hg help phases' for details) - [255] + [10] $ hg rebase -d 5 -r '1 + (6::)' abort: cannot rebase public changesets (see 'hg help phases' for details) - [255] + [10] $ hg rebase -d 5 -b 6 --keep rebasing 6:e1c4361dd923 "C" @@ -455,7 +455,7 @@ Source on have two descendant heads but $ hg rebase -r '2::8' -d 1 abort: cannot rebase changeset with children (use --keep to keep original changesets) - [255] + [10] $ hg rebase -r '2::8' -d 1 -k rebasing 2:c9e50f6cdc55 "C" rebasing 3:ffd453c31098 "D" @@ -501,7 +501,7 @@ Base on have one descendant heads we ask $ hg rebase -r '3::8' -d 1 abort: cannot rebase changeset with children (use --keep to keep original changesets) - [255] + [10] $ hg rebase -r '3::8' -d 1 --keep rebasing 3:ffd453c31098 "D" rebasing 6:3d8a618087a7 "G" @@ -544,7 +544,7 @@ rebase subset $ hg rebase -r '3::7' -d 1 abort: cannot rebase changeset with children (use --keep to keep original changesets) - [255] + [10] $ hg rebase -r '3::7' -d 1 --keep rebasing 3:ffd453c31098 "D" rebasing 6:3d8a618087a7 "G" @@ -584,7 +584,7 @@ rebase subset with multiple head $ hg rebase -r '3::(7+5)' -d 1 abort: cannot rebase changeset with children (use --keep to keep original changesets) - [255] + [10] $ hg rebase -r '3::(7+5)' -d 1 --keep rebasing 3:ffd453c31098 "D" rebasing 4:c01897464e7f "E" diff --git a/tests/test-split.t b/tests/test-split.t --- a/tests/test-split.t +++ b/tests/test-split.t @@ -79,7 +79,7 @@ Cannot split a public changeset $ hg split . abort: cannot split public changesets (see 'hg help phases' for details) - [255] + [10] $ hg phase --draft -f -r 'all()' @@ -467,7 +467,7 @@ Split a non-head without rebase #if obsstore-off $ runsplit -r 1 --no-rebase abort: cannot split changeset with children - [255] + [10] #else $ runsplit -r 1 --no-rebase >/dev/null 3 new orphan changesets @@ -518,7 +518,7 @@ Split a non-head with obsoleted descenda $ rm .hg/localtags $ hg split $B --config experimental.evolution=createmarkers abort: cannot split changeset with children - [255] + [10] $ cat > $TESTTMP/messages < Split B > EOF diff --git a/tests/test-unamend.t b/tests/test-unamend.t --- a/tests/test-unamend.t +++ b/tests/test-unamend.t @@ -284,7 +284,7 @@ Unamending in middle of a stack $ hg --config experimental.evolution=createmarkers unamend abort: cannot unamend changeset with children - [255] + [10] $ hg unamend 3 new orphan changesets @@ -298,7 +298,7 @@ Trying to unamend a public changeset $ hg unamend abort: cannot unamend public changesets (see 'hg help phases' for details) - [255] + [10] Testing whether unamend retains copies or not diff --git a/tests/test-uncommit.t b/tests/test-uncommit.t --- a/tests/test-uncommit.t +++ b/tests/test-uncommit.t @@ -53,7 +53,7 @@ Uncommit with no commits should fail $ hg uncommit abort: cannot uncommit null changeset (no changeset checked out) - [255] + [10] Create some commits @@ -411,7 +411,7 @@ Add and expect uncommit to fail on both $ hg uncommit --config experimental.uncommitondirtywdir=True abort: cannot uncommit while merging - [255] + [20] $ hg status M a